Werds (werds v1.0.7)
A module to generate valid word variants from a base word. Will also find anagrams of a word.
Summary
Functions
Get anagrams
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
Generate wordle suggestions
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
Get anagrams
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:
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.
@spec wordle_suggestions(%{required(integer()) => String.t()}, %{ required(String.t()) => :default | :correct | :misplaced | :incorrect }) :: [String.t()]
Generate wordle suggestions
letters: a map of letter positions and their values keys: a map of letters and their status :default - letter is not used :correct - letter is in the correct position :misplaced - letter is in the word but not in the correct position :incorrect - letter is not in the word
The function will return a list of words that match the criteria
In practice we only use incorrect and the map of letters because any letter we haven't yet checked, inluding the ones we know the position of, could be in the word. So we only need to check the letters that are not in the word.
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
The default search is caseless and will find acronyms and proper names, pass an empty options list to turn this behaviour off
Options [:proper_names] and [:acronyms] will do the obvious thing
The option [:standard] turns off caseless and will only find "proper" words