我正在尝试使用SPARQL从DBPedia中选择东北方向的某个国家(例如印度)。我使用的是查询:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbp: <http://dbpedia.org/property/>
SELECT ?northeast ?ne
WHERE {
OPTIONAL {<http://dbpedia.org/resource/India> dbp:northeast ?northeast }
. OPTIONAL {?northeast foaf:name ?ne}
}在变量dbp中的位置:东北应该是
Comilla_Division,Rangpur_Division
但它选择了其他事情的长列表。我想问题可能是,在DBPedia中,这个语法中的变量是:"is :东北of“。
有人知道如何制定这方面的查询吗?
谢谢!
发布于 2018-03-13 10:28:31
至于"is . of",请参见这个答案。您的查询应该是:
SELECT ?northeast ?ne WHERE {
?northeast dbp:northeast dbr:India
OPTIONAL {?northeast foaf:name ?ne}
}或
SELECT ?northeast ?ne WHERE {
VALUES (?country) {(dbr:India)}
?country ^dbp:northeast ?northeast; rdfs:label ?ne.
FILTER (lang(?ne) = "en") .
}更有趣的是,为什么返回“其他事情的长列表”而不是返回空的结果集。
SPARQL计算从所谓的“空映射”(也称为“通用映射”)开始:如果可选块无法检索任何结果,并且给定可选语义,则此步骤只保留空映射。
一般来说,永远不要从OPTIONAL开始。
https://stackoverflow.com/questions/49253458
复制相似问题