Block/Read/BaseAlignedTextReader.pm

filter: Statementstmt 57.1% 12 / 21 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 80.0% 4 / 5 Podpod 100% 1 / 1 totaltotal 54.8% 17 / 31 CC 4 SCAR 23.5
CC
4
Cov
48%
next_document_texts
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 10.5
« Block/W2A/TokenizeOnWhitespace.pm ↑ Summary Block/W2A/Tokenize.pm »
1 package Treex::Block::Read::BaseAlignedTextReader;
2 BEGIN {
3 4 ▶ $Treex::Block::Read::BaseAlignedTextReader::VERSION = '0.06903_1';
Subroutine BEGIN: called CC=1 SCAR=0.0
4 }
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  
10 #has lines_per_doc => ( isa => 'Int', is => 'ro', default => 0 );
11 #has merge_files => ( isa => 'Bool', is => 'ro', default => 0 );
12  
13 #sub BUILD {
14 # my ($self) = @_;
15 # if ( $self->lines_per_doc ) {
16 # $self->set_is_one_doc_per_file(0);
17 # }
18 # return;
19 #}
20  
21 sub next_document_texts {
22 0 ▶ my ($self) = @_;
Subroutine next_document_texts: not called CC=4 SCAR=30.0
Pod documented
23  
24 0 ▶ my %mapping = $self->next_filenames() or return;
Branch: 1 branch
BranchTrueFalseTotal
my(%mapping) = $self->next_filenames or return 0 0 0
25 0 my %texts;
26 # if ( $self->lines_per_doc ) { # TODO: option lines_per_document not implemented
27 # log_fatal "option lines_per_document not implemented for aligned readers yet";
28 # }
29 0 foreach my $lang ( keys %mapping ) {
30 0 my $filename = $mapping{$lang};
31 0 ▶ if ( $filename eq '-' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($filename eq '-') { } 0 0 0
32 0 $texts{$lang} = read_file( \*STDIN );
33 }
34 else {
35 0 $texts{$lang} = read_file( $filename, binmode => 'encoding(utf8)', err_mode => 'log_fatal' );
36 }
37 }
38  
39 0 return \%texts;
40 }
41  
42 4 1;
43  
44 __END__
45  
46 =for Pod::Coverage BUILD
47  
48 =head1 NAME
49  
50 Treex::Block::Read::BaseAlignedTextReader - abstract ancestor for parallel-corpora document readers
51  
52 =head1 VERSION
53  
54 version 0.06903_1
55  
56 =head1 DESCRIPTION
57  
58 This class serves as an common ancestor for document readers,
59 that have parameter C<from> with a space or comma separated list of filenames
60 to be loaded and load the documents from plain text files.
61 It is designed to implement the L<Treex::Core::DocumentReader> interface.
62  
63 In derived classes you need to define the C<next_document> method,
64 and you can use C<next_document_texts> and C<new_document> methods.
65  
66 =head1 METHODS
67  
68 =over
69  
70 =item next_document_texts
71  
72 Returns a hashref, where keys are zone labels and values
73 are strings representing contents of the files.
74  
75 =back
76  
77 =head1 SEE
78  
79 L<Treex::Block::Read::BaseAlignedReader>
80 L<Treex::Block::Read::AlignedSentences>
81  
82 =head1 AUTHOR
83  
84 Martin Popel
85  
86 =head1 COPYRIGHT AND LICENSE
87  
88 Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague
89  
90 This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
« Block/W2A/TokenizeOnWhitespace.pm ↑ Summary Block/W2A/Tokenize.pm »