Treex/Block/Read/BaseSplitterRole.pm

filter: Statementstmt 48.6% 18 / 37 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 4 / 6 Podpod n/a totaltotal 41.5% 22 / 53 CC 6 SCAR 27.1
CC
6
Cov
38%
__ANON__
30.0
__ANON__
6.0
BEGIN
1.0
CRAP 15.1
« Treex/Core/TredView/Colors.pm ↑ Summary Treex/Block/Write/BaseWriter.pm »
1 package Treex::Block::Read::BaseSplitterRole;
2 2 $Treex::Block::Read::BaseSplitterRole::VERSION = '2.20210102';
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Moose::Role;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use MooseX::SemiAffordanceAccessor;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 has bundles_per_doc => (
9 isa => 'Int',
10 is => 'ro',
11 default => 0,
12 documentation => 'Split the original file into more documents, each with max. N bundles. The deafult is 0 (do not split).',
13 );
14  
15 2 has _buffer_doc => (is=> 'rw');
16  
17 0 ▶after 'BUILD' => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
18 0 my ($self) = @_;
19 0 ▶ if ( $self->bundles_per_doc ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->bundles_per_doc) 0 0 0
20 0 $self->set_is_one_doc_per_file(0);
21 }
22 0 return;
23 2 };
24  
25 0 ▶around 'next_document' => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
26 0 my ($orig_next_doc_method, $self, $filename) = @_;
27  
28 0 my $doc = $self->_buffer_doc;
29  
30 0 ▶ if (!$doc) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($doc) 0 0 0
31 0 $doc = $self->$orig_next_doc_method($filename);
32 0 ▶ return if !$doc;
Branch: 1 branch
BranchTrueFalseTotal
unless $doc 0 0 0
33 }
34  
35 0 ▶ if ($self->bundles_per_doc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->bundles_per_doc) 0 0 0
36 0 my $bundles_ref = $doc->treeList();
37 0 ▶ if ( @$bundles_ref > $self->bundles_per_doc) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$bundles_ref > $self->bundles_per_doc) { } 0 0 0
38 0 my $new_doc = $self->new_document();
39 0 my @moving_bundles = splice @$bundles_ref, $self->bundles_per_doc;
40 # TODO fix references (delete coreference links) going across new doc boundaries
41 # or suggest to use block Util::FixInvalidIDs
42 0 push @{$new_doc->treeList()}, @moving_bundles;
43 0 $self->_set_buffer_doc($new_doc);
44 } else {
45 0 $self->_set_buffer_doc(undef);
46 }
47 }
48  
49 0 return $doc;
50 2 };
51  
52 2 1;
53  
54 __END__
« Treex/Core/TredView/Colors.pm ↑ Summary Treex/Block/Write/BaseWriter.pm »