Official TagMe API wrapper for Python
Official TagMe API wrapper for Python.
Installation and setup
This library is hosted by PyPI. You can install it with:
pip install tagme
To access the TagMe API you have to register (for free!) at the D4Science platform and obtain an authorization token.
- Register to the D4Science TagMe VRE.
- After login, click the show button on the left panel to get your authorization token.
Before making any call to the web service, you will need to set the module-wise GCUBE_TOKEN variable. You can do so with:
import tagme # Set the authorization token for subsequent calls. tagme.GCUBE_TOKEN = "<Your token goes here>"
As an alternative to setting the module-wise variable, you can pass the token at each call with the optional gcube_token parameter.
The annotation service lets you find entities mentioned in a text and link them to Wikipedia. This is the so-called Sa2KB problem. You can annotate a text with:
lunch_annotations = tagme.annotate("My favourite meal is Mexican burritos.") # Print annotations with a score higher than 0.1 for ann in lunch_annotations.get_annotations(0.1): print ann
The annotate method accepts parameters to set the language (parameter lang, that defaults to en) and other stuff. See the code for more information. Annotations are associated a rho-score indicating the likelihood of an annotation being correct. In the example, we discard annotations with a score lower than 0.1.
The mention finding service lets you find what parts of text may be a mention of an entity, without linking them to any entity.
tomatoes_mentions = tagme.mentions("I definitely like ice cream better than tomatoes.") for mention in tomatoes_mentions.mentions: print mention
The mentions parameter accepts an optional language parameter lang that defaults to en.
See the Changelog.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size tagme-0.1.3-py2.py3-none-any.whl (8.2 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size tagme-0.1.3.tar.gz (5.7 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for tagme-0.1.3-py2.py3-none-any.whl