-
Notifications
You must be signed in to change notification settings - Fork 1
Web service
This page gives an introduction on how to use the DBpedia Spotlight Web Service. The available service endpoints are listed below and described in more details in the User's Manual.
- http://spotlight.dbpedia.org/rest/annotate : takes text as input, recognizes entities/concepts to annotate and chooses an identifier for each recognized entity/concept given the context.
- http://spotlight.dbpedia.org/rest/disambiguate : takes wiki markup as input, where entities/concepts have already been recognized and marked with square brackets. Chooses an identifier for each recognized entity/concept given the context.
- http://spotlight.dbpedia.org/rest/candidates : similar to annotate, but returns a ranked list of candidates instead of deciding on one.
The WADL (Web Application Description Language) file describing our endpoint is available at: http://spotlight.dbpedia.org/rest/application.wadl
Example 1: Simple request
- text= "President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package, arguing that the policy provides more generous assistance."
- confidence = 0.2; support=20
- whitelist all types.
curl http://spotlight.dbpedia.org/rest/annotate \ --data-urlencode "text=President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package, arguing that the policy provides more generous assistance." \ --data "confidence=0.2" \ --data "support=20"
Example 2: Using SPARQL for filtering
This example demonstrates how to keep the annotations constrained to only politicians related to Chicago.
- text= "President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package, arguing that the policy provides more generous assistance."
- confidence = 0.2; support=20
- whitelist sparql = SELECT DISTINCT ?politician WHERE { ?politician a http://dbpedia.org/ontology/OfficeHolder . ?politician ?related http://dbpedia.org/resource/Chicago }
curl http://spotlight.dbpedia.org/rest/annotate \ --data-urlencode "text=President Obama called Wednesday on Congress to extend a tax break for students included in last year's economic stimulus package, arguing that the policy provides more generous assistance." \ --data "confidence=0.2" \ --data "support=20" \ --data-urlencode "sparql=SELECT DISTINCT ?x WHERE { ?x a . ?x ?related . }"
Notice: Due to system resources restrictions, for this demo we only use the first 2000 results returned for each query (default for the public DBpedia SPARQL endpoint). However you are welcome to download the software+data and install in your server for real world use cases.
Attention: Make sure to encode your SPARQL query before adding it as the value of the //&sparql// parameter - see java.net.URLEncoder.encode().