FastNgram v1.1.0 FastNgram View Source

A fast and unicode aware letter & word N-gram library written in Elixir.

Link to this section Summary

Functions

Returns a list of letter N-grams from the given string.

Returns a list of word N-grams from the given string.

Link to this section Functions

Link to this function

letter_ngrams(string, n)

View Source
letter_ngrams(String.t(), non_neg_integer()) :: list()

Returns a list of letter N-grams from the given string.

Example

iex> FastNgram.letter_ngrams("¥ · € · $", 3)
["¥ ·", " · ", "· €", " € ", "€ ·", " · ", "· $"]
iex> FastNgram.letter_ngrams("", 2)
[]
iex> FastNgram.letter_ngrams("abcd", 1)
["a", "b", "c", "d"]
iex> FastNgram.letter_ngrams("abcde", 2)
["ab", "bc", "cd", "de"]
Link to this function

word_ngrams(string, n)

View Source
word_ngrams(String.t(), non_neg_integer()) :: list()

Returns a list of word N-grams from the given string.

Example

iex> FastNgram.word_ngrams("the bus came to a halt", 2)
["the bus", "bus came", "came to", "to a", "a halt"]
iex> FastNgram.word_ngrams("the bus came to a halt", 3)
["the bus came", "bus came to", "came to a", "to a halt"]
iex> FastNgram.word_ngrams("", 2)
[]