Block/Read/BaseAlignedTextReader.pm

filter: Statementstmt 96.9% 32 / 33 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 1 / 1 totaltotal 93.3% 42 / 45 CC 4 SCAR 8.1
CC
4
Cov
92%
next_document_texts
4.1
BEGIN
1.0
BEGIN
1.0
CRAP 2.2
« Block/W2A/TokenizeOnWhitespace.pm ↑ Summary Block/W2A/Tokenize.pm »
1 package Treex::Block::Read::BaseAlignedTextReader;
2 4 $Treex::Block::Read::BaseAlignedTextReader::VERSION = '2.20151102';
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use Treex::Core::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 extends 'Treex::Block::Read::BaseAlignedReader';
8 4 ▶use File::Slurp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 #has lines_per_doc => ( isa => 'Int', is => 'ro', default => 0 );
12 #has merge_files => ( isa => 'Bool', is => 'ro', default => 0 );
13  
14 #sub BUILD {
15 # my ($self) = @_;
16 # if ( $self->lines_per_doc ) {
17 # $self->set_is_one_doc_per_file(0);
18 # }
19 # return;
20 #}
21  
22 2 ▶sub next_document_texts {
Subroutine next_document_texts: called CC=4 SCAR=14.1
Pod documented
23 2 my ($self) = @_;
24  
25 #print STDERR __PACKAGE__ . ":" . __LINE__ . "\n";
26  
27 2 my $filenames = $self->next_filenames();
28 2 ▶ return if ! $filenames;
Branch: 1 branch
BranchTrueFalseTotal
unless $filenames 0 2 2
29  
30 2 my %mapping = %{$filenames};
31  
32 2 my %texts;
33 # if ( $self->lines_per_doc ) { # TODO: option lines_per_document not implemented
34 # log_fatal "option lines_per_document not implemented for aligned readers yet";
35 # }
36 2 foreach my $lang ( keys %mapping ) {
37 4 my $filename = $mapping{$lang};
38 4 ▶ if ( $filename eq '-' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename eq '-') { } 0 4 4
39 0 $texts{$lang} = read_file( \*STDIN );
40 }
41 else {
42 4 $texts{$lang} = read_file( $filename, binmode => 'encoding(utf8)', err_mode => 'log_fatal' );
43 }
44 }
45  
46 2 return \%texts;
47 }
48  
49 4 1;
50  
51 __END__
« Block/W2A/TokenizeOnWhitespace.pm ↑ Summary Block/W2A/Tokenize.pm »