Maa*_*mon 1 sparql triplestore stardog
我正在尝试在同义词库中的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") .
}}
Run Code Online (Sandbox Code Playgroud)
有效的确切匹配查询如下:
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")
}
}
Run Code Online (Sandbox Code Playgroud)
编辑1
数据样本:
<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> ;
Run Code Online (Sandbox Code Playgroud)
如果不查看您的数据,我们将无法知道您的查询为什么不起作用。但是,使用包含非常简单。这只是contains(string,substring)的问题。正如Jeen所说,在不知道您的数据是什么样的情况下,我们无法重现您的问题,但这是一个包含的示例作用:
select distinct ?country ?label {
?country a dbpedia-owl:Country ; #-- select countries
rdfs:label ?label . #-- and get labels
filter langMatches(lang(?label),"en") #-- but only English labels
filter contains(?label,"land") #-- containing "land"
}
Run Code Online (Sandbox Code Playgroud)