NAME

Dictionary - Dictionary utilities.

SYNOPSIS

package require Dictionary

VARIABLES

Dictionary::directory
The directory containing the dictionary files. The dictionary must be laid out as a set of files, with each file containing a list of words (in any order) all of the same length, one word per line. The filenames must start with the string len and end with a 2 digit number describing the length of the words inside the file. For example, the file len04 could contain:

very
that
lean
keys
used
type
foot
mine
eery
flee

Dictionary::cache
The level of caching performed by the dictionary procedures. The possible caches that can be enabled are any combination of length, word, pattern, and trigram. length will cache the possible word lengths. This is useful when new lengths will not be added to the dictionary while the program is running. word will cache the words in the dictionary, as they are read in by length. pattern will cache the results of a pattern match on the dictionary words. trigram will cache the results of a valid trigram determination. Enabling the caches will consume more memory in exchange for faster dictionary lookups. Caching will not provide any benefit for programs that make a only a single pass through the dictionary.

COMMANDS

Dictionary::availableLengths ?minimum? ?maximum?
Scan the dictionary files and return a list of the all possible word lengths. If minimum or maximum lengths are specified then the return values are guaranteed to lie within the min/max limits. This procedure is use in conjunction with Dictionary::lookupByLength to iterate through all words in the dictionary. If the length cache is enabled then this procedure will only search the dictionary files the first time it is called.

Dictionary::lookupByLength length ?pattern?
Returns a list of all words in the dictionary that have the indicated length. A glob pattern can be used to limit the If the word cache is enabled then this procedure will load the words from the appropriate dictionary file only once. If the pattern cache is enabled then the result will be stored in the pattern cache.

Dictionary::lookupByPattern pattern
Deprecated. See Dictionary::lookupByLength

Dictionary::clearCache cache1 ?cache2 ...?
Clear the specified caches. This will free up the memory used by the indicated dictionary caches.

Dictionary::isWord word
Determine if word is in the dictionary. Returns 1 if the word is in the dictionary, 0 if not.

Dictionary::isNumber val
Determine if val is a valid number. Valid numbers contain only the digits 0-9.

Dictionary::addWord word
Add a word to the dictionary. The dictionary files on the disk are updated. If the word cache is enabled then the word is also added to the cache.

Dictionary::isIllegalTrigram trigram
Determine if the trigram can be formed from words in the dictionary. If two or more words can not be joined to form the trigram then this procedure returns 0. Otherwise it returns 1. If the trigram cache is enabled then the result is stored in the cache. Any necessary word and pattern lookups will also be cached if the word or pattern caches are enabled.

Dictionary::containsIllegalTrigram string
Determine if the string contains any illegal trigrams. This is done by calling Dictionary::isIllegalTrigram on all 3-character substrings composed of only the letters from a to z.

Dictionary::dumpCache
For debugging uses only.

Dictionary::allWordsMatching string
This procedure locates all words that can be formed starting at the beginning of string. Spaces in string are treated as wildcard characters. For example, the string "atten" would match attentive, attention, attend, at, and a. And the string "i qr" would match in, if, and i.

Dictionary::findWords plaintext
Attempt to split a string of plaintext up into its constituent words. Or to put it another way, try to find the word divisions in a string of plaintext. This procedure returns the input string with the space character used as a word divider. If this procedure could not find all word divisions in the string, then it will simply return the input string with no word divisions.

Dictionary::createWordTree
Initialize the builtin word tree from the dictionary. This procedure will soon be deprecated by the wordtree scoring table of the score command.

Back to the Index
wart@kobold.org
Created on Wed Mar 31 08:18:25 PST 2004
SourceForge.net Logo