1

我试图在我的同义词库中的 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")
    }
}

编辑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> ;
4

1 回答 1

5

如果没有看到您的数据,我们就无法知道您的查询为什么不起作用。但是,使用contains非常简单。这只是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"
}

SPARQL 结果

于 2015-07-07T13:07:03.600 回答