Interset/Tagset/RO/Rdt.pm untested

filter: Statementstmt 0.0% 0 / 79 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 89 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 tagset of the Romanian Dependency Treebank (RDT).
2 # Copyright © 2015, 2017 Dan Zeman <zeman@ufal.mff.cuni.cz>
3 # Copyright © 2011 Martin Popel <popel@ufal.mff.cuni.cz>
4 # Brief tagset documentation in $TMT_ROOT/share/data/resources/treebanks/ro/2008_calacean.pdf
5 # Useful resource http://dexonline.ro
6  
7 # ă â î ș ț (ş ţ)
8  
9 # NOTE:
10 # The original RDT annotation is *not consistent*:
11 # Four of the twenty POS tags and one dependency type appear only in the first 6% of the material,
12 # reducing significantly the POS tagset for the rest of the material. For instance, verbs and
13 # adjectives in participle form are annotated as such only in the first part of the material.
14 # On the other hand, the definite article POS tag is present only in the last 90% of the material.
15  
16 package Lingua::Interset::Tagset::RO::Rdt;
17 use strict;
18 use warnings;
19 our $VERSION = '3.015';
20  
21 use utf8;
22 use open ':utf8';
23 use namespace::autoclean;
24 use Moose;
25 extends 'Lingua::Interset::Atom';
26  
27  
28  
29 #------------------------------------------------------------------------------
30 # Returns the tagset id that should be set as the value of the 'tagset' feature
31 # during decoding. Every derived class must (re)define this method! The result
32 # should correspond to the last two parts in package name, lowercased.
33 # Specifically, it should be the ISO 639-2 language code, followed by '::' and
34 # a language-specific tagset id. Example: 'cs::multext'.
35 #------------------------------------------------------------------------------
36 sub get_tagset_id
37 {
38 return 'ro::rdt';
39 }
40  
41  
42  
43 #------------------------------------------------------------------------------
44 # This block will be called before object construction. It will build the
45 # decoding and encoding maps for this particular tagset.
46 # Then it will pass all the attributes to the constructor.
47 #------------------------------------------------------------------------------
48 around BUILDARGS => sub
49 {
50 my $orig = shift;
51 my $class = shift;
52 # Call the default BUILDARGS in Moose::Object. It will take care of distinguishing between a hash reference and a plain hash.
53 my $attr = $class->$orig(@_);
54 # Construct decode_map in the form expected by Atom.
55 my %dm =
56 (
57 'adjectiv' => ['pos' => 'adj'],
58 'adverb' => ['pos' => 'adv'],
59 # cel (demonstrative article, used only before adjectives "cel bun")
60 'art. dem.' => ['pos' => 'adj', 'prontype' => 'dem', 'definite' => 'def'],
61 # lui (definite article, used only in possessive constructions with male gender)
62 'art. hot.' => ['pos' => 'adj', 'prontype' => 'art', 'definite' => 'def', 'poss' => 'yes', 'gender' => 'masc'],
63 # al, a, ai, ale (genitival/possessive article)
64 'art. poses.' => ['pos' => 'adj', 'prontype' => 'art', 'poss' => 'yes'],
65 # o, un, niște
66 'art. nehot.' => ['pos' => 'adj', 'prontype' => 'art', 'definite' => 'ind'],
67 'conj. aux.' => ['pos' => 'conj', 'conjtype' => 'sub'],
68 'conj. coord.' => ['pos' => 'conj', 'conjtype' => 'coor'],
69 'numeral' => ['pos' => 'num'],
70 'prepozitie' => ['pos' => 'adp', 'adpostype' => 'prep'],
71 # se, ne, mă
72 'pron. reflex.' => ['pos' => 'noun', 'prontype' => 'prs', 'reflex' => 'yes'],
73 # care, ce, le, noi, nimic, totul
74 'pronume' => ['pos' => 'noun|adj', 'prontype' => 'prn'],
75 'substantiv' => ['pos' => 'noun'],
76 'verb' => ['pos' => 'verb', 'verbform' => 'fin'],
77 # a, au, fost, fi, vor, fie, este, sunt
78 'verb aux.' => ['pos' => 'verb', 'verbtype' => 'aux'],
79 # fi (a fi = infinitive to be), cântând (converb/transgressive, note that in Romainan it is called "gerunziu", but it is not a gerund like "doing" in English)
80 'verb nepred.' => ['pos' => 'verb', 'verbform' => 'inf|conv'],
81 # Due to inconsistent annotation, the following tags appear only in the test set :-(
82 'verb la participiu' => ['pos' => 'verb', 'verbform' => 'part'],
83 # iluminat (tagged as 'verb nepred.' in the rest of RDT)
84 'verb la infinitiv' => ['pos' => 'verb', 'verbform' => 'inf'],
85 'adj. particip.' => ['pos' => 'adj', 'verbform' => 'part'],
86 # cel, aceasta
87 'pron. dem.' => ['pos' => 'adj', 'prontype' => 'dem']
88 );
89 # Construct encode_map in the form expected by Atom.
90 my %em =
91 (
92 'pos' => { 'noun' => { 'prontype' => { '' => 'substantiv',
93 '@' => { 'reflex' => { 'yes' => 'pron. reflex.',
94 '@' => 'pronume' }}}},
95 'adj' => { 'prontype' => { '' => { 'verbform' => { 'part' => 'adj. particip.',
96 '@' => 'adjectiv' }},
97 'dem' => { 'definite' => { 'def' => 'art. dem.',
98 '@' => 'pron. dem.' }},
99 'art' => { 'poss' => { 'yes' => { 'definite' => { 'def' => 'art. hot.',
100 '@' => 'art. poses.' }},
101 '@' => 'art. nehot.' }},
102 '@' => 'pronume' }},
103 'num' => 'numeral',
104 'verb' => { 'verbtype' => { 'aux' => 'verb aux.',
105 '@' => { 'verbform' => { 'inf' => 'verb la infinitiv',
106 'fin' => 'verb',
107 'inf|conv' => 'verb nepred.',
108 'trans' => 'verb nepred.',
109 'ger' => 'verb nepred.',
110 'part' => 'verb la participiu' }}}},
111 'adv' => 'adverb',
112 'adp' => 'prepozitie',
113 'conj' => { 'conjtype' => { 'sub' => 'conj. aux.',
114 '@' => 'conj. coord.' }}}
115 );
116 # Now add the references to the attribute hash.
117 $attr->{surfeature} = 'pos';
118 $attr->{decode_map} = \%dm;
119 $attr->{encode_map} = \%em;
120 $attr->{tagset} = 'ro::rdt';
121 return $attr;
122 };
123  
124  
125  
126 #------------------------------------------------------------------------------
127 # Decodes a physical tag (string) and returns the corresponding feature
128 # structure. In addition to Atom, we just need to identify the tagset of
129 # origin.
130 #------------------------------------------------------------------------------
131 sub decode
132 {
133 my $self = shift;
134 my $tag = shift;
135 my $fs = $self->SUPER::decode($tag);
136 $fs->set_tagset('ro::rdt');
137 return $fs;
138 }
139  
140  
141  
142 1;
143  
144 __END__
145  
146 =pod
147  
148 =encoding UTF-8
149  
150 =head1 NAME
151  
152 Lingua::Interset::Tagset::RO::Rdt - Driver for the tagset of the Romanian Dependency Treebank (RDT).
153  
154 =head1 VERSION
155  
156 version 3.015
157  
158 =head1 SYNOPSIS
159  
160 use Lingua::Interset::Tagset::RO::Rdt;
161 my $driver = Lingua::Interset::Tagset::RO::Rdt->new();
162 my $fs = $driver->decode('substantiv');
163  
164 or
165  
166 use Lingua::Interset qw(decode);
167 my $fs = decode('ro::rdt', 'substantiv');
168  
169 =head1 DESCRIPTION
170  
171 Interset driver for the tagset of the Romanian Dependency Treebank (RDT).
172  
173 The original RDT annotation is I<not consistent:>
174 Four of the twenty POS tags and one dependency type appear only in the first 6% of the material,
175 reducing significantly the POS tagset for the rest of the material. For instance, verbs and
176 adjectives in participle form are annotated as such only in the first part of the material.
177 On the other hand, the definite article POS tag is present only in the last 90% of the material.
178  
179 =head1 AUTHOR
180  
181 Dan Zeman
182 Martin Popel
183  
184 =head1 SEE ALSO
185  
186 L<Lingua::Interset>,
187 L<Lingua::Interset::Tagset>,
188 L<Lingua::Interset::FeatureStructure>
189  
190 =head1 AUTHOR
191  
192 Dan Zeman <zeman@ufal.mff.cuni.cz>
193  
194 =head1 COPYRIGHT AND LICENSE
195  
196 This software is copyright (c) 2019 by Univerzita Karlova (Charles University).
197  
198 This is free software; you can redistribute it and/or modify it under
199 the same terms as the Perl 5 programming language system itself.
200  
201 =cut