gliner.decoding.trie.python_labels_trie module¶
- class gliner.decoding.trie.python_labels_trie.LabelsTrie(entities=None)[source]¶
Bases:
objectInitialize the trie.
- Parameters:
entities (List[List[int]] | None) – Optional initial list of token sequences to add to the trie. If None or empty, creates an empty trie.
- __init__(entities=None)[source]¶
Initialize the trie.
- Parameters:
entities (List[List[int]] | None) – Optional initial list of token sequences to add to the trie. If None or empty, creates an empty trie.
- add_batch(entities)[source]¶
Add multiple token sequences to the trie.
- Parameters:
entities (List[List[int]]) – List of token sequences to add.
- add(tokens)[source]¶
Add a single token sequence to the trie.
- Parameters:
tokens (List[int]) – Token sequence to add.
- get(prefix)[source]¶
Get possible next tokens after a given prefix.
- Parameters:
prefix (List[int]) – The token sequence to search for.
- Returns:
List of possible next token IDs.
- Return type:
List[int]