File: afftoOOo

package info (click to toggle)
br.ispell 3.0~beta4-12
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 892 kB
  • ctags: 76
  • sloc: perl: 2,337; awk: 1,209; makefile: 203; sh: 96
file content (90 lines) | stat: -rwxr-xr-x 1,997 bytes parent folder | download | duplicates (11)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/perl

#
# Conversor de afixos ispell -> myspell, por Ricardo Ueda.
#

#
# Cabealho.
#
# Obs. a linha "TRY" usa as freqncias aeosrindtmuclpvghqbfzjx
# indicadas no livro "Teoria Lingstica" p. 47 (M. T. C. Biderman,
# Martins Fontes 2001), temperadas com outras contagens. Inclu
# tambm caracteres acentuados que no ocorrem no Portugus porque
# o myspell no sugere palavras que usem caracteres no listados
# na linha TRY, e talvez algum que no conhea isso necessite
# adicionar ao dicionrio nomes ou palavras estrangeiras.
#
print "SET ISO8859-1\n";
print "TRY aeosrindtmuclpvghqbfzjxAEBDMCSRPLGVFTNIJHUkwyZOQKYWX\n";

# prepara
open(F,"br.aff");
$mode = '?';
$in = 0;

# converso
while (<F>) {

    # prepara
    chomp;
    #tr/\t/ /;
    $l = $_;

    # incio da seo de prefixos
    if (/^prefixes/) {
        $mode = 'PFX';
    }

    # incio da seo de sufixos
    elsif (/^suffixes/) {
        $mode = 'SFX';
    }

    # incio de bloco de regras
    elsif (/^flag/) {

        if (($in) && ($nr > 0)) {
            print "$mode $f $c $nr\n";
            print $R;
        }

        if (($c,$f) = ($l =~ /^flag (\*|)([A-Za-z]):.*$/)) {
            $c = ($c eq '*') ? 'Y' : 'N';
            $in = 1;
            $nr = 0;
            $R = '';
        }
        else {
            print "falha no parse de $l\n";
            exit 1;
        }
    }

    # comentrio ou linha em branco
    elsif (/^ *(#.*|)$/) {
        #print "desprezei $l\n";
    }

    # regra
    elsif ($in) {
        $l =~ s/#.*$//;
        $l =~ s/[ -]//g;
        $l =~ tr/A-Z/a-z/;
        ($cond,$a) = ($l =~ /^(.*)>(.*)$/);
        if ($a =~ /,/) {
            ($rem,$adc) = ($a =~ /^(.*),(.*)$/);
        }
        else {
            $rem = '0';
            $adc = $a;
        }
        $R .= sprintf("$mode $f $rem $adc $cond\n");
        ++$nr;
    }

    # outros
    else {
    }
}