File Coverage

blib/lib/Lingua/YaTeA/ChunkingDataSet.pm
Criterion Covered Total %
statement 41 41 100.0
branch 1 2 50.0
condition 2 3 66.6
subroutine 7 7 100.0
pod 4 4 100.0
total 55 57 96.4


line stmt bran cond sub pod time code
1             package Lingua::YaTeA::ChunkingDataSet;
2 5     5   36 use strict;
  5         38  
  5         142  
3 5     5   25 use warnings;
  5         11  
  5         120  
4 5     5   2081 use Lingua::YaTeA::ChunkingDataSubset;
  5         45  
  5         55  
5              
6             our $VERSION=$Lingua::YaTeA::VERSION;
7              
8              
9             sub new
10             {
11 4     4 1 17 my ($class,$file_set) = @_;
12 4         13 my $this = {};
13 4         13 bless ($this,$class);
14 4         40 $this->{ChunkingFrontiers} = Lingua::YaTeA::ChunkingDataSubset->new;
15 4         18 $this->{ChunkingExceptions} = Lingua::YaTeA::ChunkingDataSubset->new;
16 4         18 $this->{CleaningFrontiers} = Lingua::YaTeA::ChunkingDataSubset->new;
17 4         18 $this->{CleaningExceptions} = Lingua::YaTeA::ChunkingDataSubset->new;
18            
19 4         22 $this->loadData($file_set);
20 4         179 return $this;
21             }
22              
23              
24             sub loadData
25             {
26 4     4 1 13 my ($this,$file_set) = @_;
27 4         35 my $name;
28             my $path;
29 4         0 my $subset;
30 4         0 my $line;
31 4         0 my $type;
32 4         0 my $value;
33 4         20 my @file_names = ("ChunkingFrontiers","ChunkingExceptions","CleaningFrontiers","CleaningExceptions");
34 4         13 foreach $name (@file_names)
35             {
36 16         572 $path = $file_set->getFile($name)->getPath;
37            
38 16         46 $subset = $this->getSubset($name);
39            
40 16         125 my $fh = FileHandle->new("<$path");
41              
42 16         1926 while ($line= $fh->getline)
43             {
44 276 50 66     7772 if(($line !~ /^#/)&&($line !~ /^\s*$/))
45             {
46 244         462 $line =~ s/\r//g;
47 244         353 chomp $line;
48 244         686 $line =~ /([^\t]+)\t([^\t]+)/;
49 244         482 $type= $1;
50 244         383 $value = $2;
51 244         602 $subset->addSome($type,$value);
52             }
53             }
54            
55             }
56             }
57              
58             sub getSubset
59             {
60 21640     21640 1 34866 my ($this,$name) = @_;
61 21640         49584 return $this->{$name};
62             }
63              
64              
65             sub existData
66             {
67 21624     21624 1 41847 my ($this,$set,$type,$data) = @_;
68 21624         37702 return $this->getSubset($set)->existData($type,$data);
69             }
70              
71             1;
72              
73             __END__