srtk.entity_linking package
srtk.entity_linking.linker_base module
By extending LinkerBase, you can easily generalize srtk.linker to other knowledge graphs.
- class srtk.entity_linking.linker_base.LinkerBase
Bases:
objectBase class for entity linking
- abstract annotate(text: str, **kwargs)
Annotate a text with the entities in the knowledge graph
The returned dictionary should at least have the following fields: - question: The input text - question_entities: The entity ids of the entities in the text
- Parameters:
text (str) – The text to annotate
kwargs – Extra arguments
- Returns:
The annotated text with linked entities
- Return type:
dictionary
srtk.entity_linking.wikidata module
- class srtk.entity_linking.wikidata.WikidataLinker(endpoint, wikimapper_db, service='rel')
Bases:
LinkerBaseLink entitiy mentions to Wikidata entities using the REL endpoint
- annotate(text, **kwargs)
Annotate a text with the entities in the Wikidata knowledge graph
- Parameters:
text (str) – The text to annotate
- Returns:
- A dictionary with the following keys:
question: The input text question_entities: The Wikidata ids of the entities in the text spans: The spans of the entities in the text entity_names: The names of the entities in the text not_converted_entities: The entities that are not converted to Wikidata ids
- Return type:
dict
- annotate_rel(text, token=None)
Annotate using a local REL service. Check https://rel.readthedocs.io/en/latest/tutorials/e2e_entity_linking for setup instructions.
- Parameters:
text (str) – The text to annotate
- Returns:
annotation results
- Return type:
dict
- annotate_tagme_wat(text, token)
Annotate using WAT or REL online services
- Parameters:
text (str) – The text to annotate
token (str) – The token to access the service
- Returns:
annotation results
- Return type:
dict
srtk.entity_linking.dbpedia module
Link entitiy mentions to DBpedia entities with the DBpedia Spotlight endpoint.
Know more about DBpedia Spotlight at https://www.dbpedia-spotlight.org/.
- class srtk.entity_linking.dbpedia.DBpediaLinker(endpoint)
Bases:
LinkerBaseLink entitiy mentions to DBpedia entities with the DBpedia Spotlight endpoint
- annotate(text, **kwargs)
Annotate a text with the entities in the DBpedia knowledge graph
- Parameters:
text (str) – The text to annotate
- Returns:
- A dictionary with the following keys:
question: The input text question_entities: The DBpedia entities in the text spans: The spans of the entities in the text similarity_scores: The similarity scores of the entities in the text
- Return type:
dict