ExNlp.Filter.Length (ex_nlp v0.1.0)
View SourceLength-based token filtering.
Filters tokens based on minimum and maximum length constraints.
Summary
Functions
Removes tokens longer than the specified maximum length.
Removes tokens shorter than the specified minimum length.
Types
@type token() :: ExNlp.Token.t()
A token struct
Functions
@spec maximum([token()], non_neg_integer()) :: [token()]
Removes tokens longer than the specified maximum length.
Examples
iex> tokens = [%ExNlp.Token{text: "short"}, %ExNlp.Token{text: "verylongword"}]
iex> ExNlp.Filter.Length.maximum(tokens, 5)
[%ExNlp.Token{text: "short"}]
@spec minimum([token()], non_neg_integer()) :: [token()]
Removes tokens shorter than the specified minimum length.
Examples
iex> tokens = [%ExNlp.Token{text: "a"}, %ExNlp.Token{text: "an"}, %ExNlp.Token{text: "the"}]
iex> ExNlp.Filter.Length.minimum(tokens, 2)
[%ExNlp.Token{text: "an"}, %ExNlp.Token{text: "the"}]