Miscellaneous`Dictionary`This package provides functions for simple interaction with a dictionary of words. A default dictionary is available, but you can easily use your own custom dictionaries as well. Basic functions for looking up words in the dictionary. This loads the package. This finds all words in the dictionary starting with "m" and ending with "th".
Out[2]= |  |
Since FindWords is based on StringMatchQ, the wild card characters "*" and "@" also work.
Out[3]= |  |
This shows the first 10 words whose third letter is "x".
Out[4]= |  |
This checks whether the word "math" is in the dictionary.
Out[5]= |  |
Options for DictionaryWordQ and FindWords. By default, DictionaryWordQ and FindWords treat upper- and lowercase letters equivalently.
Out[6]= |  |
You can distinguish between upper- and lowercase by specifying IgnoreCase -> False.
Out[7]= |  |
If the pattern is given as a literal string, you can also find words matching with small spelling corrections by using the SpellingCorrection option.
Out[8]= |  |
Manipulating which dictionary to use. Once the dictionary is loaded, it is stored as a list of strings in $Dictionary. If $Dictionary is undefined, the loading happens automatically when one of the dictionary functions is called. This shows the number of words in the dictionary.
Out[9]= |  |
The first 10 words in the dictionary.
Out[10]= |  |
The file path for the default dictionary file used is stored in $DefaultDictionaryFile. The default dictionary is based on the Spell Check Oriented Word Lists (SCOWL) size 60 (© 2000-2004 by Kevin Atkinson, see http://wordlist.sourceforge.net/scowl-readme for information), with a few modifications, some of which are collected from the "2of12" list by Alan Beale (see http://wordlist.sourceforge.net/12dicts-readme.html). You can specify your own dictionary file, which is simply a file with one word on each line. You can either load it using GetDictionary[file] or redefine $DefaultDictionaryFile before the dictionary is loaded. You can specify the dictionary directly by redefining $Dictionary.
Out[12]= |  |
Reload the default dictionary. Finding anagrams. The Anagrams function will construct all possible anagrams of the letters in the given string, that is, all possible ways of using all the letters in the string to construct words from the dictionary. All nonletter characters are ignored when forming the anagrams. This shows all the ways of decomposing the letters in "super" into individual words. Note that accented letters are ignored.
Out[14]= |  |
Note that the first time you use Anagrams, it takes extra time because a frequency table is generated and cached. If you are looking for anagrams with many letters, it is important to limit the number of words in the result to avoid exponential slowdown. This restrict the anagrams to a maximum of two words.
Out[15]= |  |
Spell checking. You can use the SpellCheck function to perform a basic spell check of the words in a string. The return value is a list where the first element is the string with possible misspelled words highlighted in red, while the second element is a list of these words. Note that this spell check is different from the one performed by the Mathematica Check Spelling menu command. This spell checks the sentence using the words in the dictionary.
Out[16]= |  |
|