Text::Contraction - Find possible expansions for a contraction.
use Text::Contraction; my $tc = Text::Contraction->new(); my @matches = $tc->match('flgstff'); # on my system this produces 'Flagstaff'
Text::Contraction finds possible expansions for a contraction. It relies on the system dictionary for the list of candidate words, or the user may supply a dictionary of their own choosing.
This module finds possible expansions for a contraction. By default, the search is performed case-insensitively, at least half of the letters in the expansion must come from the contraction (thus the longest expansion that will be returned will be twice as long as the contraction) and the first letter of the contraction must be the first letter of the expansion.
This default behavior can easily be changed. In addition, although this module will attempt to use your system's dictionary, you can also supply your own dictionary (really just a file of words or phrases, one per line).
Options may be specified as keyword-value pairs. The following options are recognized:
Perform search case insensitively. DEFAULT: 1
Minimum ratio of letters from the contraction to letters in the possible expansions. If
minRatio if 0.5 and there are 4 letters in the contraction, the longest word that will be returned will have 8 letters. Apostrophes in the contraction do not count, but apostrophes in the expansions do. This is most likely a bug.
minRatio must be between 0 and 1, inclusive. DEFAULT: 0.5
Prefix that all candidate words must match. Set to empty string to allow for expansions that do not necessarily have the same first letter as the contraction. DEFAULT: ^
An array reference of words to use. If not specified, then first the environment variable CONTRACTION_WORDS is checked to see if it points to a dictionary file. Otherwise, various well-known locations are searched for a system dictionary. If your system has a dictionary somewhere that this module cannot find, please let me know.
Index the list of words. If study() is not called, it will be automatically called upon the first call to match().
Returns possible expansions for the supplied contraction.
Benjamin Holzman, <firstname.lastname@example.org>
Copyright 2004 by Benjamin Holzman
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.