Benjamin Holzman > Text-Contraction-0.02 > Text::Contraction

Download:
Text-Contraction-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

Text::Contraction - Find possible expansions for a contraction.

SYNOPSIS ^

  use Text::Contraction;
  my $tc = Text::Contraction->new();
  my @matches = $tc->match('flgstff');

  # on my system this produces 'Flagstaff'

ABSTRACT ^

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.

DESCRIPTION ^

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).

CONSTRUCTOR ^

$tc = Text::Contraction->new(OPTIONS)

Options may be specified as keyword-value pairs. The following options are recognized:

caseless

Perform search case insensitively. DEFAULT: 1

minRatio

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

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: ^

words

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.

ACCESSORS ^

caseless
minRatio
prefix
words

METHODS ^

$tc->study()

Index the list of words. If study() is not called, it will be automatically called upon the first call to match().

@matches = $tc->match($contraction)

Returns possible expansions for the supplied contraction.

HISTORY ^

0.01

Original version; created by h2xs 1.22

0.02

Documentation tweaks. Added tests.

SEE ALSO ^

Text::Abbrev

AUTHOR ^

Benjamin Holzman, <bholzman@earthlink.net>

COPYRIGHT AND LICENSE ^

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.

syntax highlighting: