0

我想从 dbpedia 获取一些数据。我有实体 url,想获得一些关于本地化的信息。现在我这样调用查询:

PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
PREFIX dbo: <http://dbpedia.org/ontology/>

SELECT DISTINCT * WHERE 
{
  <{0}> rdfs:label ?label . 
    OPTIONAL {
     <{0}> geo:lat ?lat ;
     geo:long ?long .
    } .
    OPTIONAL {
     <{0}> dbo:Country ?dboCountry 
    } . 
    OPTIONAL {
     <{0}> dbpedia-owl:country ?dbpediaContry .
     ?dbpediaContry dbpprop:cctld ?ccTLD
    }. 
    OPTIONAL {
     <{0}> dbpprop:country  ?dbpropContry
    }
    FILTER ( lang(?label) = "en" )
}

对于每个 url(将 {0} 替换为 url)。但我想优化它并在一个查询中获得更多实体的结果。也可以不在每一行中设置 url 吗?

问候彼得

4

1 回答 1

1

嗯,看来我已经找到了这两个问题的答案。你知道吗(http://en.wikipedia.org/wiki/Rubber_duck_debugging)解决方案是:

 SELECT DISTINCT *

        WHERE {
            ?uri rdfs:label ?label .
            OPTIONAL { ?uri geo:lat ?lat .
                       ?uri geo:long ?long} .
  
        FILTER (?uri IN ({0}, {1}, ...)  )
        }

也许它对其他人有帮助?或者也许有人知道更好的解决方案?

于 2012-09-18T20:55:08.663 回答