Interset/Tagset/CS/Cnk.pm untested

filter: Statementstmt 0.0% 0 / 56 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 72 CC 2 SCAR 10.0
CC
2
Cov
0%
list
6.0
_create_atoms
2.0
decode
2.0
CRAP 2.7
1 # ABSTRACT: Driver for the tagset of the Czech National Corpus (Český národní korpus).
2 # Copyright © 2014 Dan Zeman <zeman@ufal.mff.cuni.cz>
3  
4 package Lingua::Interset::Tagset::CS::Cnk;
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::Tagset::CS::Pdt';
14  
15  
16  
17 #------------------------------------------------------------------------------
18 # Creates atomic drivers for 12 surface features (11 inherited from Pdt).
19 #------------------------------------------------------------------------------
20 sub _create_atoms
21 {
22 my $self = shift;
23 my $atoms = $self->SUPER::_create_atoms();
24 # ASPECT ####################
25 $atoms->{aspect} = $self->create_atom
26 (
27 'surfeature' => 'aspect',
28 'decode_map' =>
29 {
30 'I' => ['aspect' => 'imp'],
31 'P' => ['aspect' => 'perf'],
32 'B' => ['aspect' => 'imp|perf'] # example: nehodí
33 },
34 'encode_map' =>
35  
36 { 'pos' => { 'verb' => { 'aspect' => { 'imp' => 'I',
37 'perf' => 'P',
38 'imp|perf' => 'B',
39 '@' => '-' }},
40 '@' => '-' }}
41 );
42 return $atoms;
43 }
44  
45  
46  
47 #------------------------------------------------------------------------------
48 # Decodes a physical tag (string) and returns the corresponding feature
49 # structure.
50 #------------------------------------------------------------------------------
51 sub decode
52 {
53 my $self = shift;
54 my $tag = shift;
55 my $pdt = substr($tag, 0, 15);
56 my $aspect = substr($tag, 15, 1);
57 my $fs = $self->SUPER::decode($pdt);
58 my $atoms = $self->atoms();
59 $atoms->{aspect}->decode_and_merge_hard($aspect, $fs);
60 # Here we could set $fs->set_tagset('cs::cnk') but we will not so that all
61 # the descendants of cs::pdt can share the same feature structures.
62 # (The cs::cnk feature structures are not identical to cs::pdt but they do
63 # not add their own 'other' values and that matters.)
64 return $fs;
65 }
66  
67  
68  
69 #------------------------------------------------------------------------------
70 # Takes feature structure and returns the corresponding physical tag (string).
71 #------------------------------------------------------------------------------
72 sub encode
73 {
74 my $self = shift;
75 my $fs = shift; # Lingua::Interset::FeatureStructure
76 my $pdt = $self->SUPER::encode($fs);
77 my $atoms = $self->atoms();
78 my $aspect = $atoms->{aspect}->encode($fs);
79 return $pdt.$aspect;
80 }
81  
82  
83  
84 #------------------------------------------------------------------------------
85 # Returns reference to list of known tags.
86 #------------------------------------------------------------------------------
87 sub list
88 {
89 my $self = shift;
90 my $list_pdt = $self->SUPER::list();
91 # Add the sixteenth character to every tag.
92 # For verbs, it is I, P or B. For everything else, it is -.
93 my @list;
94 foreach my $tag (@{$list_pdt})
95 {
96 if($tag =~ m/^V/)
97 {
98 push(@list, $tag.'B', $tag.'I', $tag.'P');
99 }
100 else
101 {
102 push(@list, $tag.'-');
103 }
104 }
105 return \@list;
106 }
107  
108  
109  
110 1;
111  
112 __END__
113  
114 =pod
115  
116 =encoding UTF-8
117  
118 =head1 NAME
119  
120 Lingua::Interset::Tagset::CS::Cnk - Driver for the tagset of the Czech National Corpus (Český národní korpus).
121  
122 =head1 VERSION
123  
124 version 3.014
125  
126 =head1 SYNOPSIS
127  
128 use Lingua::Interset::Tagset::CS::Cnk;
129 my $driver = Lingua::Interset::Tagset::CS::Cnk->new();
130 my $fs = $driver->decode('NNMS1-----A-----');
131  
132 or
133  
134 use Lingua::Interset qw(decode);
135 my $fs = decode('cs::cnk', 'NNMS1-----A-----');
136  
137 =head1 DESCRIPTION
138  
139 Interset driver for the tagset used in the Czech National Corpus (Český národní korpus).
140 The tagset is a slight modification of the tagset used in the Prague Dependency Treebank
141 (see L<Lingua::Interset::Tagset::CS::Pdt>). The only difference is a sixteenth character
142 that encodes aspect of verbs.
143  
144 =head1 SEE ALSO
145  
146 L<Lingua::Interset>,
147 L<Lingua::Interset::Tagset>,
148 L<Lingua::Interset::Tagset::CS::Pdt>,
149 L<Lingua::Interset::FeatureStructure>
150  
151 =head1 AUTHOR
152  
153 Dan Zeman <zeman@ufal.mff.cuni.cz>
154  
155 =head1 COPYRIGHT AND LICENSE
156  
157 This software is copyright (c) 2019 by Univerzita Karlova (Charles University).
158  
159 This is free software; you can redistribute it and/or modify it under
160 the same terms as the Perl 5 programming language system itself.
161  
162 =cut