Debian Codegraph @

src/proc-alt12dicts

raw
1 #!/usr/bin/perl -w
2
3 chdir "r/alt12dicts";
4
5 open IN, "abbr.txt";
6 open OUT, ">abbr.lst";
7 while (<IN>)
8 {
9 next if /~/;
10 y/:\r//d;
11 print OUT;
12 }
13 close OUT;
14 close IN;
15
16 open IN, "variant.txt";
17 open OYES , ">variant-yes.lst";
18 open OMAYBE, ">variant-maybe.lst";
19 open BYES , ">nonamer-yes.lst";
20 open BMAYBE, ">nonamer-maybe.lst";
21 while (<IN>) {
22 s/\r?\n$// or die;
23 ($w, $f, $s) = /^(.+):?\t(.)([!?]?)$/ or die "Bad Line: $_";
24 next unless $w =~ /^[A-Za-z\']+$/;
25 #print "$w -- $f -- $s\n";
26 $already_variant{$w} = 1;
27 if ($s eq '!' || $s eq '') {
28 print OYES $w, "\n" if $f eq '#';
29 print BYES $w, "\n" if $f eq '&';
30 } else {
31 print OMAYBE $w, "\n" if $f eq '#';
32 print BMAYBE $w, "\n" if $f eq '&';
33 }
34 }
35
36 close BMAYBE;
37 close BYES;
38 close OMAYBE;
39 close OYES;
40 close IN;
41
42 open IN, "2of12full.txt";
43 open O02, ">02of12.lst";
44 open O05, ">05of12.lst";
45 open O11, ">11of12.lst";
46 open U, ">4of12upper.lst";
47 open ONA, ">not-abbr.lst";
48 open V, ">variant-also.lst";
49 open NV, ">not-variant.lst";
50
51 while (<IN>)
52 {
53 s/\r?\n$// or die;
54 ($total, $not_variant, $variant, $non_american, $second_class, $word, $abrv_mark)
55 = /^(..): (..) (..)\# (..)\& (..)\= (.+?)([:.]?)$/ or die "Bad Line:$_";
56 $_ = $word;
57 $not_variant = 0 if $not_variant eq ' -';
58 $variant = 0 if $variant eq ' -';
59 $non_american = 0 if $non_american eq ' -';
60 next unless /^[A-Za-z\']+$/;
61 $_ .= "\n";
62 my $not_abrv = ($abrv_mark eq '' && $total >= 5);
63 my $is_variant = ($variant >= $non_american
64 && ($variant + $non_american) > $not_variant
65 && !$already_variant{$word});
66 print ONA if $not_abrv;
67 print V if $is_variant;
68 print NV unless $is_variant || $already_variant{$word};
69 if ($total >= 11) {
70 print O11;
71 } elsif ($total >= 5) {
72 print O05;
73 } elsif ($total >= 4 && /^[A-Z]+/ && $abrv_mark eq '') {
74 print U;
75 } elsif ($total >= 2) {
76 print O02;
77 } else {
78 die "This should not happen: $total $_\n";
79 }
80 }
81
82 close NV;
83 close V;
84 close ONA;
85 close U;
86 close O11;
87 close O05;
88 close O02;
89 close IN;