starfuzz/tokenize
A module providing tokenization capabilities. Tokenization splits raw text into smaller components such as characters, words, or n-grams before similarity metrics or vector transformations.
Types
Represents tokenization errors.
pub type TokenizeError {
InvalidN(Int)
}
Constructors
-
InvalidN(Int)Returned when the n-gram size
nis invalid (e.g. less than or equal to 0).
Values
pub fn character_ngrams(
text: String,
n: Int,
) -> Result(List(String), TokenizeError)
Generates character n-grams of size n from the input text.
pub fn characters(text: String) -> List(String)
Splits the string into its constituent Unicode grapheme characters.
pub fn word_ngrams(
text: String,
n: Int,
) -> Result(List(List(String)), TokenizeError)
Generates word n-grams of size n from the input text.