在 SPARQL 中选择 "is dbp:variable of" 形式的变量

Selecting variable in form of "is dbp:variable of" in SPARQL

我正在尝试 select 使用 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:northeast 应该是

Comilla_Division, Rangpur_Division

但它 select 是一长串其他事情。我想问题可能是在 DBPedia 中是这个语法中的变量:"is dbp:northeast of".

有人知道如何为此制定查询吗?

谢谢!

至于"is ... of",参见。您的查询应该是:

SELECT ?northeast ?ne WHERE {
    ?northeast dbp:northeast dbr:India 
    OPTIONAL {?northeast foaf:name ?ne}
}

Try it!

SELECT ?northeast ?ne WHERE {
    VALUES (?country) {(dbr:India)}
    ?country ^dbp:northeast ?northeast; rdfs:label ?ne.
    FILTER (lang(?ne) = "en") .
}

Try it!


更有趣的是,为什么返回 "long list of other things" 而不是空结果集。

来自In SPARQL, Order Matters

SPARQL evaluation starts out over the so-called “empty mapping” (also called “universal mapping”): [if] the OPTIONAL block is not able to retrieve any results, and given the semantics of OPTIONAL, this step simply retains the empty mapping.

一般来说,永远不要以 OPTIONAL 开头。