File: aff2oo.pl

package info (click to toggle)
ispell-czech 20040229-5.2
  • links: PTS
  • area: main
  • in suites: buster, stretch
  • size: 3,588 kB
  • ctags: 5
  • sloc: perl: 703; makefile: 76; sh: 43
file content (70 lines) | stat: -rw-r--r-- 1,461 bytes parent folder | download | duplicates (6)
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";
      }