Skip to main content

Module text

Module text 

Source
Expand description

Language-agnostic text primitives, ported from addok.helpers.text.

Country or language specific processing lives in crate::profile.

Structs§

Synonyms
Synonym table in addok’s file format: a, b, c => wanted words, # for comments. Applied on index and query tokens alike (synonymize).
Token
addok.helpers.text.Token: a normalized word with the metadata the pipeline and the collectors rely on.

Enums§

TokenKind

Functions§

ascii
addok.helpers.text.ascii: lowercase, transliterate, replace every non-word character by a space, collapse runs of spaces and trim.
compare_ngrams
addok.helpers.text.compare_ngrams(left, right, N=2, pad_len=0), i.e. NGram.compare: shared bigrams (with multiplicity) over the bigrams of both strings minus the shared ones.
edge_ngrams
addok.helpers.text.compute_edge_ngrams: prefixes from min chars up to, but excluding, the token itself, on the token cut to max + 1 chars.
is_digit
Python’s str.isdigit() for the ASCII strings we deal with.
normalize
addok.helpers.text.normalize: unidecode(s.lower()).
tokenize
addok.helpers.text.tokenize followed by normalize.