/[Lingua-Spelling-Alternative]/Alternative.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Alternative.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Mon Feb 11 20:19:59 2002 UTC revision 1.7 by dpavlin, Fri Oct 3 15:35:59 2003 UTC
# Line 13  $VERSION = '0.01'; Line 13  $VERSION = '0.01';
13  #@EXPORT = qw();  #@EXPORT = qw();
14  @EXPORT_OK = qw(  @EXPORT_OK = qw(
15          &alternatives          &alternatives
         &load_affix  
16          );          );
17    
18  my $debug=0;  my $debug=0;
# Line 152  sub alternatives { Line 151  sub alternatives {
151          return @out;          return @out;
152  }  }
153    
154    #
155    # function which return minimal word of all alternatives
156    #
157    
158    sub minimal {
159            my $self = shift;
160            my @out;
161            foreach my $word (@_) {
162                    my @alt = $self->alternatives($word);
163                    my $minimal = shift @alt;
164                    foreach (@alt) {
165                            $minimal=$_ if (length($_) < length($minimal));
166                    }
167                    push @out,$minimal;
168            }
169            return @out;
170    }
171    
172  ###############################################################################  ###############################################################################
173  1;  1;
174  __END__  __END__
# Line 162  Alternative.pm - alternative spelling of Line 179  Alternative.pm - alternative spelling of
179    
180  =head1 SYNOPSIS  =head1 SYNOPSIS
181    
182    use Lingua::Spelling:Alternative;    use Lingua::Spelling::Alternative;
183    
184    my $en = new Alternative;    my $en = new Alternative;
185    $en->load_affix('/usr/lib/ispell/english.aff') or die $!;    $en->load_affix('/usr/lib/ispell/english.aff') or die $!;
# Line 180  entered in search engine) Line 197  entered in search engine)
197    
198  =item new  =item new
199    
200  The new() constructor (without parameters) create container for new  The new() constructor (without parameters) create container for new language.
201  language.  Only parametar it supports is DEBUG which turns on (some) debugging output.
 Only parametar it supports is DEBUG which turns on (some) debugging  
 output.  
202    
203  =item load_affix  =item load_affix
204    
205  Function load_affix loads ispell's affix file.  Function load_affix() loads ispell's affix file for later usage.
206    
207    =item load_findaffix
208    
209    This function loads output of findaffix program from ispell package.
210    This is better idea (if you are creating affix file for particular language
211    yourself or you can get your hands on one) because affix file from ispel
212    is limited to 26 entries (because each entry is denoted by single character).
213    
214  =item alternatives  =item alternatives
215    
216  Function alternatives  Function alternatives return all alternative spellings of particular
217    word(s). It will also return spelling which are not correct if there is
218    rule like that in affix file.
219    
220    =item minimal
221    
222    This function returns minimal of all alternatives of a given word(s). It's
223    a poor man's version of normalize (because we don't know gramatic of
224    particular language, just some spelling rules).
225    
226    =back
227    
228  =head1 PRIVATE METHODS  =head1 PRIVATE METHODS
229    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.7

  ViewVC Help
Powered by ViewVC 1.1.26