Debian Codegraph @

spellcheck

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