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   54 use strict;
  5         10  
  5         139  
3 5     5   22 use warnings;
  5         7  
  5         1171  
4              
5             our $VERSION=$Lingua::YaTeA::VERSION;
6              
7             sub new
8             {
9 8     8 1 15 my ($class) = @_;
10 8         12 my $this = {};
11 8         14 bless ($this,$class);
12 8         19 $this->{IF} = {};
13 8         13 $this->{POS} = {};
14 8         13 $this->{LF} = {};
15 8         18 return $this;
16             }
17              
18             sub addTrigger
19             {
20 28     28 1 45 my ($this,$fs) = @_;
21 28         47 my $trigger = $fs->getFirstItem;
22 28         38 push @{$this->getSubset($trigger->getType)->{$trigger->getForm}}, $fs;
  28         66  
23             }
24              
25              
26              
27             sub getSubset
28             {
29 1487     1487 1 1865 my ($this,$type) = @_;
30 1487         2507 return $this->{$type};
31             }
32              
33             sub findTrigger
34             {
35 248     248 1 346 my ($this,$word) = @_;
36 248         387 my @types = ("IF","POS","LF");
37 248         273 my $type;
38 248         335 foreach $type (@types)
39             {
40 715 50       991 if(defined $this->getSubset($type))
41             {
42 715 100       932 if(exists $this->getSubset($type)->{$word->getLexItem->{$type}})
43             {
44 29         42 return $this->getSubset($type)->{$word->getLexItem->{$type}};
45             }
46             }
47             }
48 219         599 return;
49             }
50              
51              
52             1;
53             __END__