Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query dbpedia to find possible contexts to disambiguate a word

Good day, stackoverflow,

I need to suggest to user different contexts for a word, so that he could have a possibility to disambuguate it.

For example: a word "less" can be Unix program, css framework or some other things. A word "apple" can be a fruit, a corporation, a river, a state in the US (big apple) or a bunch of other things.

I hope you got the idea.

I looked over the internet and so far I could come up only with this query.

But it's still far from being perfect. It often gives too much or too few words and sometimes nothing (for "jquery").

http://www.visualdataweb.org/relfinder/relfinder.php seems to use dbpedia as well, but its results are far better than mine.

How should I change my query to get more relevant results?

like image 603
Mironor Avatar asked May 13 '12 14:05

Mironor


1 Answers

If you are looking for a Web API, use: DBpedia Lookup or DBpedia Spotlight. If you need to do it in SPARQL, you can use the DBpedia Lexicalization Dataset.

For DBpedia Lookup, you can give a string and retrieve DBpedia Resources with labels matching those strings: lookup.dbpedia.org/api/search.asmx/KeywordSearch?QueryString=apple

For DBpedia Spotlight, you can optionally give more context: spotlight.dbpedia.org/rest/candidates?text=apple+company+macintosh+computer

For the Lexicalization Dataset, there is no SPARQL endpoint available yet. You will need to download it, load it in your own RDF store and run a query like this:

PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
SELECT ?resource ?score WHERE {
GRAPH ?g {
  ?resource skos:altLabel ?label.
}
  ?g <http://dbpedia.org/spotlight/score> ?score.
  FILTER (REGEX(?label, "apple", "i"))
}
like image 100
Pablo Mendes Avatar answered Nov 11 '22 14:11

Pablo Mendes