| 1 | # ABSTRACT: Driver for the Portuguese tagset of the CINTIL corpus (Corpus Internacional do Portugues). | ||
| 2 | # http://cintil.ul.pt/ | ||
| 3 | # http://cintil.ul.pt/cintilwhatsin.html#guidelines | ||
| 4 | # Copyright © 2014 Martin Popel <popel@ufal.mff.cuni.cz> | ||
| 5 | # Copyright © 2014, 2017 Dan Zeman <zeman@ufal.mff.cuni.cz> | ||
| 6 | |||
| 7 | package Lingua::Interset::Tagset::PT::Cintil; | ||
| 8 | use strict; | ||
| 9 | use warnings; | ||
| 10 | our $VERSION = '3.014'; | ||
| 11 | |||
| 12 | use utf8; | ||
| 13 | use open ':utf8'; | ||
| 14 | use namespace::autoclean; | ||
| 15 | use Moose; | ||
| 16 | extends 'Lingua::Interset::Tagset'; | ||
| 17 | |||
| 18 | |||
| 19 | |||
| 20 | has 'atoms' => ( isa => 'HashRef', is => 'ro', builder => '_create_atoms', lazy => 1 ); | ||
| 21 | |||
| 22 | |||
| 23 | |||
| 24 | #------------------------------------------------------------------------------ | ||
| 25 | # Returns the tagset id that should be set as the value of the 'tagset' feature | ||
| 26 | # during decoding. Every derived class must (re)define this method! The result | ||
| 27 | # should correspond to the last two parts in package name, lowercased. | ||
| 28 | # Specifically, it should be the ISO 639-2 language code, followed by '::' and | ||
| 29 | # a language-specific tagset id. Example: 'cs::multext'. | ||
| 30 | #------------------------------------------------------------------------------ | ||
| 31 | sub get_tagset_id | ||
| 32 | { | ||
| 33 | return 'pt::cintil'; | ||
| 34 | } | ||
| 35 | |||
| 36 | |||
| 37 | |||
| 38 | #------------------------------------------------------------------------------ | ||
| 39 | # Creates atomic drivers for surface features. | ||
| 40 | # See http://cintil.ul.pt/cintilwhatsin.html#guidelines | ||
| 41 | #------------------------------------------------------------------------------ | ||
| 42 | sub _create_atoms | ||
| 43 | { | ||
| 44 | my $self = shift; | ||
| 45 | my %atoms; | ||
| 46 | # PART OF SPEECH #################### | ||
| 47 | $atoms{pos} = $self->create_atom | ||
| 48 | ( | ||
| 49 | 'tagset' => 'pt::cintil', | ||
| 50 | 'surfeature' => 'pos', | ||
| 51 | 'decode_map' => | ||
| 52 | { | ||
| 53 | # Adjective (bom, brilhante, eficaz) | ||
| 54 | 'ADJ' => ['pos' => 'adj'], | ||
| 55 | # Adverb (hoje, já, sim, felizmente) | ||
| 56 | 'ADV' => ['pos' => 'adv'], | ||
| 57 | # Cardinal number (zero, dez, cem, mil) | ||
| 58 | 'CARD' => ['pos' => 'num', 'numtype' => 'card'], | ||
| 59 | # Conjunction (e, ou, que, como) | ||
| 60 | 'CJ' => ['pos' => 'conj'], | ||
| 61 | # Clitic (-se, o, -lhe) | ||
| 62 | ###!!! Should Interset have a new feature for encliticized personal pronouns? They are not necessarily reflexive. | ||
| 63 | 'CL' => ['pos' => 'noun', 'prontype' => 'prs', 'variant' => 'short', 'other' => {'pos' => 'clitic'}], | ||
| 64 | # Common noun (computador, cidade, ideia) | ||
| 65 | 'CN' => ['pos' => 'noun', 'nountype' => 'com'], | ||
| 66 | # Definite article (o, a, os, as) | ||
| 67 | 'DA' => ['pos' => 'adj', 'prontype' => 'art', 'definite' => 'def'], | ||
| 68 | # Demonstrative pronoun or determiner (este, esses, aquele) | ||
| 69 | 'DEM' => ['pos' => 'noun|adj', 'prontype' => 'dem'], | ||
| 70 | # Denominator of a fraction (meio, terço, décimo, %) | ||
| 71 | 'DFR' => ['pos' => 'num', 'numtype' => 'frac'], | ||
| 72 | # Roman numeral (VI, LX, MMIII, MCMXCIX) | ||
| 73 | 'DGTR' => ['pos' => 'num', 'numform' => 'roman'], | ||
| 74 | # Number expressed in digits (0, 1, 42, 12345, 67890) | ||
| 75 | 'DGT' => ['pos' => 'num', 'numform' => 'digit'], | ||
| 76 | # Discourse marker "olá" | ||
| 77 | 'DM' => ['pos' => 'int', 'other' => {'pos' => 'discourse'}], | ||
| 78 | # Electronic address (http://www.di.fc.ul.pt) | ||
| 79 | 'EADR' => ['pos' => 'noun', 'other' => {'pos' => 'url'}], | ||
| 80 | # End of enumeration (etc.) | ||
| 81 | 'EOE' => ['pos' => 'part', 'abbr' => 'yes'], | ||
| 82 | # Exclamation (que, quanto) | ||
| 83 | 'EXC' => ['pos' => 'int'], | ||
| 84 | # Gerund (sendo, afirmando, vivendo) | ||
| 85 | 'GER' => ['pos' => 'verb', 'verbform' => 'part', 'tense' => 'pres', 'aspect' => 'prog'], | ||
| 86 | # Gerund of an auxiliary verb in compound tenses (tendo, havendo) | ||
| 87 | 'GERAUX' => ['pos' => 'verb', 'verbtype' => 'aux', 'verbform' => 'part', 'tense' => 'pres', 'aspect' => 'prog'], | ||
| 88 | # Indefinite article (uns, umas) | ||
| 89 | 'IA' => ['pos' => 'adj', 'prontype' => 'art', 'definite' => 'ind'], | ||
| 90 | # Indefinite pronoun or determiner (tudo, alguém, ninguém) | ||
| 91 | 'IND' => ['pos' => 'noun|adj', 'prontype' => 'ind|neg|tot'], | ||
| 92 | # Infinitive (ser, afirmar, viver) | ||
| 93 | 'INF' => ['pos' => 'verb', 'verbform' => 'inf'], | ||
| 94 | # Infinitive of an auxiliary verb in compound tenses (ter, haver) | ||
| 95 | 'INFAUX' => ['pos' => 'verb', 'verbtype' => 'aux', 'verbform' => 'inf'], | ||
| 96 | # Interrogative pronoun, determiner or adverb (quem, como, quando) | ||
| 97 | 'INT' => ['pos' => 'noun|adj|adv', 'prontype' => 'int'], | ||
| 98 | # Interjection (bolas, caramba) | ||
| 99 | 'ITJ' => ['pos' => 'int'], | ||
| 100 | # Letter (a, b, c) | ||
| 101 | 'LTR' => ['pos' => 'sym', 'other' => {'pos' => 'letter'}], | ||
| 102 | # Magnitude class (unidade, dezena, dúzia, resma) | ||
| 103 | # unidade = unit; dezena = dozen; dúzia = dozen; resma = ream = hromada | ||
| 104 | 'MGT' => ['pos' => 'noun', 'numtype' => 'card', 'numform' => 'word', 'other' => {'pos' => 'magnitude'}], | ||
| 105 | # Month (Janeiro, Dezembro) | ||
| 106 | 'MTH' => ['pos' => 'noun', 'other' => {'pos' => 'month'}], | ||
| 107 | # Noun phrase (idem) | ||
| 108 | 'NP' => ['pos' => 'noun', 'abbr' => 'yes'], | ||
| 109 | # Ordinal numeral (primeiro, centésimo, penúltimo) | ||
| 110 | 'ORD' => ['pos' => 'adj', 'numtype' => 'ord'], | ||
| 111 | # Part of address (Rua, av., rot.) | ||
| 112 | 'PADR' => ['pos' => 'noun', 'other' => {'pos' => 'address'}], | ||
| 113 | # Part of name (Lisboa, António, Jo&atil;o) | ||
| 114 | 'PNM' => ['pos' => 'noun', 'nountype' => 'prop'], | ||
| 115 | # Punctuation (., ?, (, )) | ||
| 116 | 'PNT' => ['pos' => 'punc'], | ||
| 117 | # Possessive pronoun or determiner (meu, teu, seu) | ||
| 118 | 'POSS' => ['pos' => 'adj', 'prontype' => 'prs', 'poss' => 'yes'], | ||
| 119 | # Past participle not in compound tenses (sido, afirmados, vivida) | ||
| 120 | 'PPA' => ['pos' => 'adj', 'verbform' => 'part', 'tense' => 'past'], | ||
| 121 | ###!!! According to Martin/documentation?, PP should mean "prepositional phrase" (algures = somewhere). | ||
| 122 | ###!!! However, there are only a few occurrences, always with the ellipsis punctuation ("..."). | ||
| 123 | 'PP' => ['pos' => 'punc'], | ||
| 124 | # Past participle in compound tenses (sido, afirmado, vivido) | ||
| 125 | 'PPT' => ['pos' => 'verb', 'verbform' => 'part', 'tense' => 'past'], | ||
| 126 | # Preposition (de, para, em redor de) | ||
| 127 | 'PREP' => ['pos' => 'adp', 'adpostype' => 'prep'], | ||
| 128 | # Personal pronoun (eu, tu, ele) | ||
| 129 | 'PRS' => ['pos' => 'noun', 'prontype' => 'prs'], | ||
| 130 | # Quantifier (todos, muitos, nenhum) | ||
| 131 | 'QNT' => ['pos' => 'adj', 'prontype' => 'ind|tot|neg', 'numtype' => 'card'], | ||
| 132 | # Relative pronoun, determiner or adverb (que, cujo, tal que) | ||
| 133 | 'REL' => ['pos' => 'noun|adj|adv', 'prontype' => 'rel'], | ||
| 134 | # Social title (Presidente, drª., prof.) | ||
| 135 | 'STT' => ['pos' => 'noun', 'other' => {'pos' => 'title'}], | ||
| 136 | # Symbol (@, #, &) | ||
| 137 | 'SYB' => ['pos' => 'sym'], | ||
| 138 | # Optional termination ((s), (as)) | ||
| 139 | 'TERMN' => [], | ||
| 140 | # "um" or "uma" (they could be either indefinite articles or cardinal numerals meaning "one") | ||
| 141 | 'UM' => ['pos' => 'adj', 'prontype' => 'art', 'definite' => 'ind', 'numtype' => 'card', 'numform' => 'word', 'numvalue' => '1'], | ||
| 142 | # Abbreviated measurement unit (Kg, h, seg, Hz, Mbytes) | ||
| 143 | 'UNIT' => ['pos' => 'noun', 'abbr' => 'yes'], | ||
| 144 | # Finite form of an auxiliary verb in compound tenses (temos, haveriam) | ||
| 145 | 'VAUX' => ['pos' => 'verb', 'verbtype' => 'aux', 'verbform' => 'fin'], | ||
| 146 | # Verb (other than PPA, PPT, INF or GER) (falou, falaria) | ||
| 147 | 'V' => ['pos' => 'verb', 'verbform' => 'fin'], | ||
| 148 | # Day of week (segunda, terça-feira, sábado) | ||
| 149 | 'WD' => ['pos' => 'noun', 'other' => {'pos' => 'weekday'}] | ||
| 150 | # LADVn ... multi-word adverb (de facto, em suma, um pouco) | ||
| 151 | # LCJn .... multi-word conjunction (assim como, já que) | ||
| 152 | # LDEMn ... multi-word demonstrative (o mesmo) | ||
| 153 | # LDFRn ... multi-word denominator of fraction (por cento) | ||
| 154 | # LDMn .... multi-word discourse marker (pois n&atil;o, até logo) | ||
| 155 | # LITJn ... multi-word interjection (meu Deus) | ||
| 156 | # LPRSn ... multi-word personal (a gente, si mesmo, V. Exa.) | ||
| 157 | # LPREPn .. multi-word preposition (através de, a partir de) | ||
| 158 | # LQDn .... multi-word quantifier (uns quantos) | ||
| 159 | # LRELn ... multi-word relative (tal como) | ||
| 160 | }, | ||
| 161 | 'encode_map' => | ||
| 162 | |||
| 163 | { 'prontype' => { 'prs' => { 'poss' => { 'yes' => 'POSS', | ||
| 164 | '@' => { 'variant' => { 'short' => 'CL', | ||
| 165 | '@' => 'PRS' }}}}, | ||
| 166 | 'art' => { 'definite' => { 'def' => 'DA', | ||
| 167 | '@' => { 'numtype' => { 'card' => 'UM', | ||
| 168 | '@' => 'IA' }}}}, | ||
| 169 | 'dem' => 'DEM', | ||
| 170 | 'ind' => { 'numtype' => { '' => 'IND', | ||
| 171 | '@' => 'QNT' }}, | ||
| 172 | 'neg' => { 'numtype' => { '' => 'IND', | ||
| 173 | '@' => 'QNT' }}, | ||
| 174 | 'tot' => { 'numtype' => { '' => 'IND', | ||
| 175 | '@' => 'QNT' }}, | ||
| 176 | 'int' => 'INT', | ||
| 177 | 'rel' => 'REL', | ||
| 178 | '@' => { 'pos' => { 'noun' => { 'other/pos' => { 'month' => 'MTH', | ||
| 179 | 'weekday' => 'WD', | ||
| 180 | 'magnitude' => 'MGT', | ||
| 181 | 'address' => 'PADR', | ||
| 182 | 'title' => 'STT', | ||
| 183 | '@' => 'CN' }}, | ||
| 184 | 'adj' => { 'verbform' => { 'part' => 'PPA', | ||
| 185 | '@' => { 'numtype' => { 'ord' => 'ORD', | ||
| 186 | '@' => 'ADJ' }}}}, | ||
| 187 | 'num' => { 'numtype' => { 'frac' => 'DFR', | ||
| 188 | '@' => { 'numform' => { 'digit' => 'DGT', | ||
| 189 | 'roman' => 'DGTR', | ||
| 190 | '@' => 'CARD' }}}}, | ||
| 191 | # We decode INF and INFAUX but we never encode it. Instead, we encode "V V inf". | ||
| 192 | # The input data are not consistent but the "V" tag is more frequent with infinitives. | ||
| 193 | # Similar with GER and GERAUX. | ||
| 194 | 'verb' => { 'verbtype' => { 'aux' => { 'verbform' => { '@' => 'VAUX' }}, | ||
| 195 | '@' => { 'verbform' => { '@' => 'V' }}}}, | ||
| 196 | 'adv' => 'ADV', | ||
| 197 | 'adp' => 'PREP', | ||
| 198 | 'conj' => 'CJ', | ||
| 199 | 'int' => { 'other/pos' => { 'discourse' => 'DM', | ||
| 200 | '@' => 'ITJ' }}, | ||
| 201 | 'punc' => 'PNT', | ||
| 202 | 'sym' => { 'other/pos' => { 'letter' => 'LTR', | ||
| 203 | '@' => 'SYB' }}}}}} | ||
| 204 | ); | ||
| 205 | # FEATURES #################### | ||
| 206 | $atoms{feature} = $self->create_atom | ||
| 207 | ( | ||
| 208 | 'surfeature' => 'feature', | ||
| 209 | 'decode_map' => | ||
| 210 | { | ||
| 211 | 'm' => ['gender' => 'masc'], | ||
| 212 | 'f' => ['gender' => 'fem'], | ||
| 213 | 'g' => [], # undetermined gender | ||
| 214 | 's' => ['number' => 'sing'], | ||
| 215 | 'p' => ['number' => 'plur'], | ||
| 216 | 'n' => [], # undetermined number | ||
| 217 | # diminutive | ||
| 218 | 'dim' => ['other' => {'diminutive' => 'yes'}], | ||
| 219 | 'comp' => ['degree' => 'cmp'], | ||
| 220 | 'sup' => ['degree' => 'sup'], | ||
| 221 | '1' => ['person' => '1'], | ||
| 222 | '2' => ['person' => '2'], | ||
| 223 | '3' => ['person' => '3'], | ||
| 224 | # presente do indicativo | ||
| 225 | 'pi' => ['mood' => 'ind', 'tense' => 'pres'], | ||
| 226 | # préterito perfeito do indicativo | ||
| 227 | 'ppi' => ['mood' => 'ind', 'tense' => 'past', 'aspect' => 'perf'], | ||
| 228 | # préterito imperfeito do indicativo | ||
| 229 | 'ii' => ['mood' => 'ind', 'tense' => 'past', 'aspect' => 'imp'], | ||
| 230 | # préterito mais que perfeito do indicativo | ||
| 231 | 'mpi' => ['mood' => 'ind', 'tense' => 'pqp', 'aspect' => 'perf'], | ||
| 232 | # futuro do indicativo | ||
| 233 | 'fi' => ['mood' => 'ind', 'tense' => 'fut'], | ||
| 234 | # condicional | ||
| 235 | 'c' => ['mood' => 'cnd'], | ||
| 236 | # presente do conjuntivo | ||
| 237 | 'pc' => ['mood' => 'sub', 'tense' => 'pres'], | ||
| 238 | # préterito imperfeito do conjuntivo | ||
| 239 | 'ic' => ['mood' => 'sub', 'tense' => 'past', 'aspect' => 'imp'], | ||
| 240 | # futuro do conjuntivo | ||
| 241 | 'fc' => ['mood' => 'sub', 'tense' => 'fut'], | ||
| 242 | # imperativo | ||
| 243 | 'imp' => ['mood' => 'imp'], | ||
| 244 | # There are two ways of tagging infinitives: either at the part-of-speech level or in the features: | ||
| 245 | # V V inf-nInf | ||
| 246 | # V V inf-3s | ||
| 247 | # V V inf-3p | ||
| 248 | # INF INF ninf | ||
| 249 | # INF INF ifl-1p | ||
| 250 | 'inf' => ['verbform' => 'inf'], | ||
| 251 | 'ifl' => [], # inflected infinitive; person+number feature follows | ||
| 252 | 'ninf' => [], # uninflected infinitive | ||
| 253 | 'nInf' => [], # uninflected infinitive | ||
| 254 | # Similarly, there are multiple ways of tagging gerunds / present participles: | ||
| 255 | # V V ger ... 21 | ||
| 256 | # V V GER ... 88 | ||
| 257 | # GER GER <lemma> ... 12 | ||
| 258 | # GERAUX GERAUX ... 0 (but documented) | ||
| 259 | 'ger' => ['verbform' => 'ger'], | ||
| 260 | # Similarly, there are multiple ways of tagging past participles (used in compound tenses, not used adjectively): | ||
| 261 | # PPT PPT <lemma> ... 27 | ||
| 262 | # V V PPT-ms ... 184 | ||
| 263 | 'PPT' => ['verbform' => 'part', 'tense' => 'past', 'aspect' => 'perf'], | ||
| 264 | # Part of name (Lisboa, António, Jo&atil;o) | ||
| 265 | # The documentation says that this is a part-of-speech tag. However, in the data it appears as a feature of the "CN" tag. | ||
| 266 | 'PNM' => ['nountype' => 'prop'], | ||
| 267 | # other undocumented features that occur in the data | ||
| 268 | '?' => [], # unknown gender or number | ||
| 269 | '??' => [], # unknown gender and number | ||
| 270 | }, | ||
| 271 | 'encode_map' => | ||
| 272 | |||
| 273 | { 'pos' => '' } | ||
| 274 | ); | ||
| 275 | # GENDER+NUMBER #################### | ||
| 276 | $atoms{gn} = $self->create_atom | ||
| 277 | ( | ||
| 278 | 'surfeature' => 'gn', | ||
| 279 | 'decode_map' => | ||
| 280 | { | ||
| 281 | 'ms' => ['gender' => 'masc', 'number' => 'sing'], | ||
| 282 | 'mp' => ['gender' => 'masc', 'number' => 'plur'], | ||
| 283 | 'mn' => ['gender' => 'masc'], | ||
| 284 | 'fs' => ['gender' => 'fem', 'number' => 'sing'], | ||
| 285 | 'fp' => ['gender' => 'fem', 'number' => 'plur'], | ||
| 286 | 'fn' => ['gender' => 'fem'], | ||
| 287 | 'gs' => ['number' => 'sing'], | ||
| 288 | 'gp' => ['number' => 'plur'], | ||
| 289 | 'gn' => [] | ||
| 290 | }, | ||
| 291 | 'encode_map' => | ||
| 292 | |||
| 293 | { 'gender' => { 'masc' => { 'number' => { 'sing' => 'ms', | ||
| 294 | 'plur' => 'mp', | ||
| 295 | '@' => 'mn' }}, | ||
| 296 | 'fem' => { 'number' => { 'sing' => 'fs', | ||
| 297 | 'plur' => 'fp', | ||
| 298 | '@' => 'fn' }}, | ||
| 299 | '@' => { 'number' => { 'sing' => 'gs', | ||
| 300 | 'plur' => 'gp', | ||
| 301 | '@' => 'gn' }}}} | ||
| 302 | ); | ||
| 303 | # PERSON+NUMBER #################### | ||
| 304 | $atoms{pn} = $self->create_atom | ||
| 305 | ( | ||
| 306 | 'surfeature' => 'pn', | ||
| 307 | 'decode_map' => | ||
| 308 | { | ||
| 309 | '1s' => ['person' => '1', 'number' => 'sing'], | ||
| 310 | '2s' => ['person' => '2', 'number' => 'sing'], | ||
| 311 | '3s' => ['person' => '3', 'number' => 'sing'], | ||
| 312 | '1p' => ['person' => '1', 'number' => 'plur'], | ||
| 313 | '2p' => ['person' => '2', 'number' => 'plur'], | ||
| 314 | '3p' => ['person' => '3', 'number' => 'plur'] | ||
| 315 | }, | ||
| 316 | 'encode_map' => | ||
| 317 | |||
| 318 | { 'number' => { 'sing' => { 'person' => { '1' => '1s', | ||
| 319 | '2' => '2s', | ||
| 320 | '3' => '3s' }}, | ||
| 321 | 'plur' => { 'person' => { '1' => '1p', | ||
| 322 | '2' => '2p', | ||
| 323 | '3' => '3p' }}}} | ||
| 324 | ); | ||
| 325 | # TENSE+MOOD #################### | ||
| 326 | $atoms{tm} = $self->create_atom | ||
| 327 | ( | ||
| 328 | 'surfeature' => 'tm', | ||
| 329 | 'decode_map' => | ||
| 330 | { | ||
| 331 | # presente do indicativo | ||
| 332 | 'pi' => ['mood' => 'ind', 'tense' => 'pres'], | ||
| 333 | # préterito perfeito do indicativo | ||
| 334 | 'ppi' => ['mood' => 'ind', 'tense' => 'past', 'aspect' => 'perf'], | ||
| 335 | # préterito imperfeito do indicativo | ||
| 336 | 'ii' => ['mood' => 'ind', 'tense' => 'past', 'aspect' => 'imp'], | ||
| 337 | # préterito mais que perfeito do indicativo | ||
| 338 | 'mpi' => ['mood' => 'ind', 'tense' => 'pqp', 'aspect' => 'perf'], | ||
| 339 | # futuro do indicativo | ||
| 340 | 'fi' => ['mood' => 'ind', 'tense' => 'fut'], | ||
| 341 | # condicional | ||
| 342 | 'c' => ['mood' => 'cnd'], | ||
| 343 | # presente do conjuntivo | ||
| 344 | 'pc' => ['mood' => 'sub', 'tense' => 'pres'], | ||
| 345 | # préterito imperfeito do conjuntivo | ||
| 346 | 'ic' => ['mood' => 'sub', 'tense' => 'past', 'aspect' => 'imp'], | ||
| 347 | # futuro do conjuntivo | ||
| 348 | 'fc' => ['mood' => 'sub', 'tense' => 'fut'], | ||
| 349 | # imperativo | ||
| 350 | 'imp' => ['mood' => 'imp'], | ||
| 351 | # There are two ways of tagging infinitives: either at the part-of-speech level or in the features: | ||
| 352 | # V V inf-nInf | ||
| 353 | # V V inf-3s | ||
| 354 | # V V inf-3p | ||
| 355 | # INF INF ninf | ||
| 356 | # INF INF ifl-1p | ||
| 357 | 'inf' => ['verbform' => 'inf'], | ||
| 358 | # Similarly, there are multiple ways of tagging gerunds / present participles: | ||
| 359 | # V V ger ... 21 | ||
| 360 | # V V GER ... 88 | ||
| 361 | # GER GER <lemma> ... 12 | ||
| 362 | # GERAUX GERAUX ... 0 (but documented) | ||
| 363 | 'GER' => ['verbform' => 'ger'], | ||
| 364 | 'ger' => ['verbform' => 'ger'], | ||
| 365 | # Similarly, there are multiple ways of tagging past participles (used in compound tenses, not used adjectively): | ||
| 366 | # PPT PPT <lemma> ... 27 | ||
| 367 | # V V PPT-ms ... 184 | ||
| 368 | 'PPT' => ['verbform' => 'part', 'tense' => 'past', 'aspect' => 'perf'], | ||
| 369 | }, | ||
| 370 | 'encode_map' => | ||
| 371 | |||
| 372 | { 'verbform' => { 'inf' => 'inf', | ||
| 373 | 'ger' => 'ger', | ||
| 374 | 'part' => { 'tense' => { 'pres' => 'ger', | ||
| 375 | '@' => 'PPT' }}, | ||
| 376 | '@' => { 'mood' => { 'ind' => { 'tense' => { 'pres' => 'pi', | ||
| 377 | 'past' => { 'aspect' => { 'imp' => 'ii', | ||
| 378 | 'perf' => 'ppi' }}, | ||
| 379 | 'pqp' => 'mpi', | ||
| 380 | 'fut' => 'fi' }}, | ||
| 381 | 'cnd' => 'c', | ||
| 382 | 'sub' => { 'tense' => { 'pres' => 'pc', | ||
| 383 | 'past' => 'ic', | ||
| 384 | 'imp' => 'ic', | ||
| 385 | 'fut' => 'fc' }}, | ||
| 386 | 'imp' => 'imp' }}}} | ||
| 387 | ); | ||
| 388 | return \%atoms; | ||
| 389 | } | ||
| 390 | |||
| 391 | |||
| 392 | |||
| 393 | #------------------------------------------------------------------------------ | ||
| 394 | # Decodes a physical tag (string) and returns the corresponding feature | ||
| 395 | # structure. | ||
| 396 | #------------------------------------------------------------------------------ | ||
| 397 | sub decode | ||
| 398 | { | ||
| 399 | my $self = shift; | ||
| 400 | my $tag = shift; | ||
| 401 | my $fs = Lingua::Interset::FeatureStructure->new(); | ||
| 402 | $fs->set_tagset('pt::cintil'); | ||
| 403 | my $atoms = $self->atoms(); | ||
| 404 | # Three components, and the first two are identical: pos, pos, features. | ||
| 405 | # example: CN\tCN\tms | ||
| 406 | my ($pos, $subpos, $features) = split(/\s+/, $tag); | ||
| 407 | # Multi-word expressions: The tags are preceded by "L" and followed by | ||
| 408 | # a numerical index: LADV1, LADV2, ..., LADV7, LDFR1, LDFR2, LPREP1, ... | ||
| 409 | $pos =~ s/^L(.+)\d+$/$1/; | ||
| 410 | # Some features are separated by a hyphen, others are not separated. | ||
| 411 | # The underscore character is used if there are no features. | ||
| 412 | $features = '' if($features eq '_'); | ||
| 413 | my @features = split(/-/, $features); | ||
| 414 | # Separate gender, number and person. | ||
| 415 | # g is the undistinguishable gender, i.e. g = m|f | ||
| 416 | # n is the undistinguishable number, i.e. n = s|p | ||
| 417 | @features = map {m/^([mfg])([spn])([123])$/ ? ($1, $2, $3) : $_} (@features); | ||
| 418 | @features = map {m/^([mfg123])([spn])$/ ? ($1, $2) : $_} (@features); | ||
| 419 | $atoms->{pos}->decode_and_merge_hard($pos, $fs); | ||
| 420 | foreach my $feature (@features) | ||
| 421 | { | ||
| 422 | $atoms->{feature}->decode_and_merge_hard($feature, $fs); | ||
| 423 | } | ||
| 424 | return $fs; | ||
| 425 | } | ||
| 426 | |||
| 427 | |||
| 428 | |||
| 429 | #------------------------------------------------------------------------------ | ||
| 430 | # Takes feature structure and returns the corresponding physical tag (string). | ||
| 431 | #------------------------------------------------------------------------------ | ||
| 432 | sub encode | ||
| 433 | { | ||
| 434 | my $self = shift; | ||
| 435 | my $fs = shift; # Lingua::Interset::FeatureStructure | ||
| 436 | my $atoms = $self->atoms(); | ||
| 437 | my $pos = $atoms->{pos}->encode($fs); | ||
| 438 | my $features = '_'; | ||
| 439 | # Proper nouns / parts of names ("PNM"): according to documentation they should be POS tags but in fact they appear as features. | ||
| 440 | if($fs->is_proper_noun()) | ||
| 441 | { | ||
| 442 | $features = 'PNM'; | ||
| 443 | } | ||
| 444 | elsif($pos =~ m/^(ADJ|CARD|CL|CN|DA|DEM|IA|IND|MGT|MTH|ORD|PADR|POSS|PPA|PRS|QNT|REL|STT|UM|WD)$/) | ||
| 445 | { | ||
| 446 | $features = $atoms->{gn}->encode($fs); | ||
| 447 | # Relative adverbs do not encode gender and number. | ||
| 448 | $features = '_' if($pos eq 'REL' && $features eq 'gn'); | ||
| 449 | # Is it a degree of comparison other than positive? | ||
| 450 | if($fs->is_comparative()) | ||
| 451 | { | ||
| 452 | $features .= '-comp'; | ||
| 453 | } | ||
| 454 | elsif($fs->is_superlative()) | ||
| 455 | { | ||
| 456 | $features .= '-sup'; | ||
| 457 | } | ||
| 458 | # Is it a diminutive? | ||
| 459 | $features .= '-dim' if($fs->is_other('pt::cintil', 'diminutive', 'yes')); | ||
| 460 | } | ||
| 461 | if($pos =~ m/^(CL|PRS)$/) | ||
| 462 | { | ||
| 463 | $features .= $fs->person(); | ||
| 464 | } | ||
| 465 | if($pos =~ m/^(V|VAUX)$/) | ||
| 466 | { | ||
| 467 | my $tm = $atoms->{tm}->encode($fs); | ||
| 468 | my $pn = $atoms->{pn}->encode($fs); | ||
| 469 | $pn = 'nInf' if($tm eq 'inf' && $pn eq ''); | ||
| 470 | $pn = 'ms' if($tm eq 'PPT'); # actually this is gender+number, not person+number | ||
| 471 | $features = $tm; | ||
| 472 | $features .= "-$pn" if($pn ne ''); | ||
| 473 | } | ||
| 474 | my $tag = "$pos\t$pos\t$features"; | ||
| 475 | return $tag; | ||
| 476 | } | ||
| 477 | |||
| 478 | |||
| 479 | |||
| 480 | #------------------------------------------------------------------------------ | ||
| 481 | # Returns reference to list of known tags. | ||
| 482 | # Tags were collected from the corpus. | ||
| 483 | # 240 tag-features combinations have been observed in the sample Jo&atil;o sent | ||
| 484 | # us. Some of them are errors and were removed from our list. (We can decode | ||
| 485 | # them but we will not try to encode them.) | ||
| 486 | #------------------------------------------------------------------------------ | ||
| 487 | sub list | ||
| 488 | { | ||
| 489 | my $self = shift; | ||
| 490 | my $list = <<end_of_list | ||
| 491 | ADJ ADJ fp | ||
| 492 | ADJ ADJ fp-comp | ||
| 493 | ADJ ADJ fp-sup | ||
| 494 | ADJ ADJ fs | ||
| 495 | ADJ ADJ fs-comp | ||
| 496 | ADJ ADJ fs-dim | ||
| 497 | ADJ ADJ fs-sup | ||
| 498 | ADJ ADJ gn | ||
| 499 | ADJ ADJ gp | ||
| 500 | ADJ ADJ gp-comp | ||
| 501 | ADJ ADJ gs | ||
| 502 | ADJ ADJ gs-comp | ||
| 503 | ADJ ADJ mp | ||
| 504 | ADJ ADJ mp-comp | ||
| 505 | ADJ ADJ mp-dim | ||
| 506 | ADJ ADJ mp-sup | ||
| 507 | ADJ ADJ ms | ||
| 508 | ADJ ADJ ms-comp | ||
| 509 | ADJ ADJ ms-dim | ||
| 510 | ADJ ADJ ms-sup | ||
| 511 | ADV ADV _ | ||
| 512 | CARD CARD fp | ||
| 513 | CARD CARD fs | ||
| 514 | CARD CARD gp | ||
| 515 | CARD CARD mp | ||
| 516 | CARD CARD ms | ||
| 517 | CJ CJ _ | ||
| 518 | CL CL fp3 | ||
| 519 | CL CL fs3 | ||
| 520 | CL CL gn3 | ||
| 521 | CL CL gp2 | ||
| 522 | CL CL gp3 | ||
| 523 | CL CL gs1 | ||
| 524 | CL CL gs2 | ||
| 525 | CL CL gs3 | ||
| 526 | CL CL mp3 | ||
| 527 | CL CL ms3 | ||
| 528 | CN CN PNM | ||
| 529 | CN CN fp | ||
| 530 | CN CN fp-dim | ||
| 531 | CN CN fs | ||
| 532 | CN CN fs-dim | ||
| 533 | CN CN gp | ||
| 534 | CN CN gs | ||
| 535 | CN CN mn | ||
| 536 | CN CN mp | ||
| 537 | CN CN mp-dim | ||
| 538 | CN CN ms | ||
| 539 | CN CN ms-dim | ||
| 540 | CN CN ms-sup | ||
| 541 | DA DA fp | ||
| 542 | DA DA fs | ||
| 543 | DA DA mp | ||
| 544 | DA DA ms | ||
| 545 | DEM DEM fp | ||
| 546 | DEM DEM fs | ||
| 547 | DEM DEM gp | ||
| 548 | DEM DEM gs | ||
| 549 | DEM DEM mp | ||
| 550 | DEM DEM ms | ||
| 551 | DFR DFR _ | ||
| 552 | DGT DGT _ | ||
| 553 | DGTR DGTR _ | ||
| 554 | DM DM _ | ||
| 555 | IA IA fp | ||
| 556 | IA IA mp | ||
| 557 | IND IND mp | ||
| 558 | IND IND ms | ||
| 559 | INT INT _ | ||
| 560 | ITJ ITJ _ | ||
| 561 | LTR LTR _ | ||
| 562 | MGT MGT mp | ||
| 563 | MTH MTH ms | ||
| 564 | ORD ORD fn | ||
| 565 | ORD ORD fp | ||
| 566 | ORD ORD fs | ||
| 567 | ORD ORD mn | ||
| 568 | ORD ORD mp | ||
| 569 | ORD ORD ms | ||
| 570 | PADR PADR fs | ||
| 571 | PADR PADR ms | ||
| 572 | PNT PNT _ | ||
| 573 | POSS POSS fp | ||
| 574 | POSS POSS fs | ||
| 575 | POSS POSS mp | ||
| 576 | POSS POSS ms | ||
| 577 | PPA PPA fp | ||
| 578 | PPA PPA fs | ||
| 579 | PPA PPA gp | ||
| 580 | PPA PPA gs | ||
| 581 | PPA PPA mp | ||
| 582 | PPA PPA ms | ||
| 583 | PREP PREP _ | ||
| 584 | PRS PRS fp3 | ||
| 585 | PRS PRS fs3 | ||
| 586 | PRS PRS gp1 | ||
| 587 | PRS PRS gp2 | ||
| 588 | PRS PRS gs1 | ||
| 589 | PRS PRS gs2 | ||
| 590 | PRS PRS gs3 | ||
| 591 | PRS PRS mp1 | ||
| 592 | PRS PRS mp3 | ||
| 593 | PRS PRS ms1 | ||
| 594 | PRS PRS ms3 | ||
| 595 | QNT QNT fp | ||
| 596 | QNT QNT fs | ||
| 597 | QNT QNT gp | ||
| 598 | QNT QNT gs | ||
| 599 | QNT QNT mp | ||
| 600 | QNT QNT ms | ||
| 601 | REL REL _ | ||
| 602 | REL REL fp | ||
| 603 | REL REL fs | ||
| 604 | REL REL gp | ||
| 605 | REL REL gs | ||
| 606 | REL REL mp | ||
| 607 | REL REL ms | ||
| 608 | STT STT fs | ||
| 609 | STT STT ms | ||
| 610 | SYB SYB _ | ||
| 611 | UM UM fs | ||
| 612 | UM UM ms | ||
| 613 | V V PPT-ms | ||
| 614 | V V c-1p | ||
| 615 | V V c-1s | ||
| 616 | V V c-2s | ||
| 617 | V V c-3p | ||
| 618 | V V c-3s | ||
| 619 | V V fc-1p | ||
| 620 | V V fc-2s | ||
| 621 | V V fc-3p | ||
| 622 | V V fc-3s | ||
| 623 | V V fi-1p | ||
| 624 | V V fi-1s | ||
| 625 | V V fi-2s | ||
| 626 | V V fi-3p | ||
| 627 | V V fi-3s | ||
| 628 | V V ger | ||
| 629 | V V ic-1p | ||
| 630 | V V ic-2s | ||
| 631 | V V ic-3p | ||
| 632 | V V ic-3s | ||
| 633 | V V ii-1p | ||
| 634 | V V ii-1s | ||
| 635 | V V ii-2s | ||
| 636 | V V ii-3p | ||
| 637 | V V ii-3s | ||
| 638 | V V imp-2s | ||
| 639 | V V inf-1p | ||
| 640 | V V inf-3p | ||
| 641 | V V inf-3s | ||
| 642 | V V inf-nInf | ||
| 643 | V V mpi-3s | ||
| 644 | V V pc-1p | ||
| 645 | V V pc-1s | ||
| 646 | V V pc-3p | ||
| 647 | V V pc-3s | ||
| 648 | V V pi-1p | ||
| 649 | V V pi-1s | ||
| 650 | V V pi-2s | ||
| 651 | V V pi-3p | ||
| 652 | V V pi-3s | ||
| 653 | V V ppi-1p | ||
| 654 | V V ppi-1s | ||
| 655 | V V ppi-2s | ||
| 656 | V V ppi-3p | ||
| 657 | V V ppi-3s | ||
| 658 | VAUX VAUX c-3p | ||
| 659 | VAUX VAUX c-3s | ||
| 660 | VAUX VAUX fi-3s | ||
| 661 | VAUX VAUX ic-3s | ||
| 662 | VAUX VAUX ii-3p | ||
| 663 | VAUX VAUX ii-3s | ||
| 664 | VAUX VAUX pc-3p | ||
| 665 | VAUX VAUX pc-3s | ||
| 666 | VAUX VAUX pi-1s | ||
| 667 | VAUX VAUX pi-3p | ||
| 668 | VAUX VAUX pi-3s | ||
| 669 | WD WD fs | ||
| 670 | WD WD mp | ||
| 671 | WD WD ms | ||
| 672 | end_of_list | ||
| 673 | ; | ||
| 674 | # Protect from editors that replace tabs by spaces. | ||
| 675 | $list =~ s/[ \t]+/\t/sg; | ||
| 676 | my @list = split(/\r?\n/, $list); | ||
| 677 | return \@list; | ||
| 678 | } | ||
| 679 | |||
| 680 | |||
| 681 | |||
| 682 | 1; | ||
| 683 | |||
| 684 | __END__ | ||
| 685 | |||
| 686 | =pod | ||
| 687 | |||
| 688 | =encoding UTF-8 | ||
| 689 | |||
| 690 | =head1 NAME | ||
| 691 | |||
| 692 | Lingua::Interset::Tagset::PT::Cintil - Driver for the Portuguese tagset of the CINTIL corpus (Corpus Internacional do Portugues). | ||
| 693 | |||
| 694 | =head1 VERSION | ||
| 695 | |||
| 696 | version 3.014 | ||
| 697 | |||
| 698 | =head1 SYNOPSIS | ||
| 699 | |||
| 700 | use Lingua::Interset::Tagset::PT::Cintil; | ||
| 701 | my $driver = Lingua::Interset::Tagset::PT::Cintil->new(); | ||
| 702 | my $fs = $driver->decode("CN\tCN\tms"); | ||
| 703 | |||
| 704 | or | ||
| 705 | |||
| 706 | use Lingua::Interset qw(decode); | ||
| 707 | my $fs = decode('pt::cintil', "CN\tCN\tms"); | ||
| 708 | |||
| 709 | =head1 DESCRIPTION | ||
| 710 | |||
| 711 | Interset driver for the Portuguese tagset of the CINTIL corpus | ||
| 712 | (Corpus Internacional do Portugu≖s, | ||
| 713 | L<http://cintil.ul.pt/>). | ||
| 714 | |||
| 715 | =head1 SEE ALSO | ||
| 716 | |||
| 717 | L<http://cintil.ul.pt/cintilwhatsin.html#guidelines> | ||
| 718 | |||
| 719 | L<Lingua::Interset>, | ||
| 720 | L<Lingua::Interset::Tagset>, | ||
| 721 | L<Lingua::Interset::FeatureStructure> | ||
| 722 | |||
| 723 | =head1 AUTHOR | ||
| 724 | |||
| 725 | Dan Zeman <zeman@ufal.mff.cuni.cz> | ||
| 726 | |||
| 727 | =head1 COPYRIGHT AND LICENSE | ||
| 728 | |||
| 729 | This software is copyright (c) 2019 by Univerzita Karlova (Charles University). | ||
| 730 | |||
| 731 | This is free software; you can redistribute it and/or modify it under | ||
| 732 | the same terms as the Perl 5 programming language system itself. | ||
| 733 | |||
| 734 | =cut |