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   21 use strict;
  3         6  
  3         85  
3 3     3   15 use warnings;
  3         8  
  3         2044  
4              
5             our $counter =0;
6              
7             our $VERSION=$Lingua::YaTeA::VERSION;
8              
9             sub new
10             {
11 600     600 1 974 my ($class,$form) = @_;
12 600         1015 my $this = {};
13 600         913 bless ($this,$class);
14 600         1151 $this->{ID} = $counter;
15 600         2383 my @lex_infos = split /\t/, $form;
16 600         1285 $this->{IF} = $lex_infos[0];
17 600         1060 $this->{POS} = $lex_infos[1];
18 600         1226 $this->{LF} = $this->setLF($lex_infos[2],$this->{IF});
19 600         1231 $this->{LENGTH} = $this->setLength;
20 600         1015 $this->{FREQUENCY} = 0;
21 600         1510 return $this;
22             }
23              
24              
25             sub setLF
26             {
27 600     600 1 1296 my ($this,$LF,$IF) = @_;
28 600 50       1049 if (defined $LF) {
29 600 50       1508 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         1441 return $LF;
36             }
37              
38             sub setLength
39             {
40 600     600 1 1005 my ($this) = @_;
41 600         1460 return length($this->{IF});
42             }
43              
44             sub incrementFrequency
45             {
46 600     600 1 971 my ($this) = @_;
47 600         1259 $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 13417 my ($this) = @_;
59 8105         24370 return $this->{IF};
60             }
61              
62             sub getPOS
63             {
64 6618     6618 1 11491 my ($this) = @_;
65 6618         19186 return $this->{POS};
66             }
67              
68             sub getLF
69             {
70 9249     9249 1 14959 my ($this) = @_;
71 9249         27701 return $this->{LF};
72             }
73              
74             sub getLength
75             {
76 1115     1115 1 1903 my ($this) = @_;
77 1115         2809 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 30687 my ($this,$field) = @_;
89 18578         47985 return $this->{$field};
90             }
91              
92             sub isCleaningFrontier
93             {
94 4814     4814 1 8882 my ($this,$chunking_data) = @_;
95 4814         9391 my @types = ("POS", "LF", "IF");
96 4814         6537 my $type;
97 4814         8485 foreach $type (@types)
98             {
99 6362 100       11556 if ($chunking_data->existData("CleaningFrontiers",$type,$this->getAny($type)) == 1)
100             {
101 4040 50       8284 if (! $this->isCleaningException($chunking_data))
102             {
103 4040         16857 return 1;
104             }
105             }
106             }
107 774         4198 return 0;
108             }
109              
110             sub isCleaningException
111             {
112 4040     4040 1 6645 my ($this,$chunking_data) = @_;
113 4040         7948 my @types = ("POS", "LF", "IF");
114 4040         5663 my $type;
115 4040         6429 foreach $type (@types)
116             {
117 12120 50       21838 if ($chunking_data->existData("CleaningExceptions",$type,$this->getAny($type)) == 1)
118             {
119 0         0 return 1;
120             }
121             }
122 4040         9354 return 0;
123             }
124              
125             1;
126              
127             __END__