| 1 | # ABSTRACT: Driver for the Mamba tagset of Swedish (Talbanken). | ||
| 2 | # Copyright © 2006, 2015, 2017 Dan Zeman <zeman@ufal.mff.cuni.cz> | ||
| 3 | # 25.1.2015: moved to the new object-oriented Interset | ||
| 4 | |||
| 5 | package Lingua::Interset::Tagset::SV::Mamba; | ||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | our $VERSION = '3.014'; | ||
| 9 | |||
| 10 | use utf8; | ||
| 11 | use open ':utf8'; | ||
| 12 | use namespace::autoclean; | ||
| 13 | use Moose; | ||
| 14 | extends 'Lingua::Interset::Atom'; | ||
| 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 '::' and | ||
| 23 | # a language-specific tagset id. Example: 'cs::multext'. | ||
| 24 | #------------------------------------------------------------------------------ | ||
| 25 | sub get_tagset_id | ||
| 26 | { | ||
| 27 | return 'sv::mamba'; | ||
| 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 | # Construct decode_map in the form expected by Atom. | ||
| 44 | my %dm = | ||
| 45 | ( | ||
| 46 | # ++ Coordinating conjunction | ||
| 47 | # Examples: och, eller, men, utan, samt | ||
| 48 | '++' => ['pos' => 'conj', 'conjtype' => 'coor'], | ||
| 49 | # AB Adverb | ||
| 50 | # Examples: inte, så, också, i, där | ||
| 51 | 'AB' => ['pos' => 'adv'], | ||
| 52 | # AJ Adjective | ||
| 53 | # Examples: stor, olika, större, stora, nya | ||
| 54 | 'AJ' => ['pos' => 'adj'], | ||
| 55 | # AN Adjectival noun | ||
| 56 | # Examples: möjlighet, trygghet, möjligheter, frihet, svårigheter | ||
| 57 | # möjlig = possible => möjlighet = possibility | ||
| 58 | 'AN' => ['pos' => 'noun', 'other' => {'nountype' => 'adj'}], | ||
| 59 | # AV The verb "vara" (be) | ||
| 60 | # Examples: är, vara, var, varit, vore | ||
| 61 | 'AV' => ['pos' => 'verb', 'other' => {'verb' => 'vara'}], | ||
| 62 | # BV The verb "bli(va)" (become) | ||
| 63 | # Examples: blir, bli, blivit, blev, bör | ||
| 64 | 'BV' => ['pos' => 'verb', 'other' => {'verb' => 'bliva'}], | ||
| 65 | # EN Indefinite article or numeral "en", "ett" (one) | ||
| 66 | # Examples: en, ett, 1 | ||
| 67 | 'EN' => ['pos' => 'adj|num', 'prontype' => 'art', 'definite' => 'ind'], | ||
| 68 | # FV The verb "faa" (get) | ||
| 69 | # Examples: får, få, fått, fick, finns | ||
| 70 | 'FV' => ['pos' => 'verb', 'other' => {'verb' => 'faa'}], | ||
| 71 | # GV The verb "göra" (do, make) | ||
| 72 | # Examples: göra, gör, gjort, gjorde, görs | ||
| 73 | 'GV' => ['pos' => 'verb', 'other' => {'verb' => 'göra'}], | ||
| 74 | # HV The verb "ha(va)" (have) | ||
| 75 | # Examples: har, ha, hade, haft, hava | ||
| 76 | 'HV' => ['pos' => 'verb', 'other' => {'verb' => 'hava'}], | ||
| 77 | # I? Question mark | ||
| 78 | # Examples: ? | ||
| 79 | 'I?' => ['pos' => 'punc', 'punctype' => 'qest'], | ||
| 80 | # IC Quotation mark | ||
| 81 | # Examples: ' | ||
| 82 | 'IC' => ['pos' => 'punc', 'punctype' => 'quot'], | ||
| 83 | # ID Part of idiom (multi-word unit) | ||
| 84 | # Examples: att, Backberger, och, av, Hellsten | ||
| 85 | 'ID' => ['hyph' => 'yes'], ###!!! Some other solution should be found. | ||
| 86 | # IG Other punctuation mark | ||
| 87 | # Examples: ..., /, =, ...., 1 | ||
| 88 | 'IG' => ['pos' => 'punc'], | ||
| 89 | # IK Comma | ||
| 90 | # Examples: , | ||
| 91 | 'IK' => ['pos' => 'punc', 'punctype' => 'comm'], | ||
| 92 | # IM Infinitive marker | ||
| 93 | # Examples: att | ||
| 94 | 'IM' => ['pos' => 'conj', 'verbform' => 'inf'], ###!!! or particle? | ||
| 95 | # IP Period | ||
| 96 | # Examples: . | ||
| 97 | 'IP' => ['pos' => 'punc', 'punctype' => 'peri'], | ||
| 98 | # IQ Colon | ||
| 99 | # Examples: : | ||
| 100 | 'IQ' => ['pos' => 'punc', 'punctype' => 'colo'], | ||
| 101 | # IR Parenthesis | ||
| 102 | # Examples: (, ) | ||
| 103 | 'IR' => ['pos' => 'punc', 'punctype' => 'brck'], | ||
| 104 | # IS Semicolon | ||
| 105 | # Examples: ; | ||
| 106 | 'IS' => ['pos' => 'punc', 'punctype' => 'semi'], | ||
| 107 | # IT Dash | ||
| 108 | # Examples: -, --- | ||
| 109 | 'IT' => ['pos' => 'punc', 'punctype' => 'dash'], | ||
| 110 | # IU Exclamation mark | ||
| 111 | # Examples: ! | ||
| 112 | 'IU' => ['pos' => 'punc', 'punctype' => 'excl'], | ||
| 113 | # KV The verb "komma att" (periphrastic future) | ||
| 114 | # Examples: kommer, kommit, kom, komma, komer | ||
| 115 | 'KV' => ['pos' => 'verb', 'other' => {'verb' => 'komma'}], | ||
| 116 | # MN Adversative | ||
| 117 | 'MN' => ['pos' => 'conj', 'conjtype' => 'coor', 'other' => {'conjtype' => 'adversative'}], | ||
| 118 | # MV The verb "maaste" (must) | ||
| 119 | # Examples: måste, måsk | ||
| 120 | 'MV' => ['pos' => 'verb', 'other' => {'verb' => 'maaste'}], | ||
| 121 | # NN Other noun | ||
| 122 | # Examples: äktenskapet, barn, äktenskap, familjen, människor | ||
| 123 | 'NN' => ['pos' => 'noun', 'nountype' => 'com'], | ||
| 124 | # PN Proper name | ||
| 125 | # Examples: Barbro, Stig, Sverige, Gud, Hellsten | ||
| 126 | 'PN' => ['pos' => 'noun', 'nountype' => 'prop'], | ||
| 127 | # PO Pronoun | ||
| 128 | # Examples: det, som, den, man, de | ||
| 129 | 'PO' => ['pos' => 'noun', 'prontype' => 'prn'], | ||
| 130 | # PR Preposition | ||
| 131 | # Examples: i, av, på, för, med | ||
| 132 | 'PR' => ['pos' => 'adp', 'adpostype' => 'prep'], | ||
| 133 | # PU Pause | ||
| 134 | # Examples: *, - | ||
| 135 | 'PU' => ['pos' => 'int', 'other' => {'inttype' => 'pause'}], | ||
| 136 | # QV The verb "kunna" (can) | ||
| 137 | # Examples: kan, kunna, kunde, kunnat | ||
| 138 | 'QV' => ['pos' => 'verb', 'other' => {'verb' => 'kunna'}], | ||
| 139 | # RO Numeral other than "en", "ett" (one) | ||
| 140 | # Examples: två, tre, 20, 1968, 10 | ||
| 141 | 'RO' => ['pos' => 'num'], | ||
| 142 | # SP Present participle | ||
| 143 | # Examples: kommande, bestående, gällande, växande, nuvarande | ||
| 144 | 'SP' => ['pos' => 'verb', 'verbform' => 'part', 'tense' => 'pres'], | ||
| 145 | # SV The verb "skola" (will, shall) | ||
| 146 | # Examples: skall, skulle, ska, skola | ||
| 147 | 'SV' => ['pos' => 'verb', 'other' => {'verb' => 'skola'}], | ||
| 148 | ###!!! The old sv::mamba driver decoded TP as total pronoun. | ||
| 149 | ###!!! Given the examples from the corpus, it must have been an error. | ||
| 150 | ###!!! I am inclined to believe that TP stands for past participles. | ||
| 151 | # TP Past participle | ||
| 152 | # Examples: ökade, ingångna, ökad, utlämnade, baserat | ||
| 153 | 'TP' => ['pos' => 'verb', 'verbform' => 'part', 'tense' => 'past'], | ||
| 154 | # UK Subordinating conjunction | ||
| 155 | # Examples: att, som, om, än, så | ||
| 156 | 'UK' => ['pos' => 'conj', 'conjtype' => 'sub'], | ||
| 157 | # VN Verbal noun | ||
| 158 | # Examples: uppfattning, betydelse, uppfostran, utsträckning, utveckling | ||
| 159 | 'VN' => ['pos' => 'noun', 'verbform' => 'ger'], | ||
| 160 | # VV Other verb | ||
| 161 | # Examples: finns, bör, tror, anser, säger | ||
| 162 | 'VV' => ['pos' => 'verb'], | ||
| 163 | # WV The verb "vilja" (want) | ||
| 164 | # Examples: vill, vilja, ville, velat | ||
| 165 | 'WV' => ['pos' => 'verb', 'other' => {'verb' => 'vilja'}], | ||
| 166 | # XX Unclassifiable part-of-speech | ||
| 167 | # Examples: som, lika, =, brattom, för | ||
| 168 | 'XX' => [], | ||
| 169 | # YY Interjection | ||
| 170 | # Examples: ja, nej, jo, jodå, javisst | ||
| 171 | 'YY' => ['pos' => 'int'], | ||
| 172 | # EH Filled pause | ||
| 173 | 'EH' => ['pos' => 'int', 'other' => {'inttype' => 'filledpause'}], | ||
| 174 | # RJ Juncture - straight | ||
| 175 | 'RJ' => ['pos' => 'int', 'other' => {'inttype' => 'straightjuncture'}], | ||
| 176 | # UJ Juncture - rise | ||
| 177 | 'UJ' => ['pos' => 'int', 'other' => {'inttype' => 'risejuncture'}], | ||
| 178 | # NJ Juncture - fall | ||
| 179 | 'NJ' => ['pos' => 'int', 'other' => {'inttype' => 'falljuncture'}], | ||
| 180 | # QQ Dummy for final omission | ||
| 181 | 'QQ' => ['other' => {'pos' => 'dummy'}], | ||
| 182 | # UU Exclamative or optative | ||
| 183 | 'UU' => ['other' => {'pos' => 'excl'}], ###!!!??? | ||
| 184 | # TT Vocative | ||
| 185 | 'TT' => ['other' => {'pos' => 'voc'}], ###!!!??? | ||
| 186 | ); | ||
| 187 | # Construct encode_map in the form expected by Atom. | ||
| 188 | my %em = | ||
| 189 | ( | ||
| 190 | 'pos' => { 'noun' => { 'verbform' => { 'ger' => 'VN', | ||
| 191 | '@' => { 'prontype' => { '' => { 'nountype' => { 'prop' => 'PN', | ||
| 192 | '@' => { 'other/nountype' => { 'adj' => 'AN', | ||
| 193 | '@' => 'NN' }}}}, | ||
| 194 | '@' => 'PO' }}}}, | ||
| 195 | 'adj' => { 'definite' => { 'ind' => 'EN', | ||
| 196 | '@' => 'AJ' }}, | ||
| 197 | 'num' => { 'definite' => { 'ind' => 'EN', | ||
| 198 | '@' => 'RO' }}, | ||
| 199 | 'verb' => { 'verbform' => { 'part' => { 'tense' => { 'pres' => 'SP', | ||
| 200 | '@' => 'TP' }}, | ||
| 201 | '@' => { 'other/verb' => { 'vara' => 'AV', | ||
| 202 | 'bliva' => 'BV', | ||
| 203 | 'faa' => 'FV', | ||
| 204 | 'göra' => 'GV', | ||
| 205 | 'hava' => 'HV', | ||
| 206 | 'komma' => 'KV', | ||
| 207 | 'maaste' => 'MV', | ||
| 208 | 'kunna' => 'QV', | ||
| 209 | 'skola' => 'SV', | ||
| 210 | 'vilja' => 'WV', | ||
| 211 | '@' => 'VV' }}}}, | ||
| 212 | 'adv' => 'AB', | ||
| 213 | 'adp' => 'PR', | ||
| 214 | 'conj' => { 'verbform' => { 'inf' => 'IM', | ||
| 215 | '@' => { 'conjtype' => { 'sub' => 'UK', | ||
| 216 | '@' => { 'other/conjtype' => { 'adversative' => 'MN', | ||
| 217 | '@' => '++' }}}}}}, | ||
| 218 | 'int' => { 'other/inttype' => { 'pause' => 'PU', | ||
| 219 | 'filledpause' => 'EH', | ||
| 220 | 'straightjuncture' => 'RJ', | ||
| 221 | 'risejuncture' => 'UJ', | ||
| 222 | 'falljuncture' => 'NJ', | ||
| 223 | '@' => 'YY' }}, | ||
| 224 | 'punc' => { 'punctype' => { 'qest' => 'I?', | ||
| 225 | 'quot' => 'IC', | ||
| 226 | 'comm' => 'IK', | ||
| 227 | 'peri' => 'IP', | ||
| 228 | 'colo' => 'IQ', | ||
| 229 | 'brck' => 'IR', | ||
| 230 | 'semi' => 'IS', | ||
| 231 | 'dash' => 'IT', | ||
| 232 | 'excl' => 'IU', | ||
| 233 | '@' => 'IG' }}, | ||
| 234 | '@' => { 'hyph' => { 'yes' => 'ID', | ||
| 235 | '@' => { 'other/pos' => { 'dummy' => 'QQ', | ||
| 236 | 'excl' => 'UU', | ||
| 237 | 'voc' => 'TT', | ||
| 238 | '@' => 'XX' }}}}} | ||
| 239 | ); | ||
| 240 | # Now add the references to the attribute hash. | ||
| 241 | $attr->{surfeature} = 'pos'; | ||
| 242 | $attr->{decode_map} = \%dm; | ||
| 243 | $attr->{encode_map} = \%em; | ||
| 244 | $attr->{tagset} = 'sv::mamba'; | ||
| 245 | return $attr; | ||
| 246 | }; | ||
| 247 | |||
| 248 | |||
| 249 | |||
| 250 | #------------------------------------------------------------------------------ | ||
| 251 | # Decodes a physical tag (string) and returns the corresponding feature | ||
| 252 | # structure. In addition to Atom, we just need to identify the tagset of | ||
| 253 | # origin. | ||
| 254 | #------------------------------------------------------------------------------ | ||
| 255 | sub decode | ||
| 256 | { | ||
| 257 | my $self = shift; | ||
| 258 | my $tag = shift; | ||
| 259 | my $fs = $self->SUPER::decode($tag); | ||
| 260 | $fs->set_tagset('sv::mamba'); | ||
| 261 | return $fs; | ||
| 262 | } | ||
| 263 | |||
| 264 | |||
| 265 | |||
| 266 | 1; | ||
| 267 | |||
| 268 | __END__ | ||
| 269 | |||
| 270 | =pod | ||
| 271 | |||
| 272 | =encoding UTF-8 | ||
| 273 | |||
| 274 | =head1 NAME | ||
| 275 | |||
| 276 | Lingua::Interset::Tagset::SV::Mamba - Driver for the Mamba tagset of Swedish (Talbanken). | ||
| 277 | |||
| 278 | =head1 VERSION | ||
| 279 | |||
| 280 | version 3.014 | ||
| 281 | |||
| 282 | =head1 SYNOPSIS | ||
| 283 | |||
| 284 | use Lingua::Interset::Tagset::SV::Mamba; | ||
| 285 | my $driver = Lingua::Interset::Tagset::SV::Mamba->new(); | ||
| 286 | my $fs = $driver->decode('NN'); | ||
| 287 | |||
| 288 | or | ||
| 289 | |||
| 290 | use Lingua::Interset qw(decode); | ||
| 291 | my $fs = decode('sv::mamba', 'NN'); | ||
| 292 | |||
| 293 | =head1 DESCRIPTION | ||
| 294 | |||
| 295 | Interset driver for the Mamba tagset of Swedish, used e.g. in the older versions of the Talbanken corpus. | ||
| 296 | |||
| 297 | =head1 SEE ALSO | ||
| 298 | |||
| 299 | L<Lingua::Interset> | ||
| 300 | L<Lingua::Interset::Tagset>, | ||
| 301 | L<Lingua::Interset::FeatureStructure> | ||
| 302 | |||
| 303 | =head1 AUTHOR | ||
| 304 | |||
| 305 | Dan Zeman <zeman@ufal.mff.cuni.cz> | ||
| 306 | |||
| 307 | =head1 COPYRIGHT AND LICENSE | ||
| 308 | |||
| 309 | This software is copyright (c) 2019 by Univerzita Karlova (Charles University). | ||
| 310 | |||
| 311 | This is free software; you can redistribute it and/or modify it under | ||
| 312 | the same terms as the Perl 5 programming language system itself. | ||
| 313 | |||
| 314 | =cut |