File Coverage

blib/lib/Lingua/YaTeA/TriggerSet.pm
Criterion Covered Total %
statement 27 27 100.0
branch 3 4 75.0
condition n/a
subroutine 6 6 100.0
pod 4 4 100.0
total 40 41 97.5


line stmt bran cond sub pod time code
1             package Lingua::YaTeA::TriggerSet;
2 5     5   61 use strict;
  5         9  
  5         144  
3 5     5   26 use warnings;
  5         10  
  5         1419  
4              
5             our $VERSION=$Lingua::YaTeA::VERSION;
6              
7             sub new
8             {
9 8     8 1 19 my ($class) = @_;
10 8         18 my $this = {};
11 8         14 bless ($this,$class);
12 8         27 $this->{IF} = {};
13 8         17 $this->{POS} = {};
14 8         15 $this->{LF} = {};
15 8         26 return $this;
16             }
17              
18             sub addTrigger
19             {
20 28     28 1 54 my ($this,$fs) = @_;
21 28         66 my $trigger = $fs->getFirstItem;
22 28         50 push @{$this->getSubset($trigger->getType)->{$trigger->getForm}}, $fs;
  28         88  
23             }
24              
25              
26              
27             sub getSubset
28             {
29 1487     1487 1 2438 my ($this,$type) = @_;
30 1487         3355 return $this->{$type};
31             }
32              
33             sub findTrigger
34             {
35 248     248 1 435 my ($this,$word) = @_;
36 248         515 my @types = ("IF","POS","LF");
37 248         343 my $type;
38 248         411 foreach $type (@types)
39             {
40 715 50       1232 if(defined $this->getSubset($type))
41             {
42 715 100       1143 if(exists $this->getSubset($type)->{$word->getLexItem->{$type}})
43             {
44 29         64 return $this->getSubset($type)->{$word->getLexItem->{$type}};
45             }
46             }
47             }
48 219         742 return;
49             }
50              
51              
52             1;
53             __END__