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   16 use strict;
  3         6  
  3         67  
3 3     3   12 use warnings;
  3         4  
  3         56  
4 3     3   361 use Lingua::YaTeA::ChunkingDataSet;
  3         7  
  3         21  
5 3     3   54 use UNIVERSAL;
  3         13  
  3         10  
6 3     3   85 use Scalar::Util qw(blessed);
  3         6  
  3         1472  
7              
8             our $VERSION=$Lingua::YaTeA::VERSION;
9              
10             sub new
11             {
12 616     616 1 814 my ($class,$form) = @_;
13 616         868 my $this = {};
14 616         1190 bless ($this,$class);
15 616         941 $this->{FORM} = $this->setForm($form);
16 616         1082 return $this;
17             }
18              
19             sub setForm
20             {
21 616     616 1 788 my ($this,$form) = @_;
22 616         1299 $this->{FORM} = $form;
23             }
24              
25             sub getForm
26             {
27 612     612 1 850 my ($this,$form) = @_;
28 612         2034 return $this->{FORM};
29             }
30              
31             sub isChunkEnd
32             {
33 612     612 1 1095 my ($this,$action,$split_after,$sentence_boundary,$document_boundary,$chunking_data) = @_;
34            
35 612 100 66     2285 if ((blessed($this)) && ($this->isa("Lingua::YaTeA::WordFromCorpus")))
36             {
37 594 100       1038 if ($Lingua::YaTeA::Corpus::tt_counter != 0){ # word is between testified term frontiers: not end
38 6         17 return 0;
39             }
40 588         696 $$split_after--;
41 588 100       895 if($$split_after == 0)
42             {
43 2         8 return 1;
44             }
45 586 100 66     1032 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         54 return 1;
52             }
53             # Test if word is a chunking frontier
54 568 100       995 if ($this->isChunkingFrontier($chunking_data))
55             {
56 214 50       342 if($Lingua::YaTeA::Corpus::tt_counter == 0)
57             {
58 214         623 return 1;
59             }
60             }
61              
62             }
63             else{
64 18 100 66     92 if ((blessed($this)) && ($this->isa("Lingua::YaTeA::ForbiddenStructureMark")))
65             {
66 12 100       36 if ($this->isOpener)
67             {
68 6         11 $Lingua::YaTeA::Corpus::forbidden_counter ++;
69 6         13 $$action = $this->getAction;
70 6 100       18 if($$action eq "split")
71             {
72            
73 2         8 $$split_after = $this->getSplitAfter +1;
74             }
75             }
76             else{
77 6 50       16 if ($this->isCloser)
78             {
79 6         15 $Lingua::YaTeA::Corpus::forbidden_counter --;
80 6 100 66     23 if (($Lingua::YaTeA::Corpus::tt_counter == 0) && ($this->getAction ne "split")) {
81             # warn "==>1\n";
82 4         15 return 1;
83             } else {
84 2         10 return(0);
85             }
86             }
87             else{
88 0         0 die "erreur\n";
89             }
90             }
91             }
92             else
93             {
94 6 50 33     28 if ((blessed($this)) && ($this->isa('Lingua::YaTeA::TestifiedTermMark'))) {
95 6 100       17 if ($this->isOpener)
96             {
97 3         5 $Lingua::YaTeA::Corpus::tt_counter++;
98             }
99             else
100             {
101 3 50       7 if ($this->isCloser)
102             {
103 3         6 $Lingua::YaTeA::Corpus::tt_counter--;
104             }
105             }
106 6         19 return 0;
107             }
108             }
109             }
110            
111 360 100 66     1356 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       25 if ($$action eq "delete")
118             {
119 8         32 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         12 return 0;
129             }
130              
131              
132             }
133              
134             sub print
135             {
136 612     612 1 827 my ($this,$fh) = @_;
137 612 50       890 if(defined $fh)
138             {
139 612         1004 print $fh $this->getForm . "\n";
140             }
141             else
142             {
143 0           print $this->getForm . "\n";
144             }
145             }
146              
147             1;
148              
149             __END__