Why not adopt me?
NAME
Games::Word::Wordlist - manages a list of words
VERSION
Version 0.01 released 02/03/2008
SYNOPSIS
use Games::Word::Wordlist;
my $wl = Games::Word::Wordlist->new('/usr/share/dict/words');
my $word = $wl->random_word;
print "we have a word" if $wl->is_word($word);
DESCRIPTION
Games::Word::Wordlist manages a list of words, either from a wordlist file on your computer or from a list of words you specify. You can use it to query things about the list, such as whether a given string is a word, or how many words are in the list, and you can also get words from the list, either randomly or by regex.
CONSTRUCTOR
- new <FILENAME|ARRAYREF> PARAMHASH
-
The constructor initializes the word list with words, either from a file or from an arrayref, given as the first argument. The remaining arguments are a paramhash which recognizes these options:
- cache
-
Whether or not we want to keep an in memory cache of the words in the word list. Defaults to true, since this is what we want in almost all cases, as it speeds up lookups by several orders of magnitude. Can be set to false if either memory is a significant issue (word lists can be several megabytes in size) or if the word list is expected to change frequently during the running of the program.
METHODS
- add_words <FILENAME|ARRAYREF>
-
Add words to the word list. Only works if the word list has been cached.
Takes either a reference to an array containing the new words, or the name of a file to read in the words from. Ignores any words already in the word list.
- remove_words LIST
-
Removes words in LIST from the word list. Only works if the word list is cached.
- words
-
Returns the number of words in the word list.
- random_word [LENGTH]
-
Returns a random word from the word list, optionally of length LENGTH.
- is_word STRING
-
Returns true if STRING is found in the word list, and false otherwise.
- each_word CODE
-
Call CODE for each word in the word list. The current word will be passed into CODE as its only argument.
- anagrams STRING
-
Returns a list of all permutations of STRING that are found in the word list.
- words_like REGEX
-
Returns a list containing all words in the word list which match REGEX.
- subwords_of STRING
-
Returns a list of words from the word list which can be made using the letters in STRING.
SEE ALSO
AUTHOR
Jesse Luehrs, <jluehrs2 at uiuc.edu>
BUGS
No known bugs.
Please report any bugs through RT: email bug-games-word at rt.cpan.org
, or browse http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Games-Word.
SUPPORT
You can find this documentation for this module with the perldoc command.
perldoc Games::Word::Wordlist
You can also look for information at:
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
RT: CPAN's request tracker
Search CPAN
COPYRIGHT AND LICENSE
Copyright 2008 Jesse Luehrs.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.