Lexicon v0.1.3 Lexicon View Source

A lexicon (word list) implemented in Elixir.

Link to this section Summary

Functions

Adds a word to the lexicon

Creates a lexicon from a saved lexicon file

Checks if prefix is in the given lexicon

Checks if word is in the given lexicon

Creates an empty lexicon

Creates a lexicon from an enumerable collection of words

Saves a lexicon to a file

Link to this section Functions

Adds a word to the lexicon.

Examples

iex> lexicon = Lexicon.new(["cat", "dog"])
#Lexicon<size: 2>
iex> Lexicon.add(lexicon, "elephant")
#Lexicon<size: 3>

Creates a lexicon from a saved lexicon file.

Examples

iex> Lexicon.from_file!("private/dictionary.lex")
#Lexicon<size: 127145>
Link to this function has_prefix?(lexicon, word) View Source

Checks if prefix is in the given lexicon.

Examples

iex> lexicon = Lexicon.new(["cat", "dog"])
iex> Lexicon.has_prefix?(lexicon, "ca")
true
iex> Lexicon.has_prefix?(lexicon, "cat")
true
iex> Lexicon.has_prefix?(lexicon, "ba")
false
Link to this function has_word?(lexicon, word) View Source

Checks if word is in the given lexicon.

Examples

iex> lexicon = Lexicon.new(["cat", "dog"])
iex> Lexicon.has_word?(lexicon, "cat")
true
iex> Lexicon.has_word?(lexicon, "ca")
false

Creates an empty lexicon.

Examples

iex> Lexicon.new()
#Lexicon<size: 0>

Creates a lexicon from an enumerable collection of words.

Examples

iex> Lexicon.new([])
#Lexicon<size: 0>
iex> Lexicon.new(["cat", "dog"])
#Lexicon<size: 2>

Saves a lexicon to a file.

Examples

iex> ["cat"] |> Lexicon.new() |> Lexicon.save!("private/lexicon.lex")
:ok