t_res.geoparser.linking.Linker
- class t_res.geoparser.linking.Linker(resources_path: str, experiments_path: Optional[str] = '../experiments', linking_resources: Optional[dict] = {})
The Linker class provides methods for entity linking, which is the task of associating mentions in text with their corresponding entities in a knowledge base.
- Parameters:
This base class should not be instatiated directly. Instead use a subclass constructor.
- disambiguate(candidates: List[SentenceCandidates]) Predictions
Perform entity disambiguation given a list of already identified toponyms and selected candidates.
- Parameters:
candidates – A list of SentenceCandidates instances.
- Returns:
- A Predictions instance representing the identified and
linked toponyms.
- Return type:
Predictions
- disambiguation_scores(links: List[WikidataLink], string_similarity: float) Dict[str, float]
Compute disambiguation scores for a given list Wikidata links.
- Parameters:
links – A list of WikidataLink instances.
string_similarity – (Optional) the string similarity score for the candidate match.
- Returns:
A dictionary containing disambiguation scores, keyed by Wikidata ID.
- Return type:
- empty_candidates(mention: Mention, ranking_method: str, place_of_pub_wqid: str, place_of_pub: str)
Returns an empty Candidates instance.
- load()
Loads the linking resources and assigns them to instance variables.
- run(matches: CandidateMatches, place_of_pub_wqid: Optional[str] = None, place_of_pub: Optional[str] = None) MentionCandidates
Execute the linking process. Each Linker subclass must implement a linking method by overriding this function.
- Parameters:
matches – A CandidatesMatches instance.
origin_wqid (Optional[str]) – The Wikidata ID of the place of publication.
- Returns:
The candidates identified by the linking process.
- Return type:
Candidates
- linking.RANDOM_SEED = 42