为什么DBPedia查询给定的Wikipedia URL仅对某些URL有效?

时间:2018-12-19 22:16:45

标签: sparql dbpedia wikipedia-api

我有一个指向维基百科页面的URL列表,并在lod.openlinksw.com端点上查询dbpedia数据。代码与此question中的代码相同。 最好理解的是:对于某些url,如果dbpedia页面具有正确的foaf:isPrimaryTopicOf url,怎么可能不起作用?

这是对相应的dbpediawikipedia页面的简化查询。

   PREFIX foaf: <http://xmlns.com/foaf/0.1/>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

   SELECT Distinct ?name ?s ?url WHERE {
   ?s a foaf:Person .
   FILTER NOT EXISTS { ?s  rdf:type  dbo:FictionalCharacter }.
   ?s foaf:isPrimaryTopicOf ?url.
   ?s rdfs:label ?name.
   filter(langMatches(lang(?name), "en")).
   ?s foaf:isPrimaryTopicOf <http://en.wikipedia.org/wiki/Adi_Shankara>.
   }
   LIMIT 1

从具有从Wikipedia提取的〜40个网址的列表中,我得到〜10个空响应。首先,我认为url可能有问题,但是大多数看起来都不错。这里有更多的“无效”案例:

  • 用于查询>> en.wikipedia.org/wiki/Harald_I_of_Norway,
    dbpedia.org/page/Harald_Fairhair >>
    en.wikipedia.org/wiki/Harald_Fairhair
  • 用于查询>> en.wikipedia.org/wiki/Ivar_the_Boneless,
    dbpedia.org/page/Ivar_the_Boneless >>
    en.wikipedia.org/wiki/Ivar_the_Boneless
  • 用于查询>>en.wikipedia.org/wiki/Jayarāśi_Bhaṭṭa,
    dbpedia.org/page/Jayarāśi_Bhaṭṭa>>
    en.wikipedia.org/wiki/Jayarāśi_Bhaṭṭa
  • 用于查询>> en.wikipedia.org/wiki/Kenneth_I_of_Scotland,
    dbpedia.org/page/Kenneth_MacAlpin >>
    en.wikipedia.org/wiki/Kenneth_MacAlpin
  • 用于查询>> en.wikipedia.org/wiki/Li_Deyu,
    dbpedia.org/page/Li_Deyu >>
    en.wikipedia.org/wiki/Li_Deyu

在第一种情况(Harald_Fairhair)和第四种情况(Kenneth_MacAlpin)中,有不同的URL指向同一个Wikipage,因此我需要找出如何处理此类情况。但是我不明白为什么其余的都不起作用。任何帮助,将不胜感激。

1 个答案:

答案 0 :(得分:0)

基于注释线程的修订查询

   PREFIX foaf: <http://xmlns.com/foaf/0.1/>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   PREFIX  rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

   SELECT DISTINCT ?name ?s ?url 
   WHERE {
     VALUES ?url { <http://en.wikipedia.org/wiki/Adi_Shankara> 
                   <http://en.wikipedia.org/wiki/Harald_I_of_Norway> 
                   <http://en.wikipedia.org/wiki/Ivar_the_Boneless> 
                   <http://en.wikipedia.org/wiki/Jayarāśi_Bhaṭṭa> 
                   <http://en.wikipedia.org/wiki/Kenneth_I_of_Scotland> 
                   <http://en.wikipedia.org/wiki/Li_Deyu> 
                 }

                       ?s ^dbo:wikiPageRedirects*
                          /foaf:isPrimaryTopicOf  ?url .
   FILTER NOT EXISTS { ?s  rdf:type               dbo:FictionalCharacter }
                       ?s  rdfs:label             ?name .
   FILTER(langMatches(LANG(?name), "en")).
   }

原始答案

this query(和DBpedia的live results)如何为您服务?

   PREFIX foaf: <http://xmlns.com/foaf/0.1/>
   PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
   PREFIX  rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

   SELECT Distinct ?name ?s ?url WHERE {
   VALUES ?url { <http://en.wikipedia.org/wiki/Adi_Shankara> 
                 <http://en.wikipedia.org/wiki/Harald_I_of_Norway> 
                 <http://en.wikipedia.org/wiki/Ivar_the_Boneless> 
                 <http://en.wikipedia.org/wiki/Jayarāśi_Bhaṭṭa> 
                 <http://en.wikipedia.org/wiki/Kenneth_I_of_Scotland> 
                 <http://en.wikipedia.org/wiki/Li_Deyu> 
               }

                       ?s  foaf:isPrimaryTopicOf  ?url .
#                      ?s  rdf:type               foaf:Person .
   FILTER NOT EXISTS { ?s  rdf:type               dbo:FictionalCharacter }
                       ?s  rdfs:label             ?name .
   FILTER(langMatches(LANG(?name), "en")).
#  ?s foaf:isPrimaryTopicOf <http://en.wikipedia.org/wiki/Adi_Shankara>.
   }
#   LIMIT 10

这有什么帮助您了解以前出了什么问题吗?