This repository has been archived by the owner on Jun 19, 2023. It is now read-only.
forked from tvondra/ispell_czech
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaff2oo.pl
70 lines (67 loc) · 1.43 KB
/
aff2oo.pl
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
#!/usr/bin/perl
#
# .aff -> Open Office afix file convertor; not tested!!!
# Using:
# perl aff2oo.pl czech.aff
#
use locale;
$number='';
while (<>) {
if (/^prefixes/) {
$affixtype='PFX';
} elsif (/^suffixes/) {
$affixtype='SFX';
} else {
next if (!$affixtype);
if (/^flag (\*?)(.):/) {
if ($number ne '') {
$out=shift(@OUT);
print "$out $number\n";
print @OUT;
print "\n";
}
$flag=$2;
$combined=($1 eq '')? 'N' : 'Y';
@OUT=("$affixtype $flag $combined");
$number=0;
} else {
s/\n$//;
s/\s*\#.*$//;
s/^\s*//;
#print "Line: `$_'\n";
if (/^([^\>]*)>(.*)/) {
$cond=$1;
$rest=$2;
#print "\$cond: `$cond'\n";
#print "\$rest: `$rest'\n";
$cond=~s/^\s*//;
$cond=~s/\s*$//;
$rest=~s/^\s*//;
$rest=~s/\s*$//;
#print "\$cond: `$cond'\n";
#print "\$rest: `$rest'\n";
if ($rest=~/-(.*),(.*)/) {
$remove=$1;
$add=$2;
} else {
$remove='0';
$add=$rest;
}
$remove=~s/\s*$//;
$add=~s/^\s*//;
$cond=~s/ //g;
$remove=lc($remove);
$add=lc($add);
$cond=lc($cond);
push(@OUT, "$affixtype $flag $remove $add $cond\n");
$number++;
}
}
}
}
if ($number ne '') {
$out=shift(@OUT);
print "$out $number\n";
print @OUT;
print "\n";
}