Whitespace Counter Tokenizer¤
This class inherits from the main Tokenizer class and extends it by counting runs of spaces and line breaks.
__init__(**data) -> None
¤
Initialise the Tokenizer class.
Source code in lexos/tokenizer/__init__.py
_get_token_widths(text: str) -> tuple[list[str], list[int]]
¤
Get the widths of tokens in a doc.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The input text. |
required |
Returns:
| Type | Description |
|---|---|
tuple[list[str], list[int]]
|
tuple[list[str], list[int]]: A tuple containing the tokens and widths. |
Source code in lexos/tokenizer/whitespace_counter.py
make_doc(text: str, max_length: int = None, disable: Optional[Iterable[str]] = None) -> Doc
¤
Return a doc from a text.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to be parsed. |
required |
max_length
|
int
|
The maximum length of the doc. |
None
|
disable
|
list[str]
|
A list of spaCy pipeline components to disable. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Doc |
Doc
|
A spaCy doc object. |
Source code in lexos/tokenizer/whitespace_counter.py
make_docs(texts: Iterable[str], max_length: int = None, disable: Optional[Iterable[str]] = None, chunk_size: int = 1000) -> Iterable[Doc]
¤
Return a generator of docs from an iterable of texts, processing in chunks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
texts
|
Iterable[str]
|
The texts to process. |
required |
max_length
|
int
|
Maximum doc length. |
None
|
disable
|
Iterable[str]
|
Pipeline components to disable. |
None
|
chunk_size
|
int
|
Number of docs to process per chunk. |
1000
|
Yields:
| Name | Type | Description |
|---|---|---|
Doc |
Iterable[Doc]
|
spaCy Doc objects. |