| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Treex::Block::Read::BaseAlignedTextReader; |
|
2
|
|
|
|
|
|
|
$Treex::Block::Read::BaseAlignedTextReader::VERSION = '0.13095'; |
|
3
|
1
|
|
|
1
|
|
567
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
37
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
23
|
|
|
5
|
1
|
|
|
1
|
|
189
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Treex::Core::Common; |
|
7
|
|
|
|
|
|
|
extends 'Treex::Block::Read::BaseAlignedReader'; |
|
8
|
|
|
|
|
|
|
use File::Slurp; |
|
9
|
|
|
|
|
|
|
use Data::Dumper; |
|
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
|
|
|
|
|
|
|
sub next_document_texts { |
|
23
|
|
|
|
|
|
|
my ($self) = @_; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#print STDERR __PACKAGE__ . ":" . __LINE__ . "\n"; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $filenames = $self->next_filenames(); |
|
28
|
|
|
|
|
|
|
return if ! $filenames; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my %mapping = %{$filenames}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
foreach my $lang ( keys %mapping ) { |
|
37
|
|
|
|
|
|
|
my $filename = $mapping{$lang}; |
|
38
|
|
|
|
|
|
|
if ( $filename eq '-' ) { |
|
39
|
|
|
|
|
|
|
$texts{$lang} = read_file( \*STDIN ); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
else { |
|
42
|
|
|
|
|
|
|
$texts{$lang} = read_file( $filename, binmode => 'encoding(utf8)', err_mode => 'log_fatal' ); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return \%texts; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
1; |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
__END__ |