Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link well-known entities to DBpedia #1

Open
selBaez opened this issue Apr 12, 2022 · 0 comments
Open

Link well-known entities to DBpedia #1

selBaez opened this issue Apr 12, 2022 · 0 comments

Comments

@selBaez
Copy link
Member

selBaez commented Apr 12, 2022

Create a linker that connects to DBpedia using the API of DBpedia spotlight. Something similar to this should be added:

def dbpedia_spot(text):
    address = 'https://api.dbpedia-spotlight.org/en/annotate'
    payload = {
        'confidence': 0.6,
        'support': 0,
        'text': text,
        'policy': 'whitelist'}

    response = requests.post(address, data=payload, headers={'accept': 'application/json'})
    json_body = response.json()


    resources = []
    if 'Resources' in json_body.keys():
        for res in json_body['Resources']:
            res2 = {'uri': res['@URI'], res['@end']], 'type': res['@types'].split(','), 'label': res['@surfaceForm']}
            resources.append(res2)

    return resources
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant