Werds (werds v1.0.0)

A module to generate valid word variants from a base word.

Summary

Functions

Check that the number of letters in the candidate word are less than or equal to the number of letters in the word we used as a source

This takes a string mask like "...x.." and creates a string that can be turned into a regex for searching

Give us a list of words from the dictionary, using the letters from source, that conform to the match pattern. The match looks like a "normal" regex, but when we have a . it matches the unused letters from the source word

Functions

check_word(word_char_counts, source_char_counts)

@spec check_word(Map, Map) :: true | false

Check that the number of letters in the candidate word are less than or equal to the number of letters in the word we used as a source

make_mask(source_word, match_string)

@spec make_mask(String.t(), String.t()) :: String.t()

This takes a string mask like "...x.." and creates a string that can be turned into a regex for searching:

Say the word is "banana" and we want to see words that will match a pattern like "..ana", as in each . would match the unused characters from our source word. You would need /[ban][ban]ana/ - this method generates it.

words(source_word, match_pattern)

@spec words(String.t(), String.t()) :: [String.t()] | {:error, String.t()}

Give us a list of words from the dictionary, using the letters from source, that conform to the match pattern. The match looks like a "normal" regex, but when we have a . it matches the unused letters from the source word