Treex/Block/Read/BaseTextReader.pm

filter: Statementstmt 69.7% 23 / 33 Branchbran 30.0% 3 / 10 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod 50.0% 1 / 2 totaltotal 58.1% 32 / 55 CC 8 SCAR 25.9
CC
8
Cov
57%
next_document_text
24.4
BUILD
3.6
BEGIN
1.0
CRAP 13.4
« Treex/Block/Write/Sentences.pm ↑ Summary Treex/Core/DocumentReader.pm »
1 package Treex::Block::Read::BaseTextReader;
2 5 $Treex::Block::Read::BaseTextReader::VERSION = '2.20210102';
3 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use Treex::Core::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 extends 'Treex::Block::Read::BaseReader';
6 #use File::Slurp 9999;
7 5 ▶use PerlIO::via::gzip;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 # By default read from STDIN
10 5 has '+from' => (
11 default => '-',
12 handles => [qw(current_filename current_filehandle file_number _set_file_number next_filehandle)],
13 );
14  
15 5 has lines_per_doc => ( isa => 'Int', is => 'ro', default => 0 );
16 5 has merge_files => ( isa => 'Bool', is => 'ro', default => 0 );
17 5 has encoding => ( isa => 'Str', is => 'ro', default => 'utf8' );
18  
19 8 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=12.7
Pod undocumented
20 8 my ($self) = @_;
21 8 ▶ if ( $self->lines_per_doc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->lines_per_doc) 0 8 8
22 0 $self->set_is_one_doc_per_file(0);
23 }
24 8 ▶ if ($self->encoding ne 'utf8'){
Branch: 1 branch
BranchTrueFalseTotal
if ($self->encoding ne "utf8") 0 8 8
25 0 $self->from->set_encoding($self->encoding);
26 }
27 8 return;
28 }
29  
30 2 ▶sub next_document_text {
Subroutine next_document_text: called CC=6 SCAR=32.0
Pod documented
31 2 my ($self) = @_;
32 2 ▶ if ( $self->is_one_doc_per_file ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_one_doc_per_file) 2 0 2
33 2 return $self->from->next_file_text();
34 }
35  
36 0 my $text = '';
37 LINE:
38 0 for my $line ( 1 .. $self->lines_per_doc ) {
39 0 $line = $self->from->next_line();
40 0 ▶ if (!defined $line){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $line) 0 0 0
41 0 ▶ return if $text eq '' && !$self->from->has_next_file();
Branch: 1 branch
BranchTrueFalseTotal
if $text eq "" and not $self->from->has_next_file 0 0 0
Condition0%0/3
$text eq "" and not $self->from->has_next_file
!ll&&!rl&&r
000
MC/DC0%0/2
$text eq "" and not $self->from->has_next_file
$text eq "" not $self->from->has_next_file
Truth table0%0/3
A and not(B)
A= $text eq ""B= not $self->from->has_next_file
ABresult
0X0
100
111
42 0 last LINE;
43 }
44
45 0 $text .= $line;
46 }
47 0 return $text;
48 }
49  
50 5 1;
51  
52 __END__
« Treex/Block/Write/Sentences.pm ↑ Summary Treex/Core/DocumentReader.pm »