【发布时间】:2015-07-06 20:31:00
【问题描述】:
我试图在我的同义词库中的 dbpedia 中获取一些定义。
虽然可以找到标签与我所在国家/地区相匹配的国家/地区,但我没有找到所有这些国家/地区。所以我尝试将类似的标签与包含匹配,但它不起作用。
知道为什么。
SELECT distinct ?idbcountry ?label ?labelDb ?def
WHERE {
?idbcountry a skos:Concept .
?idbcountry rdfs:label ?label .
?idbcountry skos:inScheme iadb:IdBCountries .
FILTER(lang(?label) = "en")
Service <http://dbpedia.org/sparql> {
?s a <http://dbpedia.org/ontology/Country> .
?s rdfs:label ?labelDb .
FILTER(CONTAINS (?labelDb, ?label)).
?s rdfs:comment ?def .
FILTER(lang(?def) = "en") .
FILTER(lang(?labelDb) = "en") .
}}
有效的完全匹配查询如下:
SELECT distinct ?idbcountry ?label ?def
WHERE {
?idbcountry a skos:Concept .
?idbcountry rdfs:label ?label .
?idbcountry skos:inScheme iadb:IdBCountries .
FILTER(lang(?label) = "en")
Service <http://dbpedia.org/sparql> {
?s a <http://dbpedia.org/ontology/Country> .
?s rdfs:label ?label .
?s rdfs:comment ?def
FILTER(lang(?def) = "en")
}
}
EDIT1
数据样本:
<http://thesaurus.iadb.org/publicthesauri/10157002136735779158437>
rdf:type skos:Concept ;
dct:created "2015-03-27T16:43:48.052-04:00"^^xsd:dateTime ;
rdfs:label "BO"@en ;
rdfs:label "Bolivia"@en ;
rdfs:label "Bolivia"@es ;
rdfs:label "Bolivie"@fr ;
rdfs:label "Bolívia"@pt ;
skos:altLabel "BO"@en ;
skos:definition "Bolivia (/bəˈlɪviə/, Spanish: [boˈliβja], Quechua: Buliwya, Aymara: Wuliwya), officially known as the Plurinational State of Bolivia (Spanish: Estado Plurinacional de Bolivia locally: [esˈtaðo pluɾinasjoˈnal de βoˈliβja]), is a landlocked country located in western-central South America."@en ;
skos:inScheme :IdBCountries ;
skos:prefLabel "Bolivia"@en ;
skos:prefLabel "Bolivia"@es ;
skos:prefLabel "Bolivie"@fr ;
skos:prefLabel "Bolívia"@pt ;
skos:topConceptOf :IdBCountries ;
<http://xmlns.com/foaf/0.1/focus> <http://dbpedia.org/resource/Bolivia> ;
【问题讨论】:
-
可能是因为
?labelDB的值实际上并不包含?label的值作为子字符串,所以查询不起作用。但由于您没有向我们展示您的数据,因此无法确定。 -
@JeenBroekstra 我知道首先评估子选择查询(从最内到最外);你知道这是否也适用于服务表格?如果是这样,那么 ?label 甚至可能在服务块中没有值。
-
@JoshuaTaylor 如果不查看规范,我不能 100% 确定自己,但您可能是对的。如果是这种情况,解决方法是将 FILTER 子句从 SERVICE 子句内部移动到 behind 它 - 尽管可能会降低查询效率。
-
这很奇怪,因为我在我看过的每本 sparql 书中几乎都是红色的,当你交叉引用时,就像在我的第二个示例中一样,?label 已经绑定到最外层查询的值。这是否意味着,事实上他们都说的只是阅读方式而不是工作方式?
标签: sparql triplestore stardog