File Coverage

blib/lib/Lingua/YaTeA/LexiconItem.pm
Criterion Covered Total %
statement 49 56 87.5
branch 6 10 60.0
condition n/a
subroutine 13 15 86.6
pod 13 13 100.0
total 81 94 86.1


line stmt bran cond sub pod time code
1             package Lingua::YaTeA::LexiconItem;
2 3     3   17 use strict;
  3         5  
  3         111  
3 3     3   14 use warnings;
  3         5  
  3         1642  
4              
5             our $counter =0;
6              
7             our $VERSION=$Lingua::YaTeA::VERSION;
8              
9             sub new
10             {
11 600     600 1 810 my ($class,$form) = @_;
12 600         774 my $this = {};
13 600         724 bless ($this,$class);
14 600         935 $this->{ID} = $counter;
15 600         1697 my @lex_infos = split /\t/, $form;
16 600         998 $this->{IF} = $lex_infos[0];
17 600         818 $this->{POS} = $lex_infos[1];
18 600         973 $this->{LF} = $this->setLF($lex_infos[2],$this->{IF});
19 600         922 $this->{LENGTH} = $this->setLength;
20 600         855 $this->{FREQUENCY} = 0;
21 600         1105 return $this;
22             }
23              
24              
25             sub setLF
26             {
27 600     600 1 899 my ($this,$LF,$IF) = @_;
28 600 50       836 if (defined $LF) {
29 600 50       1252 if ($LF =~ /(\)|(\@card@)/){ # si le lemme est inconnu du tagger (TTG) : lemme = forme flechie
30 0         0 return $IF;
31             }
32             } else {
33 0         0 $LF = "";
34             }
35 600         1159 return $LF;
36             }
37              
38             sub setLength
39             {
40 600     600 1 780 my ($this) = @_;
41 600         1248 return length($this->{IF});
42             }
43              
44             sub incrementFrequency
45             {
46 600     600 1 764 my ($this) = @_;
47 600         899 $this->{FREQUENCY}++;
48             }
49              
50             sub getID
51             {
52 0     0 1 0 my ($this) = @_;
53 0         0 return $this->{ID};
54             }
55              
56             sub getIF
57             {
58 8105     8105 1 10175 my ($this) = @_;
59 8105         18315 return $this->{IF};
60             }
61              
62             sub getPOS
63             {
64 6618     6618 1 8405 my ($this) = @_;
65 6618         15066 return $this->{POS};
66             }
67              
68             sub getLF
69             {
70 9249     9249 1 11555 my ($this) = @_;
71 9249         21260 return $this->{LF};
72             }
73              
74             sub getLength
75             {
76 1115     1115 1 1398 my ($this) = @_;
77 1115         2223 return $this->{LENGTH};
78             }
79              
80             sub getFrequency
81             {
82 0     0 1 0 my ($this) = @_;
83 0         0 return $this->{FREQUENCY};
84             }
85              
86             sub getAny
87             {
88 18578     18578 1 24249 my ($this,$field) = @_;
89 18578         36905 return $this->{$field};
90             }
91              
92             sub isCleaningFrontier
93             {
94 4814     4814 1 7208 my ($this,$chunking_data) = @_;
95 4814         7783 my @types = ("POS", "LF", "IF");
96 4814         5337 my $type;
97 4814         6657 foreach $type (@types)
98             {
99 6362 100       9457 if ($chunking_data->existData("CleaningFrontiers",$type,$this->getAny($type)) == 1)
100             {
101 4040 50       6259 if (! $this->isCleaningException($chunking_data))
102             {
103 4040         13134 return 1;
104             }
105             }
106             }
107 774         3177 return 0;
108             }
109              
110             sub isCleaningException
111             {
112 4040     4040 1 5290 my ($this,$chunking_data) = @_;
113 4040         6217 my @types = ("POS", "LF", "IF");
114 4040         4392 my $type;
115 4040         5131 foreach $type (@types)
116             {
117 12120 50       16858 if ($chunking_data->existData("CleaningExceptions",$type,$this->getAny($type)) == 1)
118             {
119 0         0 return 1;
120             }
121             }
122 4040         7424 return 0;
123             }
124              
125             1;
126              
127             __END__