本文介绍了如何从dbpedia中查找类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个给出自由文本(用户输入)的sparql查询,它从dbpedia中找到了所有与之相关的类.

I need a sparql query that given a free text (user input), it finds me from dbpedia all the classes related to it.

怎么做?

推荐答案

也要求此处.接受的答案说-

Also asked here. Accepted answer said --

SELECT ?uri ?label ?type
WHERE {
?uri rdfs:label ?label .
?uri <http://dbpedia.org/ontology/type> ?type .
FILTER regex(str(?label), "Leipzig") .
}
limit 10

我不能放弃...

PREFIX     rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
PREFIX  virtdrf:  <http://www.openlinksw.com/schemas/virtrdf#>

SELECT      ?s1c AS ?c1 
       COUNT (*) AS ?c2 
                    ?c3
WHERE 
  { 
    QUAD MAP virtrdf:DefaultQuadMap 
    { 
      GRAPH ?g 
      { 
         ?s1  ?s1textp      ?o1          .
         ?o1  bif:contains  '"dbpedia"'  .
      }
    }
    ?s1 a ?s1c .
    OPTIONAL { ?s1c  rdfs:label  ?c3 
               FILTER(langMatches(LANG(?c3),"EN"))}
  }
GROUP BY ?s1c ?c3
ORDER BY DESC (2) ASC (3)

较早的答案可以使您获得部分结果.

The earlier answer gets you partial results.

这篇关于如何从dbpedia中查找类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 18:55