Amogh Mishra
Amogh Mishra

Reputation: 1238

Extract entities from text using Knowledge Bases in Python

I have an entity extraction tasks which needs KBs like wikidata, freebase, DBpedia. Given the huge size of them, it is hard to download and extract entities from them. Is there a python client which can make API calls to get the extractions through them with unstructured text as input?

Upvotes: 0

Views: 419

Answers (1)

firefly
firefly

Reputation: 51

For DBPedia at least, you can use DBPedia Spotlight, something like that:

spotlight_url = 'http://api.dbpedia-spotlight.org/en/annotate?'
params = dict(text="Barack Obama was a president", confidence='0.2', support='10')
headers = {'Accept':'application/json'}
resp = requests_retry_session().get(url=spotlight_url, params=params,headers=headers)
results = resp.json()

If you were to do loads of queries, you'd have a local install of the knowledge base in a triplestore and a local install of Spotlight too.

Upvotes: 1

Related Questions