--- Alternative.pm 2002/02/11 20:19:59 1.3 +++ Alternative.pm 2002/07/03 08:06:06 1.6 @@ -13,7 +13,6 @@ #@EXPORT = qw(); @EXPORT_OK = qw( &alternatives - &load_affix ); my $debug=0; @@ -152,6 +151,24 @@ return @out; } +# +# function which return minimal word of all alternatives +# + +sub minimal { + my $self = shift; + my @out; + foreach my $word (@_) { + my @alt = $self->alternatives($word); + my $minimal = shift @alt; + foreach (@alt) { + $minimal=$_ if (length($_) < length($minimal)); + } + push @out,$minimal; + } + return @out; +} + ############################################################################### 1; __END__ @@ -162,7 +179,7 @@ =head1 SYNOPSIS - use Lingua::Spelling:Alternative; + use Lingua::Spelling::Alternative; my $en = new Alternative; $en->load_affix('/usr/lib/ispell/english.aff') or die $!; @@ -180,18 +197,31 @@ =item new -The new() constructor (without parameters) create container for new -language. -Only parametar it supports is DEBUG which turns on (some) debugging -output. +The new() constructor (without parameters) create container for new language. +Only parametar it supports is DEBUG which turns on (some) debugging output. =item load_affix -Function load_affix loads ispell's affix file. +Function load_affix() loads ispell's affix file for later usage. + +=item 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 ispel +is limited to 26 entries (because each entry is denoted by single character). =item alternatives -Function alternatives +Function alternatives return all alternative spellings of particular +word(s). It will also return spelling which are not correct if there is +rule like that in affix file. + +=item 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 gramatic of +particular language, just some spelling rules). =head1 PRIVATE METHODS