<<

NAME

Lingua::Spelling::Alternative - alternative spelling of a given word in a given language

SYNOPSIS

  use Lingua::Spelling::Alternative;

  my $en = new Lingua::Spelling::Alternative;
  $en->load_affix('/usr/lib/ispell/default.aff') or die $!;
  print join(" ",$en->alternatives("cars")),"\n";

DESCRIPTION

This module is designed to return all forms of a given word (for example when you want to see all possible forms of some word entered in search engine) which can be generated using affix file (from ispell) or findaffix output file (also part of ispell package) or using OpenOffice.org affix files.

PUBLIC METHODS

new

The new() constructor (without parameters) create container for new language.

 my $en = new Lingua::Spelling::Alternative(
        debug => 1,
        min_length => 3,
 );

Options:

debug

Turns debugging which will be spilled on STDOUT.

min_length

Minimum word length (by default 3) which will be considered for alternatives.

clear

This method will clear internal affix and is called every time you use load_affix, load_findaffix or load_oooaffix on same object.

load_affix

Loads ispell's affix file for later usage. It will create internal structures needed for other methods.

 $en->load_affix('/etc/dictionaries-common/default.aff');

load_findaffix

This function loads output of findaffix program from ispell package. This is better idea (if you are creating affix file for particular language yourself or you can get your hands on one) because affix file from ispell is limited to 26 entries (because each entry is denoted by single character).

 $en->load_findaffix('findaffix.out');

alternatives

Return array of all alternative spellings of particular word(s). It will also return spellings which are not lexically correct if there is rule like that in affix file.

 print $en->alternatives(qw(cat dog));
 print $en->alternatives('demo');

minimal

This function returns minimal of all alternatives of a given word(s). It's a poor man's version of normalize (because we don't know grammatic of particular language, just some spelling rules).

 $en->minimal('informations');

EXAMPLES

Please see the test program in distribution which exercises some aspects of Alternative.pm.

BUGS

There are no known bugs. If you find any, please report it in CPAN's request tracker at: http://rt.cpan.org/

CONTACT AND COPYRIGHT

Copyright 2002-2005 Dobrica Pavlinusic (dpavlin@rot13.org). All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

<<