| 1 | # ABSTRACT: Driver for the tagset of the Uyghur Dependency Treebank. | ||
| 2 | # Copyright © 2016 Dan Zeman <zeman@ufal.mff.cuni.cz> | ||
| 3 | |||
| 4 | package Lingua::Interset::Tagset::UG::Udt; | ||
| 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 'ug::udt'; | ||
| 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 | # Some help with Uyghur parts of speech but not the same tagset: | ||
| 46 | # http://www.aclweb.org/anthology/Y03-1025 | ||
| 47 | # noun / isim ئىسىم | ||
| 48 | 'N' => ['pos' => 'noun'], | ||
| 49 | # verb / pë'il پېئىل | ||
| 50 | 'V' => ['pos' => 'verb'], | ||
| 51 | # adjective / süpet سۈپەت | ||
| 52 | 'A' => ['pos' => 'adj'], | ||
| 53 | # verbal adjective / lewzan / söz-herp سۆز-ھەرپ | ||
| 54 | 'LW' => ['pos' => 'adj', 'verbform' => 'part'], | ||
| 55 | # pronoun / almash ئالماش | ||
| 56 | 'P' => ['pos' => 'noun', 'prontype' => 'prn'], | ||
| 57 | # quantifier / miqtar söz مىقدار سۆز | ||
| 58 | 'Q' => ['pos' => 'adj', 'numtype' => 'card', 'prontype' => 'ind'], | ||
| 59 | # numeral / san سان | ||
| 60 | 'M' => ['pos' => 'num'], | ||
| 61 | # adverb / rewish رەۋىش | ||
| 62 | 'D' => ['pos' => 'adv'], | ||
| 63 | # postposition / tirkelme تىركەلمە | ||
| 64 | 'R' => ['pos' => 'adp'], | ||
| 65 | # conjunction / baghlighuchi باغلىغۇچى | ||
| 66 | 'C' => ['pos' => 'conj'], | ||
| 67 | # particle / yüklime يۈكلىمە (e.g. the question particle "mu", or "too") | ||
| 68 | 'T' => ['pos' => 'part'], | ||
| 69 | # exclamation / imliq söz ئىملىق سۆز / ündesh # uff, wow, cool | ||
| 70 | 'E' => ['pos' => 'int', 'other' => {'pos' => 'exclamation'}], | ||
| 71 | # onomatopoeia / imitative word / teqlid söz تەقلىد سۆز # nock nock (on the door) etc. | ||
| 72 | 'I' => ['pos' => 'int', 'other' => {'pos' => 'onomatopoeia'}], | ||
| 73 | # extra / surplus / residual / qoshumche قوشۇمچە | ||
| 74 | 'X' => [], | ||
| 75 | # punctuation / tinish belgiliri تىنىش بەلگىلىرى | ||
| 76 | 'Y' => ['pos' => 'punc'] | ||
| 77 | ); | ||
| 78 | # Construct encode_map in the form expected by Atom. | ||
| 79 | my %em = | ||
| 80 | ( | ||
| 81 | 'pos' => { 'noun' => { 'prontype' => { '' => 'N', | ||
| 82 | '@' => 'P' }}, | ||
| 83 | 'verb' => 'V', | ||
| 84 | 'adj' => { 'verbform' => { 'part' => 'LW', | ||
| 85 | '@' => { 'prontype' => { '' => 'A', | ||
| 86 | '@' => 'Q' }}}}, | ||
| 87 | 'num' => 'M', | ||
| 88 | 'adv' => 'D', | ||
| 89 | 'adp' => 'R', | ||
| 90 | 'conj' => 'C', | ||
| 91 | 'part' => 'T', | ||
| 92 | 'int' => { 'other/pos' => { 'exclamation' => 'E', | ||
| 93 | '@' => 'I' }}, | ||
| 94 | 'punc' => 'Y', | ||
| 95 | '@' => 'X' } | ||
| 96 | ); | ||
| 97 | # Now add the references to the attribute hash. | ||
| 98 | $attr->{surfeature} = 'pos'; | ||
| 99 | $attr->{decode_map} = \%dm; | ||
| 100 | $attr->{encode_map} = \%em; | ||
| 101 | $attr->{tagset} = 'ug::udt'; | ||
| 102 | return $attr; | ||
| 103 | }; | ||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | #------------------------------------------------------------------------------ | ||
| 108 | # Decodes a physical tag (string) and returns the corresponding feature | ||
| 109 | # structure. In addition to Atom, we just need to identify the tagset of | ||
| 110 | # origin. | ||
| 111 | #------------------------------------------------------------------------------ | ||
| 112 | sub decode | ||
| 113 | { | ||
| 114 | my $self = shift; | ||
| 115 | my $tag = shift; | ||
| 116 | my $fs = $self->SUPER::decode($tag); | ||
| 117 | $fs->set_tagset('ug::udt'); | ||
| 118 | return $fs; | ||
| 119 | } | ||
| 120 | |||
| 121 | |||
| 122 | |||
| 123 | 1; | ||
| 124 | |||
| 125 | __END__ | ||
| 126 | |||
| 127 | =pod | ||
| 128 | |||
| 129 | =encoding UTF-8 | ||
| 130 | |||
| 131 | =head1 NAME | ||
| 132 | |||
| 133 | Lingua::Interset::Tagset::UG::Udt - Driver for the tagset of the Uyghur Dependency Treebank. | ||
| 134 | |||
| 135 | =head1 VERSION | ||
| 136 | |||
| 137 | version 3.014 | ||
| 138 | |||
| 139 | =head1 SYNOPSIS | ||
| 140 | |||
| 141 | use Lingua::Interset::Tagset::UG::Udt; | ||
| 142 | my $driver = Lingua::Interset::Tagset::UG::Udt->new(); | ||
| 143 | my $fs = $driver->decode('N'); | ||
| 144 | |||
| 145 | or | ||
| 146 | |||
| 147 | use Lingua::Interset qw(decode); | ||
| 148 | my $fs = decode('ug::udt', 'N'); | ||
| 149 | |||
| 150 | =head1 DESCRIPTION | ||
| 151 | |||
| 152 | Interset driver for the part-of-speech tagset of the Uyghur Dependency Treebank. | ||
| 153 | |||
| 154 | =head1 SEE ALSO | ||
| 155 | |||
| 156 | L<Lingua::Interset> | ||
| 157 | L<Lingua::Interset::Tagset>, | ||
| 158 | L<Lingua::Interset::FeatureStructure> | ||
| 159 | |||
| 160 | =head1 AUTHOR | ||
| 161 | |||
| 162 | Dan Zeman <zeman@ufal.mff.cuni.cz> | ||
| 163 | |||
| 164 | =head1 COPYRIGHT AND LICENSE | ||
| 165 | |||
| 166 | This software is copyright (c) 2019 by Univerzita Karlova (Charles University). | ||
| 167 | |||
| 168 | This is free software; you can redistribute it and/or modify it under | ||
| 169 | the same terms as the Perl 5 programming language system itself. | ||
| 170 | |||
| 171 | =cut |