Teanga utils
TokenizationMismatch
Bases: Exception
Exception raised for tokenization mismatches.
Source code in teanga/utils.py
63 64 65 66 67 68 69 70 71 72 |
|
find_spans(tokens, text)
Find the spans of tokens in the text.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tokens
|
list A list of tokens to find in the text. |
required | |
text
|
str The text to search for the tokens. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the tokens do not match the text. |
Source code in teanga/utils.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
teanga_id_for_doc(ids, *args, **kwargs)
Return the Teanga ID for a document.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ids
|
str The IDs already generated and not to be repeated |
required |
Examples:
>>> teanga_id_for_doc(set(), text="This is a document.")
'Kjco'
>>> teanga_id_for_doc(set(), en="This is a document.", nl="Dit is een document.")
'Nnrd'
Source code in teanga/utils.py
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|