我正在寻找有关如何从sparql端点(如DBPedia)使用和解析数据的教程.我是语义网和rdf和sparql的新手.我只是将响应视为XML并使用众多第三方xml解析器之一来读取rdf输入吗?
在iphone上使用sparql端点的好教程链接会很棒
鉴于一位音乐艺术家,我正在努力寻找其他音乐艺术家,他们与一位特定的艺术家拥有最常见的"相关行为".我对Eminem有以下查询,它工作正常
SELECT ?c (COUNT(*) AS ?count) WHERE {
{
?b <http://dbpedia.org/property/associatedActs> <http://dbpedia.org/resource/Eminem>.
?b <http://dbpedia.org/property/associatedActs> ?
}
}group by ?c order by desc(?count) LIMIT 10
Run Code Online (Sandbox Code Playgroud)
但我想回到艺术家的图片以及他们的dbpedia资源链接(?c)添加.试试这个
SELECT ?c (COUNT(*) AS ?count) WHERE {
{
?b <http://dbpedia.org/property/associatedActs> <http://dbpedia.org/resource/Eminem>.
?b <http://dbpedia.org/property/associatedActs> ?c.
?c <http://dbpedia.org/ontology/thumbnail> ?i
}
}group by ?c order by desc(?count) LIMIT 10
Run Code Online (Sandbox Code Playgroud)
给我一个错误"变量?我在聚合之外的结果集中使用,而在GROUP BY子句中没有提到".如果我分组我的工作正常,但我不能回来.
那么如何才能获得其他匹配艺术家的图片和资源链接?
有谁知道在java或scala中使用dbpedia聚光灯的地方怎么样?或者任何人都可以解释它是如何完成的?我找不到任何关于此的信息......
我想通过JSON获取Wikiquote页面的结构化版本(基本上我需要所有短语)
示例: http ://en.wikiquote.org/wiki/Fight_Club_(film)
我尝试过:http://en.wikiquote.org/w/api.php?format = xml&action = paarse&page = Fight_Club_(film)&prop = text
但是我得到了所有的HTML源代码.我需要每个pharse作为Array的元素
我怎么能用DBPEDIA实现这个目标?
我试图从DBpedia中为某些人提取标签.我现在部分成功,但我遇到了以下问题.以下代码有效.
public class DbPediaQueryExtractor {
public static void main(String [] args) {
String entity = "Aharon_Barak";
String queryString ="PREFIX dbres: <http://dbpedia.org/resource/> SELECT * WHERE {dbres:"+ entity+ "<http://www.w3.org/2000/01/rdf-schema#label> ?o FILTER (langMatches(lang(?o),\"en\"))}";
//String queryString="select * where { ?instance <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person>; <http://www.w3.org/2000/01/rdf-schema#label> ?o FILTER (langMatches(lang(?o),\"en\")) } LIMIT 5000000";
QueryExecution qexec = getResult(queryString);
try {
ResultSet results = qexec.execSelect();
for ( ; results.hasNext(); )
{
QuerySolution soln = results.nextSolution();
System.out.print(soln.get("?o") + "\n");
}
}
finally {
qexec.close();
}
}
public static QueryExecution getResult(String queryString){ …
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试为我必须展示的用例创建一个 dbpedia 数据示例。我的主要目标是要求每位欧洲艺术家 5 幅五幅画(而且我想在开始时每个国家只展示两位艺术家)。
没有限制的查询如下。
PREFIX dbpedia-owl:<http://dbpedia.org/ontology/>
PREFIX category: <http://dbpedia.org/resource/Category:>
PREFIX dcterms:<http://purl.org/dc/terms/>
PREFIX prop:<http://dbpedia.org/property/>
PREFIX geonames:<http://sws.geonames.org/>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia:<http://dbpedia.org/resource/>
PREFIX geo-ont:<http://www.geonames.org/ontology#>
PREFIX ourvocab:<http://example.org/>
prefix foaf:<http://xmlns.com/foaf/0.1/>
SELECT DISTINCT ?painting_name ?artist_name ?european_country ?description ?artist_birthday_year
WHERE {
?european_country dcterms:subject category:Countries_in_Europe.
?european_country rdf:type dbpedia-owl:Place.
?painting prop:artist ?artist.
?painting rdfs:label ?painting_name.
?painting prop:type dbpedia:Oil_painting.
?painting rdfs:comment ?description.
?artist foaf:name ?artist_name.
?artist rdf:type dbpedia-owl:Artist.
?artist prop:placeOfBirth ?european_country.
?artist dbpedia-owl:birthDate ?artist_birthday.
FILTER (lang(?painting_name) = "" || lang(?painting_name) = "en")
FILTER (lang(?description) = "" || lang(?description) …
Run Code Online (Sandbox Code Playgroud) 我想从维基百科页面获取主图像,我有所有维基百科实体名称,我从中创建维基链接并从该页面获取主图像。
我试过
https://github.com/richardasaurus/wiki-api , https://github.com/goldsmith/Wikipedia
但这并不适用于所有页面,尽管页面包含图像。
from wikiapi import WikiApi
wiki = WikiApi()
wiki = WikiApi({ 'locale' : 'es'})
def getWikiImage(entity):
results = wiki.find(entity)
print results
if len(results):
article = wiki.get_article(results[0])
print article.image
#getWikiImage("Rudy Sarzo")
getWikiImage("Melody Gersbach")
Run Code Online (Sandbox Code Playgroud)
位于http://www.mediawiki.org/wiki/API:Client_code#Python 的mediawiki api我检查了,但似乎没有帮助。
我写了这个查询并返回夫妻和特定条件的列表.(在http://live.dbpedia.org/sparql中)
SELECT DISTINCT ?actor ?person2 ?cnt
WHERE
{
{
select DISTINCT ?actor ?person2 (count (?film) as ?cnt)
where {
?film dbo:starring ?actor .
?actor dbo:spouse ?person2.
?film dbo:starring ?person2.
}
order by ?actor
}
FILTER (?cnt >9)
}
Run Code Online (Sandbox Code Playgroud)
问题是某些行是重复的.例:
http://dbpedia.org/resource/George_Burns http://dbpedia.org/resource/Gracie_Allen 12
http://dbpedia.org/resource/Gracie_Allen http://dbpedia.org/resource/George_Burns 12
如何删除这些重复?我将性别添加到?actor但它会损害当前结果.
我想从维基数据中获取特定类别的所有成员。例如,我想P31 Q11424
从类别“类别:以斯德哥尔摩为背景的电影”( ) 中获取所有电影(电影实例: ) Q7519614
。但是,我似乎找不到这种关系。DBpedia 使用“主题”,但 Wikidata 的等效项 ( P805
) 不返回任何结果。
我还以为我可以通过此查询引导找到答案,但无济于事:
SELECT ?s ?p ?pLabel WHERE {
?s ?p wd:Q7519614.
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
Run Code Online (Sandbox Code Playgroud) 我想从 dbpedia 端点获取数据,在 vue js 中使用 axios。
我曾经axios.get
从 dbpedia 获取数据,但在控制台中出现错误提示:
类型错误:name.toUpperCase 不是函数
我该如何解决?
created(){
this.fetch();
},
methods: {
fetch(){
axios
.get('http://id.dbpedia.org/sparql?query=SELECT+DISTINCT+?concept+WHERE+{+?s+a+?concept+}+LIMIT+50', {
headers: 'Access-Control-Allow-Origin: *'
}).then(response => {
/* eslint-disable */
console.log('SUCCESS');
console.log(response);
}).catch((e) => {
console.log(e);
})
}
},
Run Code Online (Sandbox Code Playgroud)