Interset/Tagset/DE/Stts.pm untested

filter: Statementstmt 0.0% 0 / 142 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 152 CC 1 SCAR 6.9
CC
1
Cov
0%
get_tagset_id
2.0
decode
2.0
BEGIN
2.0
CRAP 2.0
1 # ABSTRACT: Driver for the Stuttgart-Tübingen Tagset of German.
2 # Copyright © 2008, 2014, 2017 Dan Zeman <zeman@ufal.mff.cuni.cz>
3  
4 package Lingua::Interset::Tagset::DE::Stts;
5 use strict;
6 use warnings;
7 our $VERSION = '3.014';
8  
9 use utf8;
10 use open ':utf8';
11 use namespace::autoclean;
12 use Moose;
13 extends 'Lingua::Interset::Atom';
14  
15  
16  
17 #------------------------------------------------------------------------------
18 # Returns the tagset id that should be set as the value of the 'tagset' feature
19 # during decoding. Every derived class must (re)define this method! The result
20 # should correspond to the last two parts in package name, lowercased.
21 # Specifically, it should be the ISO 639-2 language code, followed by '::' and
22 # a language-specific tagset id. Example: 'cs::multext'.
23 #------------------------------------------------------------------------------
24 sub get_tagset_id
25 {
26 return 'de::stts';
27 }
28  
29  
30  
31 #------------------------------------------------------------------------------
32 # This block will be called before object construction. It will build the
33 # decoding and encoding maps for this particular tagset.
34 # Then it will pass all the attributes to the constructor.
35 #------------------------------------------------------------------------------
36 around BUILDARGS => sub
37 {
38 my $orig = shift;
39 my $class = shift;
40 # Call the default BUILDARGS in Moose::Object. It will take care of distinguishing between a hash reference and a plain hash.
41 my $attr = $class->$orig(@_);
42 # Construct decode_map in the form expected by Atom.
43 my %dm =
44 (
45 # common noun / normales Nomen
46 'NN' => ['pos' => 'noun', 'nountype' => 'com'],
47 # proper noun / Eigenname
48 'NE' => ['pos' => 'noun', 'nountype' => 'prop'],
49 # truncated first part of a compound / Kompositions-Erstglied
50 # "be- [und entladen]", "Ein- [und Ausgang]", "Damen- [und Herrenbekleidung]"
51 'TRUNC' => ['hyph' => 'yes'],
52 # attributive adjective / attributives Adjektiv
53 # modifies a noun
54 # all inflected adjectives belong here; some uninflected as well
55 'ADJA' => ['pos' => 'adj'], ###!!! synpos => 'attr' ... we want to get rid of synpos
56 # predicative or adverbial adjective / prädikatives oder adverbiales Adjektiv
57 # also if modifying another adjective
58 'ADJD' => ['pos' => 'adj', 'variant' => 'short'], ###!!! synpos => 'pred' ... we want to get rid of synpos
59 # article / Artikel
60 'ART' => ['pos' => 'adj', 'prontype' => 'art'],
61 # irreflexive personal pronoun / irreflexives Personalpronomen
62 # "ich", "du", "er", "sie", "es", "wir", "ihr"
63 # "mir", "mich", "dir", ... when used irreflexively ("er begegnet mir hier")
64 # "meiner", ... when it is genitive of "ich" (and not a possessive pronoun)
65 'PPER' => ['pos' => 'noun', 'prontype' => 'prs'],
66 # reflexive personal pronoun / reflexives Personalpronomen
67 # "mir", "mich", "dir", "dich", ... when used reflexively ("ich freue mich daran")
68 # "einander" ("sie mögen sich einander")
69 'PRF' => ['pos' => 'noun', 'prontype' => 'prs', 'reflex' => 'yes'],
70 # possessive pronoun / Possessivpronomen
71 # PPOSAT: "mein", "dein", "sein", "ihr", "unser", "euer" ... "ihr Kleid", "euer Auto"
72 # PPOSS: "[das ist] meins"
73 'PPOSAT' => ['pos' => 'adj', 'prontype' => 'prs', 'poss' => 'yes'],
74 'PPOSS' => ['pos' => 'noun', 'prontype' => 'prs', 'poss' => 'yes'],
75 # demonstrative pronoun / Demonstrativpronomen
76 # PDS: "dies [ist ein Buch]", "jenes [ist schwierig]"
77 # PDAT: "dieses [Buch]", "jene [Frage]"
78 # (demonstrative) pronominal adverb / (Demonstrativ-) Pronominaladverb
79 # PAV: "darauf", "hierzu", "deswegen", "außerdem"
80 'PDS' => ['pos' => 'noun', 'prontype' => 'dem'],
81 'PDAT' => ['pos' => 'adj', 'prontype' => 'dem'],
82 'PAV' => ['pos' => 'adv', 'prontype' => 'dem'],
83 # interrogative pronoun / Interrogativpronomen
84 # PWS: "wer", "was" ... "was ist los?", "wer ist da?"
85 # PWAT: "wessen", "welche", ...
86 # PWAV: "wann", "wo", "warum", "worüber", "weshalb" ...
87 'PWS' => ['pos' => 'noun', 'prontype' => 'int'],
88 'PWAT' => ['pos' => 'adj', 'prontype' => 'int'],
89 'PWAV' => ['pos' => 'adv', 'prontype' => 'int'],
90 # relative pronoun / Relativpronomen
91 # PRELS: "was", "welcher" ... "[derjenige], welcher", "[das], was"
92 # PRELAT: "dessen" ... "[der Mann,] dessen [Hut]"
93 'PRELS' => ['pos' => 'noun', 'prontype' => 'rel'],
94 'PRELAT' => ['pos' => 'adj', 'prontype' => 'rel'],
95 # indefinite pronoun / Indefinitpronomen
96 # PIS: "etwas", "nichts", "irgendwas", "man"
97 # PIAT: "etliche [Dinge]", "zuviele [Fragen]", "etwas [Schokolade]"
98 # PIDAT: with determiner: "all [die Bücher]", "solch [eine Frage]", "beide [Fragen]", "viele [Leute]"
99 'PIS' => ['pos' => 'noun', 'prontype' => 'ind|tot|neg'],
100 'PIAT' => ['pos' => 'adj', 'prontype' => 'ind|tot|neg'],
101 'PIDAT' => ['pos' => 'adj', 'prontype' => 'ind|tot|neg', 'adjtype' => 'pdt'],
102 # cardinal number / Kardinalzahl
103 'CARD' => ['pos' => 'num', 'numtype' => 'card'],
104 # verb / Verb
105 # VVFIN VVIMP VVINF VVIZU VVPP VAFIN VAIMP VAINF VAPP VMFIN VMINF VMPP
106 'VAFIN' => ['pos' => 'verb', 'verbtype' => 'aux', 'verbform' => 'fin', 'mood' => 'ind'],
107 'VAIMP' => ['pos' => 'verb', 'verbtype' => 'aux', 'verbform' => 'fin', 'mood' => 'imp'],
108 'VAINF' => ['pos' => 'verb', 'verbtype' => 'aux', 'verbform' => 'inf'],
109 'VAPP' => ['pos' => 'verb', 'verbtype' => 'aux', 'verbform' => 'part', 'aspect' => 'perf'],
110 'VMFIN' => ['pos' => 'verb', 'verbtype' => 'mod', 'verbform' => 'fin', 'mood' => 'ind'],
111 'VMINF' => ['pos' => 'verb', 'verbtype' => 'mod', 'verbform' => 'inf'],
112 'VMPP' => ['pos' => 'verb', 'verbtype' => 'mod', 'verbform' => 'part', 'aspect' => 'perf'],
113 'VVFIN' => ['pos' => 'verb', 'verbform' => 'fin', 'mood' => 'ind'],
114 'VVIMP' => ['pos' => 'verb', 'verbform' => 'fin', 'mood' => 'imp'],
115 'VVINF' => ['pos' => 'verb', 'verbform' => 'inf'],
116 # infinitive with the incorporated "zu" marker: "abzukommen"
117 'VVIZU' => ['pos' => 'verb', 'verbform' => 'inf', 'other' => {'verbform' => 'infzu'}],
118 'VVPP' => ['pos' => 'verb', 'verbform' => 'part', 'aspect' => 'perf'],
119 # adverb / Adverb
120 # "dort", "da", "heute", "dann", "gerne", "sehr", "darum", "sonst", "ja", "aber", "denn"
121 # "miteinander", "nebeneinander", ...
122 # "erstens", "zweitens", "drittens", ...
123 # "einmal", "zweimal", "dreimal", ...
124 # "bzw.", "u.a.", "z.B."
125 'ADV' => ['pos' => 'adv'],
126 # adposition / Adposition
127 # APPR APPRART APPO APZR
128 'APPR' => ['pos' => 'adp', 'adpostype' => 'prep'],
129 # preposition with article / Präposition mit Artikel
130 # "zum", "zur", "aufs", "vom", "im"
131 'APPRART' => ['pos' => 'adp', 'adpostype' => 'prep', 'prontype' => 'art'],
132 # postposition / Postposition
133 # "[der Straße] entlang"
134 # beware: same word in "entlang [der Straße]" is preposition
135 'APPO' => ['pos' => 'adp', 'adpostype' => 'post'],
136 # second part of circumposition / zweiter Teil einer Zirkumposition
137 # (the first part is tagged as preposition)
138 # "[von dieser Stelle] an"
139 'APZR' => ['pos' => 'adp', 'adpostype' => 'circ'],
140 # conjunction / Konjunktion
141 # KOUI KOUS KON KOKOM
142 # subordinating conjunction with infinitive / unterordnende Konjunktion mit Infinitiv
143 # "ohne [zu]", "statt [zu]"
144 'KOUI' => ['pos' => 'conj', 'conjtype' => 'sub', 'other' => {'conjtype' => 'zu'}],
145 # subordinating conjunction with sentence / unterordnende Konjunktion mit Satz
146 # "daß", "weil", "wenn", "obwohl", "als", "damit"
147 'KOUS' => ['pos' => 'conj', 'conjtype' => 'sub'],
148 # coordinating conjunction / nebenordnende Konjunktion
149 # "und", "oder", "entweder ... oder", "weder ... noch", "denn", "aber", "doch", "jedoch"
150 'KON' => ['pos' => 'conj', 'conjtype' => 'coor'],
151 # comparative particle without sentence / Vergleichspartikel ohne Satz
152 # "als", "wie"
153 'KOKOM' => ['pos' => 'conj', 'conjtype' => 'comp'],
154 # particle / Partikel
155 # PTKZU PTKNEG PTKVZ PTKA PTKANT
156 # "zu" before infinitive or future participle / "zu" vor Infinitiv oder Partizipien Futur
157 # "[ohne] zu [wollen]", "[in der] zu [zerstörenden Stadt]"
158 'PTKZU' => ['pos' => 'part', 'parttype' => 'inf'],
159 # negation particle / Negationspartikel
160 # "nicht"
161 'PTKNEG' => ['pos' => 'part', 'polarity' => 'neg'],
162 # separated verb prefix / abgetrennter Verbzusatz
163 # "[er hört] auf", "[er kommt] herbei"
164 'PTKVZ' => ['pos' => 'part', 'parttype' => 'vbp'],
165 # particle with adjective or adverb / Partikel bei Adjektiv oder Adverb
166 # "am [besten]", "[er ist] zu [groß]", "[er fährt] zu [schnell]"
167 'PTKA' => ['pos' => 'part'],
168 # response particle / Antwortpartikel
169 # "ja", "nein", "danke", "bitte", "doch"
170 'PTKANT' => ['pos' => 'part', 'parttype' => 'res'],
171 # interjection / Interjektion
172 'ITJ' => ['pos' => 'int'],
173 # punctuation / Interpunktion
174 # comma / Komma
175 '$,' => ['pos' => 'punc', 'punctype' => 'comm'],
176 # sentence-internal, non-comma / satzintern, nicht Komma
177 # ( ) [ ] { } "
178 '$(' => ['pos' => 'punc', 'punctype' => 'brck'], # )
179 # sentence-final
180 # . ! ? : ;
181 '$.' => ['pos' => 'punc', 'punctype' => 'peri'],
182 # foreign-language material / Fremdsprachliches Material
183 # "[der spanische Film] Mujer de [Benjamin]"
184 'FM' => ['foreign' => 'yes'],
185 # non-word / Nichtwort
186 # "[das Modell] DX3E"
187 'XY' => []
188 );
189 # Construct encode_map in the form expected by Atom.
190 my %em =
191 (
192 'pos' => { 'noun' => { 'prontype' => { '' => { 'nountype' => { 'prop' => 'NE',
193 '@' => 'NN' }},
194 'prs' => { 'reflex' => { 'yes' => 'PRF',
195 '@' => { 'poss' => { 'yes' => 'PPOSS',
196 '@' => 'PPER' }}}},
197 'dem' => 'PDS',
198 'int' => 'PWS',
199 'rel' => 'PRELS',
200 'ind' => 'PIS',
201 'tot' => 'PIS',
202 'neg' => 'PIS',
203 '@' => 'PIS' }},
204 'adj' => { 'adjtype' => { 'pdt' => 'PIDAT',
205 '@' => { 'prontype' => { '' => { 'variant' => { 'short' => 'ADJD',
206 '@' => 'ADJA' }},
207 'prs' => 'PPOSAT',
208 'art' => 'ART',
209 'dem' => 'PDAT',
210 'int' => 'PWAT',
211 'rel' => 'PRELAT',
212 '@' => 'PIAT' }}}},
213 'num' => 'CARD',
214 'verb' => { 'verbtype' => { 'aux' => { 'verbform' => { 'fin' => { 'mood' => { 'imp' => 'VAIMP',
215 '@' => 'VAFIN' }},
216 'part' => 'VAPP',
217 '@' => 'VAINF' }},
218 'mod' => { 'verbform' => { 'fin' => 'VMFIN',
219 'part' => 'VMPP',
220 '@' => 'VMINF' }},
221 '@' => { 'verbform' => { 'fin' => { 'mood' => { 'imp' => 'VVIMP',
222 '@' => 'VVFIN' }},
223 'part' => 'VVPP',
224 '@' => { 'other/verbform' => { 'infzu' => 'VVIZU',
225 '@' => 'VVINF' }}}}}},
226 'adv' => { 'prontype' => { 'dem' => 'PAV',
227 'int' => 'PWAV',
228 '@' => 'ADV' }},
229 'adp' => { 'adpostype' => { 'post' => 'APPO',
230 'circ' => 'APZR',
231 '@' => { 'prontype' => { 'art' => 'APPRART',
232 '@' => 'APPR' }}}},
233 'conj' => { 'conjtype' => { 'sub' => { 'other/conjtype' => { 'zu' => 'KOUI',
234 '@' => 'KOUS' }},
235 'comp' => 'KOKOM',
236 '@' => 'KON' }},
237 'part' => { 'parttype' => { 'inf' => 'PTKZU',
238 'vbp' => 'PTKVZ',
239 'res' => 'PTKANT',
240 '@' => { 'polarity' => { 'neg' => 'PTKNEG',
241 '@' => 'PTKA' }}}},
242 'int' => 'ITJ',
243 'punc' => { 'punctype' => { 'comm' => '$,',
244 'peri' => '$.',
245 '@' => '$(' #)
246 }},
247 '@' => { 'hyph' => { 'yes' => 'TRUNC',
248 '@' => { 'foreign' => { 'yes' => 'FM',
249 '@' => 'XY' }}}}}
250 );
251 # Now add the references to the attribute hash.
252 $attr->{surfeature} = 'pos';
253 $attr->{decode_map} = \%dm;
254 $attr->{encode_map} = \%em;
255 $attr->{tagset} = 'de::stts';
256 return $attr;
257 };
258  
259  
260  
261 #------------------------------------------------------------------------------
262 # Decodes a physical tag (string) and returns the corresponding feature
263 # structure. In addition to Atom, we just need to identify the tagset of
264 # origin (it is not crucial because we do not use the 'other' feature but it
265 # is customary).
266 #------------------------------------------------------------------------------
267 sub decode
268 {
269 my $self = shift;
270 my $tag = shift;
271 my $fs = $self->SUPER::decode($tag);
272 $fs->set_tagset('de::stts');
273 return $fs;
274 }
275  
276  
277  
278 1;
279  
280 __END__
281  
282 =pod
283  
284 =encoding UTF-8
285  
286 =head1 NAME
287  
288 Lingua::Interset::Tagset::DE::Stts - Driver for the Stuttgart-Tübingen Tagset of German.
289  
290 =head1 VERSION
291  
292 version 3.014
293  
294 =head1 SYNOPSIS
295  
296 use Lingua::Interset::Tagset::DE::Stts;
297 my $driver = Lingua::Interset::Tagset::DE::Stts->new();
298 my $fs = $driver->decode('NN');
299  
300 or
301  
302 use Lingua::Interset qw(decode);
303 my $fs = decode('de::stts', 'NN');
304  
305 =head1 DESCRIPTION
306  
307 Interset driver for the Stuttgart-Tübingen Tagset of German.
308  
309 =head1 SEE ALSO
310  
311 L<Lingua::Interset>
312 L<Lingua::Interset::Tagset>,
313 L<Lingua::Interset::Atom>,
314 L<Lingua::Interset::Tagset::DE::Conll>,
315 L<Lingua::Interset::FeatureStructure>
316  
317 =head1 AUTHOR
318  
319 Dan Zeman <zeman@ufal.mff.cuni.cz>
320  
321 =head1 COPYRIGHT AND LICENSE
322  
323 This software is copyright (c) 2019 by Univerzita Karlova (Charles University).
324  
325 This is free software; you can redistribute it and/or modify it under
326 the same terms as the Perl 5 programming language system itself.
327  
328 =cut