AnchorTokenizer
- class AnchorTokenizer(selection=None, selection_kwargs=None, searcher=None, searcher_kwargs=None)[source]
Bases:
pykeen.nn.node_piece.tokenization.Tokenizer
Tokenize entities by representing them as a bag of anchor entities.
The entities are chosen by shortest path distance.
Initialize the tokenizer.
- Parameters
selection (
Union
[str
,AnchorSelection
,Type
[AnchorSelection
],None
]) – the anchor node selection strategy.selection_kwargs (
Optional
[Mapping
[str
,Any
]]) – additional keyword-based arguments passed to the selection strategysearcher (
Union
[str
,AnchorSearcher
,Type
[AnchorSearcher
],None
]) – the component for searching the closest anchors for each entitysearcher_kwargs (
Optional
[Mapping
[str
,Any
]]) – additional keyword-based arguments passed to the searcher
Methods Summary
__call__
(mapped_triples, num_tokens, ...)Tokenize the entities contained given the triples.
Methods Documentation
- __call__(mapped_triples, num_tokens, num_entities, num_relations)[source]
Tokenize the entities contained given the triples.
- Parameters
- Return type
LongTensor
- Returns
shape: (num_entities, num_tokens), -1 <= res < vocabulary_size the selected relation IDs for each entity. -1 is used as a padding token.