Interset/Tagset/RO/Multext.pm untested

filter: Statementstmt 0.0% 0 / 101 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 115 CC 1 SCAR 6.9
CC
1
Cov
0%
get_tagset_id
2.0
_create_atoms
2.0
_create_feature_map
2.0
CRAP 2.0
1 # ABSTRACT: Driver for the Romanian tagset of the Multext-EAST v4 project.
2 # http://nl.ijs.si/ME/V4/msd/html/msd-ro.html
3 # Copyright © 2015, 2017 Dan Zeman <zeman@ufal.mff.cuni.cz>
4  
5 package Lingua::Interset::Tagset::RO::Multext;
6 use strict;
7 use warnings;
8 our $VERSION = '3.015';
9  
10 use utf8;
11 use open ':utf8';
12 use namespace::autoclean;
13 use Moose;
14 extends 'Lingua::Interset::Tagset::Multext';
15  
16  
17  
18 #------------------------------------------------------------------------------
19 # Returns the tagset id that should be set as the value of the 'tagset' feature
20 # during decoding. Every derived class must (re)define this method! The result
21 # should correspond to the last two parts in package name, lowercased.
22 # Specifically, it should be the ISO 639-2 language code, followed by
23 # '::multext'. Example: 'cs::multext'.
24 #------------------------------------------------------------------------------
25 sub get_tagset_id
26 {
27 return 'ro::multext';
28 }
29  
30  
31  
32 #------------------------------------------------------------------------------
33 # This block will be called before object construction. It will build the
34 # decoding and encoding maps for this particular tagset.
35 # Then it will pass all the attributes to the constructor.
36 #------------------------------------------------------------------------------
37 around BUILDARGS => sub
38 {
39 my $orig = shift;
40 my $class = shift;
41 # Call the default BUILDARGS in Moose::Object. It will take care of distinguishing between a hash reference and a plain hash.
42 my $attr = $class->$orig(@_);
43 # Tell the POS atom that this language uses determiners, articles and entities.
44 $attr->{determiners} = 1;
45 return $attr;
46 };
47  
48  
49  
50 #------------------------------------------------------------------------------
51 # Creates atomic drivers for surface features.
52 #------------------------------------------------------------------------------
53 sub _create_atoms
54 {
55 my $self = shift;
56 # Most atoms can be inherited but some have to be redefined.
57 my $atoms = $self->SUPER::_create_atoms();
58 # CASE ####################
59 $atoms->{case} = $self->create_atom
60 (
61 'surfeature' => 'case',
62 'decode_map' =>
63 {
64 # Direct case of nouns, articles and numerals. The base form.
65 # example indefinite nouns: dor, târg, gând, suflet, deal
66 # example definite nouns: locul, anul, orașul, cazul, teritoriul
67 # example articles: cel, cea, cei, cele, un, o, -ul
68 'r' => ['case' => 'nom'],
69 # Indirect case of nouns, articles and numerals.
70 # In Romanian it corresponds to genitive rather than accusative!
71 # example definite nouns: secolului, guvernului, medicului, numelui, orașului
72 # example articles: celei, celor, unui, unei, unor, lui, -ului
73 'o' => ['case' => 'gen'],
74 # Vocative case, rarely used with nouns.
75 # example: domnule (sir)
76 'v' => ['case' => 'voc'],
77 # Nominative case, used only with 1st and 2nd person singular pronouns (non-possessive).
78 # examples: eu (I), tu (you)
79 'n' => ['case' => 'nom'],
80 # Dative case of personal pronouns.
81 # examples: mi (me), ți (you), i (him, her), ne (us), vă (you), le (them), și (oneself)
82 'd' => ['case' => 'dat'],
83 # Accusative case of personal pronouns.
84 # examples: mine, mă (me), tine, te (you), îl (him), o (her), ne (us), vă (you), îi, le (them), se (oneself)
85 'a' => ['case' => 'acc'],
86 # Genitive case occurs only as subcategorization case of prepositions, and the following noun is tagged as oblique case.
87 # examples: asupra (on), în_jurul (around)
88 'g' => ['case' => 'gen']
89 },
90 'encode_map' =>
91 {
92 'case' => { 'nom' => { 'prontype' => { 'prs' => { 'poss' => { '' => { 'number' => { 'sing' => { 'person' => { '1' => 'n',
93 '2' => 'n',
94 '@' => 'r' }},
95 '@' => 'r' }},
96 '@' => 'r' }},
97 '@' => 'r' }},
98 'gen' => { 'pos' => { 'adp' => 'g',
99 '@' => 'o' }},
100 'voc' => 'v',
101 'dat' => 'd',
102 'acc' => 'a',
103 '@' => '-' }
104 }
105 );
106 # FORMATION ####################
107 # This feature corresponds to adposition_formation, defined in the general Multext driver class.
108 # However, it is different and we need the 'other' feature here. (The "general" variant is quite specific too, but for Czech.)
109 # formation of adpositions and conjunctions: simple (s) / compound (c)
110 # simple conjunctions: sau (36) dar (11) însă (7) că (6)
111 # compound conjunctions: așa_că (1)
112 # simple adpositions: de, în, la, din, cu
113 # compound adpositions: de_la, până_la, înainte_de, de_după
114 $atoms->{formation} = $self->create_atom
115 (
116 'surfeature' => 'formation',
117 'decode_map' =>
118 {
119 's' => ['other' => {'formation' => 'simple'}],
120 'c' => ['other' => {'formation' => 'compound'}]
121 },
122 'encode_map' =>
123 {
124 'other/formation' => { 'simple' => 's',
125 'compound' => 'c',
126 '@' => 's' }
127 }
128 );
129 # COORDINATION TYPE ####################
130 # simple, between conjuncts: Ion ori Maria (John or Mary)
131 # repetitive, before each conjunct: Ion fie Maria fie... (either John or Mary or...)
132 # correlative, before a conjoined phrase, it requires specific coordinators between conjuncts: atât mama cât şi tata (both mother and father)
133 # All examples in the UD Romanian corpus are tagged as simple.
134 $atoms->{coord_type} = $self->create_atom
135 (
136 'surfeature' => 'coordtype',
137 'decode_map' =>
138 {
139 's' => ['other' => {'coordtype' => 'simple'}],
140 'r' => ['other' => {'coordtype' => 'repetit'}],
141 'c' => ['other' => {'coordtype' => 'correlat'}]
142 },
143 'encode_map' =>
144 {
145 'other/coordtype' => { 'simple' => 's',
146 'repetit' => 'r',
147 'correlat' => 'c',
148 '@' => 's' }
149 }
150 );
151 # COORDINATION SUBTYPE ####################
152 # Distinguishes positive and negative conjunctions.
153 # We use the feature of polarity to store it, but unlike Multext polarity, the values are p|z (instead of n|y).
154 $atoms->{sub_type} = $self->create_simple_atom
155 (
156 'intfeature' => 'polarity',
157 'simple_decode_map' =>
158 {
159 'z' => 'neg',
160 'p' => 'pos'
161 },
162 'encode_default' => '-'
163 );
164 # MODIFICATION TYPE ####################
165 # This feature applies to Romanian determiners.
166 # prenominal modifier: acest băiat (this boy)
167 # postnominal modifier: băiatul acesta (this boy)
168 $atoms->{modtype} = $self->create_simple_atom
169 (
170 'intfeature' => 'position',
171 'simple_decode_map' =>
172 {
173 'e' => 'prenom',
174 'o' => 'postnom'
175 },
176 'encode_default' => '-'
177 );
178 # PRONOUN FORM ####################
179 # Weak pronouns can be adjoined to the adjacent words both proclitically or enclitically. The junction is always marked by a hyphen, sometimes there are elisions.
180 # Even if they are not adjoined, they are tagged as weak.
181 # Weak: ne, mă, vă
182 # Strong: noi, mine, eu, voi
183 $atoms->{pronform} = $self->create_simple_atom
184 (
185 'intfeature' => 'strength',
186 'simple_decode_map' =>
187 {
188 's' => 'strong',
189 'w' => 'weak'
190 },
191 'encode_default' => '-'
192 );
193 # IS PRONOUN CLITIC? ####################
194 # clitic = yes for short forms of pronouns that behave like clitics (they are attached to verbs)
195 # clitic = - independent forms of the pronouns; these can be short (weak) or long (strong)
196 # The examples below are weak (-,w); only one pronoun had also the strong form in the corpus (mă vs. mine).
197 # PerGenNumCase: 1-sa 1-sd 2-sd 3msa 3fsa 1-pa 2-pa 3mpa 3fpa 3a 3d
198 # Examples (yes): m-, -mi, ți-, -l, -o, ne-, v-, -i, le- s-, -și
199 # Examples (-,w): mă, mi, îți, îl, o, ne, vă, îi, le, se, își
200 # Examples (-,s): mine
201 $atoms->{clitic} = $self->create_atom
202 (
203 'surfeature' => 'clitic',
204 'decode_map' =>
205 {
206 'y' => ['variant' => 'short']
207 },
208 'encode_map' =>
209 {
210 'variant' => { 'short' => 'y',
211 '@' => '-' }
212 }
213 );
214 return $atoms;
215 }
216  
217  
218  
219 #------------------------------------------------------------------------------
220 # Creates a map that tells for each surface part of speech which features are
221 # relevant and in what order they appear.
222 #------------------------------------------------------------------------------
223 sub _create_feature_map
224 {
225 my $self = shift;
226 my %features =
227 (
228 'N' => ['pos', 'nountype', 'gender', 'number', 'case', 'definite', 'clitic'],
229 'V' => ['pos', 'verbtype', 'verbform', 'tense', 'person', 'number', 'gender', undef, undef, undef, 'clitic'],
230 'A' => ['pos', 'adjtype', 'degree', 'gender', 'number', 'case', 'definite', 'clitic'],
231 'P' => ['pos', 'prontype', 'person', 'gender', 'number', 'case', 'possnumber', undef, 'clitic', undef, undef, undef, undef, undef, 'pronform'],
232 'D' => ['pos', 'prontype', 'person', 'gender', 'number', 'case', 'possnumber', 'clitic', 'pronform', 'modtype'],
233 'T' => ['pos', 'prontype', 'gender', 'number', 'case', 'clitic'],
234 'R' => ['pos', 'adverb_type', 'degree', 'clitic'],
235 'S' => ['pos', 'adpostype', 'formation', 'case', 'clitic'],
236 'C' => ['pos', 'conjtype', 'formation', 'coord_type', 'sub_type', 'clitic'],
237 'M' => ['pos', 'numtype', 'gender', 'number', 'case', 'numform', 'definite', 'clitic'],
238 'Q' => ['pos', 'parttype', undef, 'clitic'],
239 'Y' => ['pos', 'syntactic_type', 'gender', 'number', 'case', 'definite'],
240 'X' => ['pos', 'restype']
241 );
242 return \%features;
243 }
244  
245  
246  
247 #------------------------------------------------------------------------------
248 # Returns reference to list of known tags.
249 # This list has been collected from the UD Romanian 1.2 corpus.
250 #
251 # The total of 313 tags included the following 18 special punctuation tags that
252 # are not Multext and we excluded them from the driver:
253 # BULLET
254 # COLON
255 # COMMA
256 # DASH
257 # DBLQ
258 # EXCL
259 # LPAR
260 # LSQR
261 # PERCENT
262 # PERIOD
263 # PLUS
264 # QUEST
265 # QUOT
266 # RPAR
267 # RSQR
268 # SCOLON
269 # SLASH
270 # UNDERSC
271 # Thus we have only 295 Multext-East tags in the corpus.
272 # Removed five entity tags (E.+) because they were not documented and there
273 # were few occurrences of them. Left just one general 'E'. Result: 290 tags.
274 # Removed 'M'. We always know the numeral type, don't we?
275 # Removed 'Mc'. We always know if a numeral is expressed in word or digits.
276 # Added 'Rg' (there was only 'Rgp' but the other adverb types could only be
277 # distinguished by the 'other' feature).
278 # Removed 'Sp'. We always know whether an adposition is simple or compound.
279 # Removed verbal tags without verbform.
280 # Removed Pp2-sr--------s (dumneata, polite); kept Pp2-sn--------s (tu, informal);
281 # the difference between the tags is the direct vs. nominative case and it is not
282 # important to distinguish. There is no explicit marking of politeness.
283 #------------------------------------------------------------------------------
284 sub list
285 {
286 my $self = shift;
287 my $list = <<end_of_list
288 Af
289 Afcms-n
290 Afp
291 Afp-p-n
292 Afp-poy
293 Afpf--n
294 Afpfp-n
295 Afpfpry
296 Afpfson
297 Afpfsoy
298 Afpfsrn
299 Afpfsry
300 Afpmp-n
301 Afpmpoy
302 Afpms-n
303 Afpmsoy
304 Afpmsry
305 Cccsp
306 Ccssp
307 Crssp
308 Cscsp
309 Csssp
310 Cssspy
311 Dd3-po---e
312 Dd3fpr
313 Dd3fpr---e
314 Dd3fso---e
315 Dd3fsr---e
316 Dd3fsr---o
317 Dd3mpo
318 Dd3mso---e
319 Dd3msr---e
320 Dh3fs
321 Dh3ms
322 Di3--r
323 Di3--r---e
324 Di3-po
325 Di3-po---e
326 Di3-sr
327 Di3-sr---e
328 Di3fp
329 Di3fpr
330 Di3fpr---e
331 Di3fsr
332 Di3fsr---e
333 Di3mp
334 Di3mpr
335 Di3mpr---e
336 Di3ms----e
337 Di3mso---e
338 Di3msr
339 Ds1fp-p
340 Ds1fp-s
341 Ds1fsos
342 Ds1fsrp
343 Ds1fsrs
344 Ds1mp-s
345 Ds1ms-s
346 Ds2fsrp
347 Ds3---p
348 Ds3---s
349 Ds3fp-s
350 Ds3fsos
351 Ds3fsrs
352 Ds3mp-s
353 Ds3ms-s
354 Dw3--r---e
355 Dz3fsr---e
356 Dz3msr---e
357 E
358 I
359 Mc-p-l
360 Mcfp-l
361 Mcfp-ln
362 Mcfprln
363 Mcfsrln
364 Mcmp-l
365 Mcms-ln
366 Mlfpr
367 Mlmpr
368 Mo-s-r
369 Mofpoly
370 Mofprly
371 Mofs-l
372 Mofsoly
373 Mofsrly
374 Momprly
375 Moms-l
376 Moms-ln
377 Momsoly
378 Momsrly
379 Nc
380 Nc---n
381 Ncf--n
382 Ncfp-n
383 Ncfpoy
384 Ncfpry
385 Ncfson
386 Ncfsony
387 Ncfsoy
388 Ncfsrn
389 Ncfsry
390 Ncfsvy
391 Ncm--n
392 Ncmp-n
393 Ncmpoy
394 Ncmpry
395 Ncmpvy
396 Ncms-n
397 Ncmsoy
398 Ncmsrn
399 Ncmsry
400 Ncmsvn
401 Ncmsvy
402 Np
403 Npfson
404 Npfsoy
405 Npfsrn
406 Npfsry
407 Npmpoy
408 Npmpry
409 Npms-n
410 Npmsry
411 Pd3-po
412 Pd3fpr
413 Pd3fso
414 Pd3fsr
415 Pd3mpr
416 Pd3mso
417 Pd3msr
418 Pi3--r
419 Pi3-po
420 Pi3-sr
421 Pi3fpr
422 Pi3fso
423 Pi3fsr
424 Pi3mpr
425 Pi3msr
426 Pp1-pa--------w
427 Pp1-pa--y-----w
428 Pp1-pd--------w
429 Pp1-pr--------s
430 Pp1-sa--------s
431 Pp1-sa--------w
432 Pp1-sa--y-----w
433 Pp1-sd--------w
434 Pp1-sd--y-----w
435 Pp1-sn--------s
436 Pp2-----------s
437 Pp2-pa--------w
438 Pp2-pa--y-----w
439 Pp2-pd--------w
440 Pp2-pr--------s
441 Pp2-sa--------s
442 Pp2-sa--------w
443 Pp2-sd--------w
444 Pp2-sd--y-----w
445 Pp2-sn--------s
446 Pp3-pd--------w
447 Pp3-sd--------w
448 Pp3-sd--y-----w
449 Pp3fpa--------w
450 Pp3fpa--y-----w
451 Pp3fpr--------s
452 Pp3fsa--------w
453 Pp3fsa--y-----w
454 Pp3fsr--------s
455 Pp3mpa--------w
456 Pp3mpa--y-----w
457 Pp3mpr--------s
458 Pp3msa--------w
459 Pp3msa--y-----w
460 Pp3mso--------s
461 Pp3msr--------s
462 Ps1fsrp
463 Ps1ms-s
464 Ps2fsrs
465 Ps3---s
466 Ps3fsrs
467 Pw3--r
468 Pw3-po
469 Pw3-so
470 Pw3fpr
471 Pw3fso
472 Pw3mso
473 Px3--a--------w
474 Px3--a--y-----w
475 Px3--d--------w
476 Px3--d--y-----w
477 Pz3-sr
478 Pz3msr
479 Qn
480 Qs
481 Qz
482 Qz-y
483 Rc
484 Rg
485 Rgp
486 Rp
487 Rw
488 Rz
489 Spca
490 Spcg
491 Spsa
492 Spsay
493 Spsd
494 Spsg
495 Td-po
496 Tdfpr
497 Tdfso
498 Tdfsr
499 Tdmpr
500 Tdmsr
501 Tf-so
502 Tffs-y
503 Tfms-y
504 Tfmsoy
505 Tfmsry
506 Ti-po
507 Tifso
508 Tifsr
509 Timso
510 Timsr
511 Tsfp
512 Tsfs
513 Tsmp
514 Tsms
515 Vag
516 Vaii3s
517 Vail3p
518 Vaip1p
519 Vaip1s
520 Vaip2s
521 Vaip3p
522 Vaip3s
523 Vanp
524 Vap--sm
525 Vasp3
526 Vmg
527 Vmg-------y
528 Vmii1
529 Vmii1p
530 Vmii1s
531 Vmii2p
532 Vmii2s
533 Vmii3p
534 Vmii3s
535 Vmil1
536 Vmil3p
537 Vmil3s
538 Vmip1p
539 Vmip1s
540 Vmip2p
541 Vmip2s
542 Vmip3
543 Vmip3p
544 Vmip3s
545 Vmip3s----y
546 Vmis1p
547 Vmis1s
548 Vmis3p
549 Vmis3s
550 Vmm-2p
551 Vmm-2s
552 Vmnp
553 Vmp--pf
554 Vmp--pm
555 Vmp--sf
556 Vmp--sm
557 Vmsp1p
558 Vmsp1s
559 Vmsp2p
560 Vmsp2s
561 Vmsp3
562 Vmsp3s
563 X
564 Y
565 Yn
566 Yr
567 end_of_list
568 ;
569 my @list = split(/\r?\n/, $list);
570 return \@list;
571 }
572  
573  
574  
575 1;
576  
577 __END__
578  
579 =pod
580  
581 =encoding UTF-8
582  
583 =head1 NAME
584  
585 Lingua::Interset::Tagset::RO::Multext - Driver for the Romanian tagset of the Multext-EAST v4 project.
586  
587 =head1 VERSION
588  
589 version 3.015
590  
591 =head1 SYNOPSIS
592  
593 use Lingua::Interset::Tagset::RO::Multext;
594 my $driver = Lingua::Interset::Tagset::RO::Multext->new();
595 my $fs = $driver->decode('Ncms-n');
596  
597 or
598  
599 use Lingua::Interset qw(decode);
600 my $fs = decode('ro::multext', 'Ncms-n');
601  
602 =head1 DESCRIPTION
603  
604 Interset driver for the Romanian tagset of the Multext-EAST v4 project.
605 See L<http://nl.ijs.si/ME/V4/msd/html/msd-ro.html> for a detailed description
606 of the tagset.
607  
608 =head1 SEE ALSO
609  
610 L<Lingua::Interset>,
611 L<Lingua::Interset::Tagset>,
612 L<Lingua::Interset::FeatureStructure>
613  
614 =head1 AUTHOR
615  
616 Dan Zeman <zeman@ufal.mff.cuni.cz>
617  
618 =head1 COPYRIGHT AND LICENSE
619  
620 This software is copyright (c) 2019 by Univerzita Karlova (Charles University).
621  
622 This is free software; you can redistribute it and/or modify it under
623 the same terms as the Perl 5 programming language system itself.
624  
625 =cut