-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtospeling-gd.pl
169 lines (165 loc) · 4.06 KB
/
tospeling-gd.pl
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/perl
use strict;
use warnings;
use utf8;
binmode STDIN, ":utf8";
binmode STDOUT, ":utf8";
binmode STDERR, ":utf8";
# pipe fullstem-nomutate-gd.txt through this
# and output in "speling.org" format; see
# http://wiki.apertium.org/wiki/Speling_format
while (<STDIN>) {
chomp;
(my $pos, my $surface, my $lemmapos, my $lemma) = m/^(<[^>]+>)([^<]+)<\/[A-Z]> <([A-Z])[^>]*>([^<]+)<\/[A-Z]>$/;
my $flags;
my $my_pos;
if ($pos =~ m/^<N/) {
$my_pos = 'n';
if ($pos =~ m/gnd="m"/) {
$my_pos .= '.m';
}
elsif ($pos =~ m/gnd="f"/) {
$my_pos .= '.f';
}
if ($pos =~ m/pl="y"/) {
$flags = 'pl';
}
else {
$flags = 'sg';
}
if ($pos =~ m/gnt="n"/) {
$flags .= '.com';
}
elsif ($pos =~ m/gnt="y"/) {
$flags .= '.gen';
}
# no datives else { $flags .= '.dat'; }
if ($lemmapos eq 'V') {
if ($my_pos =~ /f$/) {
$flags = "ger.f.$flags";
}
elsif ($my_pos =~ /m$/) {
$flags = "ger.m.$flags";
}
else {
$flags = "ger.$flags";
}
$my_pos = 'vblex';
}
print "$lemma; $surface; $flags; $my_pos\n";
}
elsif ($pos =~ m/^<V/) { # don't forget copula
$my_pos = 'vblex';
if ($pos =~ m/cop="y"/) {
next;
}
else {
# ignoring p="[y|n]" now, use endings
if ($pos =~ m/t="ord"/) {
$flags = 'imp';
if ($surface eq $lemma) {
print "$lemma; $surface; $flags.p2.sg; $my_pos\n";
}
elsif ($surface =~ m/ibh$/) {
print "$lemma; $surface; $flags.p2.pl; $my_pos\n";
}
else {
print STDERR "Fadhb le foirm $surface (ord)\n";
}
}
# elsif ($pos =~ m/t="láith"/) { }
elsif ($pos =~ m/t="coinn"/) {
$flags = 'cni';
if ($surface =~ m/nn$/) {
print "$lemma; $surface; $flags.p1.sg; $my_pos\n";
}
elsif ($surface =~ m/fe?á$/) {
}
elsif ($surface =~ m/dh$/) {
print "$lemma; $surface; $flags.p2.sg; $my_pos\n";
print "$lemma; $surface; $flags.p3.sg; $my_pos\n";
print "$lemma; $surface; $flags.p2.pl; $my_pos\n";
print "$lemma; $surface; $flags.p3.pl; $my_pos\n";
}
elsif ($surface =~ m/maid$/) {
print "$lemma; $surface; $flags.p1.pl; $my_pos\n";
}
else {
print STDERR "Fadhb le foirm $surface (coinn)\n";
}
}
# elsif ($pos =~ m/t="gnáth"/) { }
elsif ($pos =~ m/t="fáist"/) {
$flags = 'fti';
if ($surface =~ m/idh$/ or $surface eq 'nì') {
print "$lemma; $surface; $flags.p1.sg; $my_pos\n";
print "$lemma; $surface; $flags.p2.sg; $my_pos\n";
print "$lemma; $surface; $flags.p3.sg; $my_pos\n";
print "$lemma; $surface; $flags.p1.pl; $my_pos\n";
print "$lemma; $surface; $flags.p2.pl; $my_pos\n";
print "$lemma; $surface; $flags.p3.pl; $my_pos\n";
}
else {
print STDERR "Fadhb le foirm $surface (fáist)\n";
}
}
elsif ($pos =~ m/t="caite"/) {
$flags = 'past';
if ($surface eq $lemma or $surface eq 'ràinig' or $surface eq 'rinn' or $surface eq 'rug') {
print "$lemma; $surface; $flags.p1.sg; $my_pos\n";
print "$lemma; $surface; $flags.p2.sg; $my_pos\n";
print "$lemma; $surface; $flags.p3.sg; $my_pos\n";
print "$lemma; $surface; $flags.p1.pl; $my_pos\n";
print "$lemma; $surface; $flags.p2.pl; $my_pos\n";
print "$lemma; $surface; $flags.p3.pl; $my_pos\n";
}
else {
print STDERR "Fadhb le foirm $surface (caite)\n";
}
}
# elsif ($pos =~ m/t="foshuit"/) { }
}
}
elsif ($pos =~ m/^<A/) {
$my_pos = 'adj';
if ($pos =~ m/gnt="y"/) {
if ($pos =~ m/gnd="m"/) {
$flags = 'm';
}
elsif ($pos =~ m/gnd="f"/) {
$flags = 'f';
}
$flags .= '.sg.gen';
}
elsif ($pos =~ m/pl="y"/) {
$flags = 'pl';
}
else {
$flags = 'sg';
}
if ($lemmapos eq 'V') {
$my_pos = 'vblex';
$flags = "pp.$flags";
}
print "$lemma; $surface; $flags; $my_pos\n";
}
# elsif ($pos =~ m/^<R/) {
# $my_pos = 'adv';
# }
# elsif ($pos =~ m/^<S/) {
# $my_pos = 'pr';
# }
# elsif ($pos =~ m/^<P/) {
# $my_pos = 'prn';
# }
# elsif ($pos =~ m/^<T/) {
# $my_pos = 'det';
# }
# elsif ($pos =~ m/^<I/) {
# $my_pos = 'ij';
# }
else {
next; # <O>, <C>, <D>, <U>, <Q>
}
}
exit 0;