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   34 use strict;
  5         11  
  5         145  
3 5     5   27 use warnings;
  5         8  
  5         127  
4 5     5   2005 use Lingua::YaTeA::ChunkingDataSubset;
  5         14  
  5         56  
5              
6             our $VERSION=$Lingua::YaTeA::VERSION;
7              
8              
9             sub new
10             {
11 4     4 1 18 my ($class,$file_set) = @_;
12 4         13 my $this = {};
13 4         12 bless ($this,$class);
14 4         39 $this->{ChunkingFrontiers} = Lingua::YaTeA::ChunkingDataSubset->new;
15 4         17 $this->{ChunkingExceptions} = Lingua::YaTeA::ChunkingDataSubset->new;
16 4         17 $this->{CleaningFrontiers} = Lingua::YaTeA::ChunkingDataSubset->new;
17 4         15 $this->{CleaningExceptions} = Lingua::YaTeA::ChunkingDataSubset->new;
18            
19 4         20 $this->loadData($file_set);
20 4         170 return $this;
21             }
22              
23              
24             sub loadData
25             {
26 4     4 1 13 my ($this,$file_set) = @_;
27 4         38 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         17 my @file_names = ("ChunkingFrontiers","ChunkingExceptions","CleaningFrontiers","CleaningExceptions");
34 4         13 foreach $name (@file_names)
35             {
36 16         533 $path = $file_set->getFile($name)->getPath;
37            
38 16         47 $subset = $this->getSubset($name);
39            
40 16         118 my $fh = FileHandle->new("<$path");
41              
42 16         1899 while ($line= $fh->getline)
43             {
44 276 50 66     7728 if(($line !~ /^#/)&&($line !~ /^\s*$/))
45             {
46 244         432 $line =~ s/\r//g;
47 244         353 chomp $line;
48 244         683 $line =~ /([^\t]+)\t([^\t]+)/;
49 244         479 $type= $1;
50 244         354 $value = $2;
51 244         596 $subset->addSome($type,$value);
52             }
53             }
54            
55             }
56             }
57              
58             sub getSubset
59             {
60 21640     21640 1 32756 my ($this,$name) = @_;
61 21640         49757 return $this->{$name};
62             }
63              
64              
65             sub existData
66             {
67 21624     21624 1 38406 my ($this,$set,$type,$data) = @_;
68 21624         35601 return $this->getSubset($set)->existData($type,$data);
69             }
70              
71             1;
72              
73             __END__