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