我想从DBPedia中提取5个电影(或电影)个人的图形。
我的查询是:
ParameterizedSparqlString qs = new ParameterizedSparqlString(“ +
” construct {?s?p?o}“ +” where {?http://dbpedia.org/ontology/Film。"+“?s?p?o”}偏移量0 LIMIT 5“);
我得到以下结果:
1- http://dbpedia.org/resource/1001_Inventions_and_the_World_of_Ibn_Al-Haytham http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://dbpedia.org/ontology/Film。
2- http://dbpedia.org/resource/1001_Inventions_and_the_World_of_Ibn_Al-Haytham http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.w3.org/2002/ 07 / owl#Thing。
3- http://dbpedia.org/resource/1001_Inventions_and_the_World_of_Ibn_Al-Haytham http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://www.wikidata.org/entity/ Q386724。
4- http://dbpedia.org/resource/1001_Inventions_and_the_World_of_Ibn_Al-Haytham http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://dbpedia.org/ontology/Wikidata: Q11424。
5- http://dbpedia.org/resource/1001_Inventions_and_the_World_of_Ibn_Al-Haytham http://www.w3.org/1999/02/22-rdf-syntax-ns#type http://dbpedia.org/ontology/Work。
问题:相同的影片是所有类别的5次返回:Film,Thing,Q386724,WIKIdata:Q11424和Work是等效类别(或存在Subclass关系)。
我的问题:
我想一次返回
<http://dbpedia.org/resource/1001_Inventions_and_the_World_of_Ibn_Al-Haytham>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://dbpedia.org/ontology/Film> .
Run Code Online (Sandbox Code Playgroud)
并滤除其他4个三元组
怎么办?
先感谢您
我认为以下应为您工作:
CONSTRUCT {?s ?p ?o}
WHERE {
{ SELECT DISTINCT ?s
WHERE {
?s a <http://dbpedia.org/ontology/Film> .
} LIMIT 5
}
?s ?p ?o .
}
Run Code Online (Sandbox Code Playgroud)