File Coverage

blib/lib/Lingua/YaTeA/WordOccurrence.pm
Criterion Covered Total %
statement 60 62 96.7
branch 29 34 85.2
condition 11 18 61.1
subroutine 10 10 100.0
pod 5 5 100.0
total 115 129 89.1


line stmt bran cond sub pod time code
1             package Lingua::YaTeA::WordOccurrence;
2 3     3   19 use strict;
  3         8  
  3         80  
3 3     3   16 use warnings;
  3         6  
  3         73  
4 3     3   401 use Lingua::YaTeA::ChunkingDataSet;
  3         8  
  3         26  
5 3     3   67 use UNIVERSAL;
  3         16  
  3         12  
6 3     3   103 use Scalar::Util qw(blessed);
  3         7  
  3         1836  
7              
8             our $VERSION=$Lingua::YaTeA::VERSION;
9              
10             sub new
11             {
12 616     616 1 948 my ($class,$form) = @_;
13 616         1062 my $this = {};
14 616         1086 bless ($this,$class);
15 616         1109 $this->{FORM} = $this->setForm($form);
16 616         1350 return $this;
17             }
18              
19             sub setForm
20             {
21 616     616 1 1060 my ($this,$form) = @_;
22 616         1579 $this->{FORM} = $form;
23             }
24              
25             sub getForm
26             {
27 612     612 1 1070 my ($this,$form) = @_;
28 612         2612 return $this->{FORM};
29             }
30              
31             sub isChunkEnd
32             {
33 612     612 1 1359 my ($this,$action,$split_after,$sentence_boundary,$document_boundary,$chunking_data) = @_;
34            
35 612 100 66     2622 if ((blessed($this)) && ($this->isa("Lingua::YaTeA::WordFromCorpus")))
36             {
37 594 100       1234 if ($Lingua::YaTeA::Corpus::tt_counter != 0){ # word is between testified term frontiers: not end
38 6         20 return 0;
39             }
40 588         863 $$split_after--;
41 588 100       1092 if($$split_after == 0)
42             {
43 2         9 return 1;
44             }
45 586 100 66     1327 if ( # word is a sentence or document boundary : end
46             ($this->isSentenceBoundary($sentence_boundary) == 1)
47             ||
48             ($this->isDocumentBoundary($document_boundary) == 1)
49             )
50             {
51 18         69 return 1;
52             }
53             # Test if word is a chunking frontier
54 568 100       1327 if ($this->isChunkingFrontier($chunking_data))
55             {
56 214 50       421 if($Lingua::YaTeA::Corpus::tt_counter == 0)
57             {
58 214         782 return 1;
59             }
60             }
61              
62             }
63             else{
64 18 100 66     114 if ((blessed($this)) && ($this->isa("Lingua::YaTeA::ForbiddenStructureMark")))
65             {
66 12 100       43 if ($this->isOpener)
67             {
68 6         11 $Lingua::YaTeA::Corpus::forbidden_counter ++;
69 6         19 $$action = $this->getAction;
70 6 100       20 if($$action eq "split")
71             {
72            
73 2         12 $$split_after = $this->getSplitAfter +1;
74             }
75             }
76             else{
77 6 50       21 if ($this->isCloser)
78             {
79 6         13 $Lingua::YaTeA::Corpus::forbidden_counter --;
80 6 100 66     26 if (($Lingua::YaTeA::Corpus::tt_counter == 0) && ($this->getAction ne "split")) {
81             # warn "==>1\n";
82 4         20 return 1;
83             } else {
84 2         9 return(0);
85             }
86             }
87             else{
88 0         0 die "erreur\n";
89             }
90             }
91             }
92             else
93             {
94 6 50 33     34 if ((blessed($this)) && ($this->isa('Lingua::YaTeA::TestifiedTermMark'))) {
95 6 100       17 if ($this->isOpener)
96             {
97 3         7 $Lingua::YaTeA::Corpus::tt_counter++;
98             }
99             else
100             {
101 3 50       9 if ($this->isCloser)
102             {
103 3         7 $Lingua::YaTeA::Corpus::tt_counter--;
104             }
105             }
106 6         24 return 0;
107             }
108             }
109             }
110            
111 360 100 66     1669 if( # word is in a forbidden structure but out of testified term frontiers: end
112             ($Lingua::YaTeA::Corpus::forbidden_counter != 0)
113             &&
114             ($Lingua::YaTeA::Corpus::tt_counter == 0)
115             )
116             {
117 12 100       32 if ($$action eq "delete")
118             {
119 8         39 return 1;
120             }
121             else{
122            
123             # $Lingua::YaTeA::Corpus::split_counter--;
124             # if($Lingua::YaTeA::Corpus::split_counter == 0)
125            
126             #return 0;
127             }
128 4         16 return 0;
129             }
130              
131              
132             }
133              
134             sub print
135             {
136 612     612 1 1055 my ($this,$fh) = @_;
137 612 50       1107 if(defined $fh)
138             {
139 612         1270 print $fh $this->getForm . "\n";
140             }
141             else
142             {
143 0           print $this->getForm . "\n";
144             }
145             }
146              
147             1;
148              
149             __END__