Interset/Tagset/SV/Conll.pm untested

filter: Statementstmt 0.0% 0 / 36 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 48 CC 1 SCAR 6.9
CC
1
Cov
0%
decode
2.0
encode
2.0
list
2.0
CRAP 2.0
1 # ABSTRACT: Driver for the tagset of the Swedish treebank from the CoNLL 2006 Shared Task (Talbanken / Mamba).
2 # Copyright © 2006, 2015 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::Conll;
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::Tagset::SV::Mamba';
15  
16  
17  
18 #------------------------------------------------------------------------------
19 # Decodes a physical tag (string) and returns the corresponding feature
20 # structure. In addition to Atom, we just need to identify the tagset of
21 # origin.
22 #------------------------------------------------------------------------------
23 sub decode
24 {
25 my $self = shift;
26 my $tag = shift;
27 $tag =~ s/\t.*//;
28 my $fs = $self->SUPER::decode($tag);
29 return $fs;
30 }
31  
32  
33  
34 #------------------------------------------------------------------------------
35 # Takes feature hash.
36 # Returns tag string.
37 #------------------------------------------------------------------------------
38 sub encode
39 {
40 my $self = shift;
41 my $fs = shift; # Lingua::Interset::FeatureStructure
42 my $tag = $self->SUPER::encode($fs);
43 return "$tag\t$tag\t_";
44 }
45  
46  
47  
48 #------------------------------------------------------------------------------
49 # Returns reference to list of known tags.
50 # cat otrain.conll etest.conll | perl -pe '@x = split(/\s+/, $_); $_ = "$x[3]\n"' | sort -u | wc -l
51 # 42
52 #------------------------------------------------------------------------------
53 sub list
54 {
55 my $self = shift;
56 my $list = $self->SUPER::list();
57 my @list = map {"$_\t$_\t_"} @{$list};
58 return \@list;
59 }
60  
61  
62  
63 1;
64  
65 __END__
66  
67 =pod
68  
69 =encoding UTF-8
70  
71 =head1 NAME
72  
73 Lingua::Interset::Tagset::SV::Conll - Driver for the tagset of the Swedish treebank from the CoNLL 2006 Shared Task (Talbanken / Mamba).
74  
75 =head1 VERSION
76  
77 version 3.014
78  
79 =head1 SYNOPSIS
80  
81 use Lingua::Interset::Tagset::SV::Conll;
82 my $driver = Lingua::Interset::Tagset::SV::Conll->new();
83 my $fs = $driver->decode("NN\tNN\t_");
84  
85 or
86  
87 use Lingua::Interset qw(decode);
88 my $fs = decode('sv::conll', "NN\tNN\t_");
89  
90 =head1 DESCRIPTION
91  
92 Interset driver for the tagset of the Swedish treebank (Talbanken) from the CoNLL 2006 Shared Task.
93 It was derived from the two-letter tags of the Mamba tagset.
94 The sv::conll driver only handles a slight change in formatting.
95 CoNLL tagsets in Interset are traditionally three values separated by tabs.
96 The values come from the CoNLL columns CPOS, POS and FEAT.
97  
98 =head1 SEE ALSO
99  
100 L<Lingua::Interset>
101 L<Lingua::Interset::Tagset>,
102 L<Lingua::Interset::Tagset::SV::Mamba>,
103 L<Lingua::Interset::FeatureStructure>
104  
105 =head1 AUTHOR
106  
107 Dan Zeman <zeman@ufal.mff.cuni.cz>
108  
109 =head1 COPYRIGHT AND LICENSE
110  
111 This software is copyright (c) 2019 by Univerzita Karlova (Charles University).
112  
113 This is free software; you can redistribute it and/or modify it under
114 the same terms as the Perl 5 programming language system itself.
115  
116 =cut