/[stem-hr]/StemHR.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /StemHR.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4 by dpavlin, Sat Feb 26 00:37:18 2005 UTC revision 6 by dpavlin, Sat Feb 26 16:19:22 2005 UTC
# Line 33  my $sa = '[aeiou]'; Line 33  my $sa = '[aeiou]';
33  # suglasnici  # suglasnici
34  my $su = '[^aeiou]';  my $su = '[^aeiou]';
35    
36    my $palatal = '(lj|nj|j|æ|¾|¹|¾|¹t|¾d)';
37    
38  my %rules;  my %rules;
39  my %stem_words;  my %stem_words;
40  my $words = 0;  my $words = 0;
41  my $stems = 0;  my $stems = 0;
42    
43    
44    my $last_stem = '';
45    sub check_stem {
46            my $s = shift || return;
47            if ($last_stem) {
48                    print "ERROR==> " if ($last_stem ne $s);
49            } else {
50                    $last_stem = $s;
51            }
52    }
53    
54  while(<>) {  while(<>) {
55          chomp;          chomp;
56            next if (/^#/);
57          if (/^$/) {          if (/^$/) {
58                  print "\n";                  print "\n";
59                    $last_stem = '';
60                  next;                  next;
61          }          }
62    
# Line 50  while(<>) { Line 65  while(<>) {
65          my $orig = $_;          my $orig = $_;
66    
67          # imenice          # imenice
         # vrsta a  
68    
69          unless (          unless (
70                    # vrsta a
71                    s/(${su}st)a$/$1 13/g ||
72                    s/(${su})c[ae]$/$1ce 17/g ||
73                  # kgh                  # kgh
74                  s/(${sa})([è¾¹czs])(i|e|ima)$/kgh($1,$2,' 1')/gex ||                  s/(${sa})([è¾¹czs])(i|e|ima)$/kgh($1,$2,' 1')/gex ||
75                  s/(${sa}[kgh])(a|u|om)$/$1 2/g ||                  s/(${sa}[kgh])(a|u|om)$/$1 2/g ||
76                  s/(${su})([è¾¹czs])(i|e|ima)$/kgh($1,"a$2",' 3')/gex ||                  s/(${su})([è¾¹czs])(i|e|ima)$/kgh($1,"a$2",' 3')/gex ||
77                    # imenice na palatal
78                    s/${palatal}${palatal}(a|u|em|i|ima|e)$/$1a$2 9/g ||
79                    s/${palatal}(a|u|em)$/$1 8/g ||
80                  # nepostojano a                  # nepostojano a
81                  s/(${su}a{$su})a/$1 4/g ||                  s/(${su}a{$su})a/$1 4/g ||
82                  s/(${su})(${su})(a|u|i|e|om|ima)$/$1a$2 5/g                  s/(${su})(${su})(a|u|i|e|om|ima)$/$1a$2 5/g
83          ) {          ) {
84    
85                    # vrsta a
86                    s/me$/me 11/g ||
87                    s/(eta|ena)$/e 12/g ||
88                    s/(${sa}${su})(o|e|a|u|om|em|i|ima|ina)$/$1 7/g ||
89    
90                    s/(${su})sa$/$1as 14/g ||
91                    s/(${su})ena$/$1e 16/g ||
92                    s/(${su})eta$/$1e 17/g ||
93                    s/(${su})([oe])$/$1-$2 18/g ||
94    
95                  # mno¾ina                  # mno¾ina
96                  s/(${su})(ov|ev)*(i|a|ima|e|in|ina)$/$1 6/g;                  s/(${su})(ov|ev)*(i|a|ima|e|in|ina|eta)$/$1 6/g;
                 # jednina  
                 s/(o|e|a|u|om|em)$/ 7/g;  
97          }          }
98    
99          if (s/^(.+)\s(\d+)$/$1\t$2/g) {          if (s/^(.+)\s(\d+)$/$1\t$2/g) {
100                  $rules{$2}++;                  $rules{$2}++;
101                  $stems++;                  $stems++;
102                  $stem_words{$1}++;                  $stem_words{$1}++;
103                    check_stem($1);
104            } else  {
105                    $last_stem = $_;
106          }          }
107    
108          printf("%-15s %s\n",$orig,$_);          printf("%-15s %s\n",$orig,$_);
# Line 84  foreach my $s (keys %stem_words) { Line 115  foreach my $s (keys %stem_words) {
115          print "#stem $stem_words{$s} $s\n";          print "#stem $stem_words{$s} $s\n";
116  }  }
117    
118  foreach my $r (keys %rules) {  foreach my $r (sort keys %rules) {
119          print "#rule $rules{$r} $r\n";          print "#rule $rules{$r} $r\n";
120  }  }

Legend:
Removed from v.4  
changed lines
  Added in v.6

  ViewVC Help
Powered by ViewVC 1.1.26