/[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

Contents of /StemHR.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2 - (show annotations)
Fri Feb 25 23:40:18 2005 UTC (19 years, 1 month ago) by dpavlin
Original Path: stem-hr.pl
File MIME type: text/plain
File size: 935 byte(s)
imenice na -ak

1 #!/usr/bin/perl -w
2 #
3 # Croatian stemmer
4 #
5
6 # promjenjive:
7 # - imenice
8 # - pridjevi
9 # - brojevi
10 # - zamjenice
11 # - prilozi
12 # - glagoli
13 #
14 # nepromjenjive:
15 # - prijedlozi
16 # - veznici
17 # - èestice
18 # - uzvici
19 #
20
21 sub rm_a {
22 s/a//g;
23 }
24
25 sub kgh {
26 my ($pre,$replace,$post) = @_;
27 $replace =~ s/[cè]/k/g;
28 $replace =~ s/[z¾]/g/g;
29 $replace =~ s/[s¹]/h/g;
30 return $pre . $replace . $post;
31 }
32
33 # samoglasnici
34 my $sa = '[aeiou]';
35 # suglasnici
36 my $su = '[^aeiou]';
37
38 while(<>) {
39 chomp;
40
41 my $orig = $_;
42
43 # imenice
44 # vrsta a
45
46 unless (
47 # kgh
48 s/(${sa})([è¾¹czs])(i|e|ima)$/kgh($1,$2,' 1')/gex ||
49 s/(${sa}[kgh])(a|u|om)$/$1 2/g ||
50 s/(${su})([è¾¹czs])(i|e|ima)$/kgh($1,"a$2",' 3')/gex ||
51 # nepostojano a
52 s/(${su}a{$su})a/$1 4/g ||
53 s/(${su})(${su})(a|u|i|e|om|ima)$/$1a$2 5/g
54 ) {
55
56 # mno¾ina
57 s/(${su})(ov|ev)*(i|a|ima|e|in|ina)$/$1 6/g;
58 # jednina
59 s/(o|e|a|u|om|em)$/ 7/g;
60 }
61
62 s/\s(\d+)$/\t$1/g;
63
64 printf("%-15s %s\n",$orig,$_);
65 }

Properties

Name Value
svn:executable

  ViewVC Help
Powered by ViewVC 1.1.26