/[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 5 by dpavlin, Sat Feb 26 02:18:43 2005 UTC revision 9 by dpavlin, Sat Feb 26 18:54:49 2005 UTC
# Line 35  my $su = '[^aeiou]'; Line 35  my $su = '[^aeiou]';
35    
36  my $palatal = '(lj|nj|j|æ|¾|¹|¾|¹t|¾d)';  my $palatal = '(lj|nj|j|æ|¾|¹|¾|¹t|¾d)';
37    
38    # glagolni razredi
39    my $g_1r = '[td]';
40    my $g_2r = '[sz]';
41    my $g_3r = '[pb]';
42    my $g_4r = '[kgh]';
43    my $g_5r = '[nm]';
44    my $g_6r = '(:?nu|n)';
45    
46  my %rules;  my %rules;
47  my %stem_words;  my %stem_words;
48  my $words = 0;  my $words = 0;
# Line 42  my $stems = 0; Line 50  my $stems = 0;
50    
51    
52  my $last_stem = '';  my $last_stem = '';
53    my $errors = 0;
54  sub check_stem {  sub check_stem {
55          my $s = shift || return;          my $s = shift || return;
56          if ($last_stem) {          if ($last_stem) {
57                  print "ERROR==> " if ($last_stem ne $s);                  if ($last_stem ne $s) {
58                            print "ERROR==> ";
59                            $errors++;
60                    }
61          } else {          } else {
62                  $last_stem = $s;                  $last_stem = $s;
63          }          }
# Line 64  while(<>) { Line 76  while(<>) {
76    
77          my $orig = $_;          my $orig = $_;
78    
         # imenice  
79    
80          unless (          unless (
81                    # infinitiv
82                    s/(\w)(ti|æi)$/$1.$2 100/g ||
83                    # 1. razred
84                    s/([^sk])[td](em|e¹|e|emo|ete|oh|osmo|oste|o¹e|ijah|ija¹e|ijasno|ijaste|ijahu|imo|ite|en|ena|eni)$/$1s.ti 101/g ||
85                    # 2. razred
86                    s/(${sa})[sz](em|e¹|e|e¹emo|emo|ete|u|oh|e|osmo|oste|o¹e|ijah|ija¹e|ijasmo|ijaste|ijahu|imo|ite|uæi|av¹i|ao|la|lo|li|le|la|en|ena|eni)$/$1s.ti 102/ ||
87                    # 3. razdred
88                    s/(p|b|sp|su)(em|e¹|e|emo|ete|u|oh|osmo|oste|o¹e|ah|a¹e|asmo|aste|ahu|ijah|ija¹e|i|imo|ite||uæi|av¹i|ao|la|lo|en|ena|eni)$/$1s.ti 103/ ||
89    
90                    # imenice
91    
92                  # vrsta a                  # vrsta a
                 s/${palatal}e$/$1e 10/g ||  
93                  s/(${su}st)a$/$1 13/g ||                  s/(${su}st)a$/$1 13/g ||
94                  s/(${su})c[ae]$/$1ce 17/g ||                  s/(${su})c[ae]$/$1ce 17/g ||
95                  # kgh                  # kgh
96                  s/(${sa})([è¾¹czs])(i|e|ima)$/kgh($1,$2,' 1')/gex ||                  s/(\w${sa})([è¾¹czs])(i|e|ima)$/kgh($1,$2,' 1')/gex ||
97                  s/(${sa}[kgh])(a|u|om)$/$1 2/g ||                  s/(${sa}[kgh])(a|u|om)$/$1 2/g ||
98                  s/(${su})([è¾¹czs])(i|e|ima)$/kgh($1,"a$2",' 3')/gex ||                  s/(${su})([è¾¹czs])(i|e|ima)$/kgh($1,"a$2",' 3')/gex ||
99                  # imenice na palatal                  # imenice na palatal
# Line 86  while(<>) { Line 107  while(<>) {
107                  # vrsta a                  # vrsta a
108                  s/me$/me 11/g ||                  s/me$/me 11/g ||
109                  s/(eta|ena)$/e 12/g ||                  s/(eta|ena)$/e 12/g ||
110                  s/(${sa}${su})(o|e|a|u|om|em|i|ima)$/$1 7/g;  
111                    s/(\w${sa}${su})(o|e|a|u|om|em|i|ima|ina|eta)$/$1 7/g ||
112    
113                  s/(${su})sa$/$1as 14/g ||                  s/(${su})sa$/$1as 14/g ||
114                  s/(${su})ena$/$1e 16/g ||                  s/(${su})ena$/$1e 16/g ||
115                  s/eta$/e 17/g ||                  s/(${su})eta$/$1e 17/g ||
116                  s/(${su})([oe])$/$1-$2 18/g ||                  s/(${su})([oe])$/$1$2 18/g ||
117    
118                    0;
119    
                 # mno¾ina  
                 s/(${su})(ov|ev)*(i|a|ima|e|in|ina|eta)$/$1 6/g;  
120          }          }
121    
122          if (s/^(.+)\s(\d+)$/$1\t$2/g) {          if (s/^(.+)\s(\d+)$/$1\t$2/g) {
# Line 110  while(<>) { Line 132  while(<>) {
132    
133  }  }
134  my $nr_stems = keys(%stem_words);  my $nr_stems = keys(%stem_words);
135  printf "\n# %d words, %d stems in %d ops, %.2f%% size\n",$words,$nr_stems,$stems,($nr_stems*100/$words);  printf "\n# %d words, %d stems in %d ops, %.2f%% size [%d errors]\n",$words,$nr_stems,$stems,($nr_stems*100/$words),$errors;
136    
137  foreach my $s (keys %stem_words) {  foreach my $s (keys %stem_words) {
138          print "#stem $stem_words{$s} $s\n";          print "#stem $stem_words{$s} $s\n";

Legend:
Removed from v.5  
changed lines
  Added in v.9

  ViewVC Help
Powered by ViewVC 1.1.26