line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl |
2
|
|
|
|
|
|
|
# -*- Mode: Perl -*- |
3
|
|
|
|
|
|
|
# Word.pm -- |
4
|
|
|
|
|
|
|
# ITIID : $ITI$ $Header $__Header$ |
5
|
|
|
|
|
|
|
# Author : Ulrich Pfeifer |
6
|
|
|
|
|
|
|
# Created On : Thu Feb 1 13:57:42 1996 |
7
|
|
|
|
|
|
|
# Last Modified By: Ulrich Pfeifer |
8
|
|
|
|
|
|
|
# Last Modified On: Sun Apr 3 12:17:56 2005 |
9
|
|
|
|
|
|
|
# Language : Perl |
10
|
|
|
|
|
|
|
# Update Count : 70 |
11
|
|
|
|
|
|
|
# Status : Unknown, Use with caution! |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
package Text::German; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$VERSION = $VERSION = 0.06; |
17
|
2
|
|
|
2
|
|
4370
|
use Text::German::Util; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1970
|
|
18
|
|
|
|
|
|
|
require Text::German::Adjektiv; |
19
|
|
|
|
|
|
|
require Text::German::Ausnahme; |
20
|
|
|
|
|
|
|
require Text::German::Endung; |
21
|
|
|
|
|
|
|
require Text::German::Regel; |
22
|
|
|
|
|
|
|
require Text::German::Verb; |
23
|
|
|
|
|
|
|
require Text::German::Vorsilbe; |
24
|
|
|
|
|
|
|
require Text::German::Cache; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub partition { |
27
|
28
|
|
|
28
|
0
|
32
|
my $word = shift; |
28
|
28
|
|
|
|
|
85
|
my $vorsilbe = Text::German::Vorsilbe::max_vorsilbe($word); |
29
|
28
|
|
100
|
|
|
109
|
my $vl = length($vorsilbe||''); |
30
|
28
|
|
|
|
|
103
|
my $endung = Text::German::Endung::max_endung(substr($word,$vl)); |
31
|
28
|
|
100
|
|
|
113
|
my $el = length($endung||''); |
32
|
28
|
|
|
|
|
35
|
my $l = length($word); |
33
|
|
|
|
|
|
|
|
34
|
28
|
|
|
|
|
110
|
return ($vorsilbe, substr($word, $vl, $l-$vl-$el), $endung); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub reduce { |
38
|
28
|
|
|
28
|
0
|
169
|
my $word = shift; |
39
|
28
|
|
|
|
|
35
|
my $satz_anfang = shift; |
40
|
28
|
|
|
|
|
55
|
my @word = partition($word); |
41
|
28
|
|
|
|
|
60
|
my @tmp; |
42
|
|
|
|
|
|
|
|
43
|
28
|
50
|
|
|
|
59
|
printf "INIT %s\n", join ':', @word if $debug; |
44
|
28
|
|
100
|
|
|
101
|
$word[0] ||= ''; |
45
|
28
|
|
100
|
|
|
69
|
$word[2] ||= ''; |
46
|
|
|
|
|
|
|
|
47
|
28
|
|
|
|
|
83
|
my $a = Text::German::Ausnahme::reduce(@word); |
48
|
28
|
100
|
|
|
|
63
|
return($a) if defined $a; |
49
|
|
|
|
|
|
|
|
50
|
26
|
|
|
|
|
62
|
my $c = wordclass($word, $satz_anfang); |
51
|
|
|
|
|
|
|
|
52
|
26
|
100
|
66
|
|
|
71
|
unless ($c&$FUNNY || $word[2]) { |
53
|
4
|
|
|
|
|
14
|
return $word[1]; |
54
|
|
|
|
|
|
|
} |
55
|
22
|
100
|
|
|
|
46
|
if ($c & $VERB) { |
56
|
19
|
|
|
|
|
56
|
@tmp = Text::German::Verb::reduce(@word); |
57
|
19
|
100
|
|
|
|
59
|
if ($#tmp) { |
58
|
2
|
|
|
|
|
8
|
@word = @tmp; |
59
|
2
|
50
|
|
|
|
7
|
printf "VERB %s\n", join ':', @word if $debug; |
60
|
2
|
|
|
|
|
11
|
return($word[1].'en'); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
20
|
100
|
|
|
|
45
|
if ($c & $ADJEKTIV) { |
64
|
17
|
|
|
|
|
50
|
@tmp = Text::German::Adjektiv::reduce(@word); |
65
|
17
|
50
|
|
|
|
40
|
if ($#tmp) { |
66
|
0
|
|
|
|
|
0
|
@word = @tmp; |
67
|
0
|
0
|
|
|
|
0
|
printf "VERB %s\n", join ':', @word if $debug; |
68
|
0
|
|
|
|
|
0
|
return($word[1]); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
20
|
|
|
|
|
58
|
@tmp = Text::German::Regel::reduce(@word); |
72
|
20
|
100
|
|
|
|
103
|
if ($#tmp) { |
73
|
16
|
|
|
|
|
42
|
@word = @tmp; |
74
|
16
|
50
|
|
|
|
40
|
printf "REGEL %s\n", join ':', @word if $debug; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
#return join ':', @word; |
77
|
20
|
|
|
|
|
110
|
return $word[0].$word[1]; # vorsilbe wieder anhaengen |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
# Do not use this! |
81
|
|
|
|
|
|
|
my $cache; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub cache_reduce { |
84
|
18
|
100
|
|
18
|
0
|
206
|
unless ($cache) { |
85
|
14
|
|
|
14
|
|
35
|
$cache = Text::German::Cache->new(Verbose => 0, |
86
|
|
|
|
|
|
|
Function => sub {reduce($_[0], 1); }, |
87
|
1
|
|
|
|
|
15
|
Gc => 1000, |
88
|
|
|
|
|
|
|
Hold => 600, |
89
|
|
|
|
|
|
|
); |
90
|
|
|
|
|
|
|
} |
91
|
18
|
|
|
|
|
58
|
$cache->get(@_); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# This is a hoax! |
95
|
|
|
|
|
|
|
sub stem { |
96
|
0
|
|
|
0
|
0
|
|
my $word = shift; |
97
|
0
|
|
|
|
|
|
my $gf = reduce($word, @_); |
98
|
0
|
|
|
|
|
|
my @word = partition($gf); |
99
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
return $word[1]; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |