Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

How do it?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
234 views
Welcome To Ask or Share your Answers For Others

1 Answer

Also asked here. Accepted answer said --

When you say classes, are you mean about types? If yes, try something like

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

I couldn't let this go...

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...