tokeniser.py

A tokeniser.

class malti.tokeniser.tokeniser.Tokeniser

Bases: ABC

Top-level abstract class representing all tokenisers.

__init__() None

Empty constructor.

Return type:

None

tokenise(text: str) list[str]

Tokenise a text into a list of tokens.

Parameters:

text (str) – The text to tokenise.

Returns:

The list of tokens.

Return type:

list[str]

tokenise_indices(text: str) list[tuple[int, int]]

Tokenise a text and return the indices of the tokens. A list of integer pair tuples [(i, j)] is returned such that text[i:j] is a token.

Parameters:

text (str) – The text to tokenise.

Returns:

The list of tuple pairs containing integers specifying the locations of the tokens in the text.

Return type:

list[tuple[int, int]]