1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
#!/usr/bin/perl -w
$| = 1;
use lib qw( lib );
use Lingua::Ispell qw( :all );
use strict;
while ( <> ) {
chomp;
my $line = $_;
if ( s/^-C\s*// ) { allow_compounds(1); next; }
if ( s/^-m\s*// ) { infer_root_affix_combos(1); next; }
if ( s/^-d\s*// ) { use_dictionary(split); next; }
if ( s/^-p\s*// ) { use_personal_dictionary(split); next; }
for my $r ( spellcheck( $line ) ) {
{
'ok' =>
sub { print "ok: $r->{'term'}\n"; },
'compound' =>
sub { print "ok: $r->{'term'}\n"; },
'root' =>
sub { print "ok: '$r->{'term'}' can be formed from root '$r->{'root'}'\n"; },
'none' =>
sub {
my $indent = ' ' x $r->{'offset'};
print <<EOF;
No match found for term "$r->{'term'}" in:
"$line"
$indent^
EOF
},
'miss' =>
sub {
my $indent = ' ' x $r->{'offset'};
local $" = "\n\t";
print <<EOF;
Near miss on term "$r->{'term'}" in:
"$line"
$indent^
missed terms:
@{$r->{'misses'}}
EOF
},
'guess' =>
sub {
my $indent = ' ' x $r->{'offset'};
local $" = "\n\t";
print <<EOF;
Guess on term "$r->{'term'}" in:
"$line"
$indent^
missed terms:
@{$r->{'misses'}}
guesses:
@{$r->{'guesses'}}
EOF
},
}->{ $r->{'type'} }->();
}
}
|