| 1 | package Treex::Core::TredView; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | $Treex::Core::TredView::VERSION = '2.20151210'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # planned to be used from contrib.mac of tred's extensions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Treex::Core::Log; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Treex::Core::TredView::TreeLayout; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Treex::Core::TredView::Labels; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Treex::Core::TredView::Styles; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Treex::Core::TredView::Vallex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Treex::Core::Types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Scalar::Util qw(blessed refaddr); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use List::Util qw(first); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Cache::LRU; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Treex::Core::Config; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | $Treex::Core::Config::running_in_tred = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | has 'grp' => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | has 'pml_doc' => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | has 'doc_cache' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | isa => 'Cache::LRU', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 0 | ▶ | default => sub { Cache::LRU->new(size => 20); } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | has 'treex_doc' => ( is => 'rw' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | has 'tree_layout' => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | isa => 'Treex::Core::TredView::TreeLayout', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | ▶ | default => sub { Treex::Core::TredView::TreeLayout->new() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 1 | has 'labels' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | isa => 'Treex::Core::TredView::Labels', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | writer => '_set_labels', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | has '_styles' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | isa => 'Treex::Core::TredView::Styles', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | writer => '_set_styles', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | has 'vallex' => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | isa => 'Treex::Core::TredView::Vallex', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | writer => '_set_vallex', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | has fast_loading => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | isa => 'Bool', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | default => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | documentation => 'Do the precomputation lazily for each bundle', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | has _displayed_nodes => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | isa => 'HashRef[Treex::Core::Node]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | default => sub { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | has _ptb_index_map => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | isa => 'HashRef[Treex::Core::Node::P]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | default => sub { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | has _ptb_coindex_map => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | isa => 'HashRef[Treex::Core::Node::P]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | default => sub { {} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 1 | has 'clause_collapsing' => ( is => 'rw', isa => 'Bool', default => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 1 | has 'show_alignment' => ( is => 'rw', isa => 'Bool', default => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | has 'tree_type_to_wrap' => ( is => 'rw', isa => 'HashRef', default => sub { {} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | sub _spread_nodes { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my ( $self, $node ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_spread_nodes: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my ( $left, $right, $gap, $pos ) = ( -1, 0, 0, 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my ( @buf, @lower ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | for my $child ( $node->children ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ( $pos, @buf ) = $self->_spread_nodes($child); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ( $left < 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $left = $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $right += $gap; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $gap = scalar(@buf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | push @lower, @buf; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | $right += $pos; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return ( 0, $node ) if !@lower; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $mid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | if ( scalar( $node->children ) == 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $mid = int( ( $#lower + 1 ) / 2 - 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $mid = int( ( $left + $right ) / 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return ( $mid + 1 ), @lower[ 0 .. $mid ], $node, @lower[ ( $mid + 1 ) .. $#lower ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | sub _pmldoc_equals { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | my ($self, $fsfile) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pmldoc_equals: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | return ($self->pml_doc && $fsfile && refaddr($self->pml_doc) == refaddr($fsfile)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$self->pml_doc && $fsfile && builtin::refaddr($self->pml_doc) == builtin::refaddr($fsfile)
$self->pml_doc and $fsfile
MC/DC0%0/3
$self->pml_doc && $fsfile && builtin::refaddr($self->pml_doc) == builtin::refaddr($fsfile)
$self->pml_doc
$fsfile
builtin::refaddr($self->pml_doc) == builtin::refaddr($fsfile)
Truth table0%0/4
A and B && C
A= $self->pml_docB= $fsfileC= builtin::refaddr($self->pml_doc) == builtin::refaddr($fsfile)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | sub get_nodelist_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | my ( $self, $fsfile, $treeNo, $currentNode ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_nodelist_hook: not called CC=29 SCAR=67.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | #return if not $self->pml_doc(); # get_nodelist_hook is invoked also before file_opened_hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | unless ($self->_pmldoc_equals($fsfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $self->file_opened_hook($fsfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my $bundle = $fsfile->tree($treeNo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | bless $bundle, 'Treex::Core::Bundle'; # TODO: how to make this automatically? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | # Otherwise (in certain circumstances) $bundle->get_all_zones | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | # results in Can't locate object method "get_all_zones" via package "Treex::PML::Node" at /ha/work/people/popel/tectomt/treex/lib/Treex/Core/TredView.pm line 22 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | my $layout = $self->tree_layout->get_layout(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->{'_ptb_index_map'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->{'_ptb_coindex_map'} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my %nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | foreach my $tree ( map { ref($_) eq 'Treex::Core::BundleZone' ? $_->get_all_trees : () } $bundle->get_all_zones ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $label = $self->tree_layout->get_tree_label($tree); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if ( $tree->get_layer eq 'p' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | @nodes = $self->_spread_nodes($tree); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | shift @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | foreach my $node (@nodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | $self->{'_ptb_index_map'}->{ $node->{'index'} } = $node if defined $node->{'index'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | $self->{'_ptb_coindex_map'}->{ $node->{'coindex'} } = $node if defined $node->{'coindex'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | elsif ( $self->tree_type_to_wrap->{$self->_tree_type_signature($tree)} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | @nodes = $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | elsif ( $tree->does('Treex::Core::Node::Ordered') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | @nodes = $tree->get_descendants( { add_self => 1, ordered => 1 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | @nodes = $tree->get_descendants( { add_self => 1 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $nodes{$label} = \@nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | my $pick_next_tree = sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | my @task = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $max = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my $max_index = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | for ( my $i = 0; $i < scalar @task; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $val = $task[$i]{'left'} / $task[$i]{'total'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | if ( $val > $max ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | $max = $val; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $max_index = $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | return $max_index; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my @nodes = ($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | for ( my $col = 0; $col < scalar @$layout; $col++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | my @task = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | ▶ | for ( my $row = 0; $row < scalar @{ $layout->[$col] }; $row++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | if ( $layout->[$col][$row] and $layout->[$col][$row]->{'visible'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$layout->[$col][$row] and $layout->[$col][$row]{"visible"}
MC/DC0%0/2
$layout->[$col][$row] and $layout->[$col][$row]{"visible"}
$layout->[$col][$row]
$layout->[$col][$row]{"visible"}
Truth table0%0/3
A and B
A= $layout->[$col][$row]B= $layout->[$col][$row]{"visible"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | my $label = $layout->[$col][$row]->{'label'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | my %tree_info = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $tree_info{'total'} = $tree_info{'left'} = scalar @{ $nodes{$label} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | $tree_info{'label'} = $label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | push @task, \%tree_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | while ( ( my $index = &$pick_next_tree(@task) ) >= 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | push @nodes, shift @{ $nodes{ $task[$index]{'label'} } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $task[$index]{'left'}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | # only nodes having different clause number from their parents are | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | # displayed if node-collapsing is switched on | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( ( $self->clause_collapsing || 0 ) != ( $bundle->{_is_collapsed} || 0 ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$self->clause_collapsing || 0
$bundle->{'_is_collapsed'} || 0
MC/DC0%0/1
$self->clause_collapsing || 0
$self->clause_collapsing
MC/DC0%0/1
$bundle->{'_is_collapsed'} || 0
$bundle->{'_is_collapsed'}
Truth table0%0/2
A
A= $self->clause_collapsing
Truth table0%0/2
A
A= $bundle->{'_is_collapsed'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->clause_collapsing( $bundle->{_is_collapsed} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | if ( $self->clause_collapsing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my %root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | foreach my $node ( grep { $_->isa('Treex::Core::Node::A') } @nodes ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | if ( defined $node->clause_number ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $root{$node} = $node->get_clause_root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | my %hide; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | foreach my $node ( grep { $_->isa('Treex::Core::Node::A') } @nodes ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | if ( defined $node->clause_number and $root{$node} ne $node ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $node->clause_number and $root{$node} ne $node
MC/DC0%0/2
defined $node->clause_number and $root{$node} ne $node
defined $node->clause_number
$root{$node} ne $node
Truth table0%0/3
A and B
A= defined $node->clause_numberB= $root{$node} ne $node
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $hide{$node} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | @nodes = grep { !$hide{$_} } @nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | foreach my $node ( grep { $_->isa('Treex::Core::Node::A') } @nodes ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $parent = $node->get_parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | if ( $parent and $hide{$parent} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parent and $hide{$parent}
MC/DC0%0/2
$parent and $hide{$parent}
$parent
$hide{$parent}
Truth table0%0/3
A and B
A= $parentB= $hide{$parent}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $node->set_parent( $root{$parent} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | $self->{'_displayed_nodes'} = { map { $_->attr('id') => 1 } @nodes }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | ▶ | unless ( $currentNode and ( first { $_ == $currentNode } @nodes ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
Condition0%0/3
$currentNode and &first(sub {
MC/DC0%0/2
$currentNode and &first(sub {
$_ == $currentNode;
}
, @nodes)
$currentNode
&first(sub {
$_ == $currentNode;
}
, @nodes)
Truth table0%0/3
A and B
A= $currentNodeB= &first(sub {
$_ == $currentNode;
}
, @nodes)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $currentNode = $nodes[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return [ \@nodes, $currentNode ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | sub recompute_visualization { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my ( $self, $bundle ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
recompute_visualization: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $self->precompute_tree_depths($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | $self->precompute_tree_shifts($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $self->precompute_visualization($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | $self->precompute_value_line($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | sub file_opened_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | my ($self, $fsfile) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file_opened_hook: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my $pmldoc = $fsfile || $self->grp()->{FSFile}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$fsfile || $self->grp->{'FSFile'}
MC/DC0%0/2
$fsfile || $self->grp->{'FSFile'}
$fsfile
$self->grp->{'FSFile'}
Truth table0%0/3
A || B
A= $fsfileB= $self->grp->{'FSFile'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | return unless $pmldoc && $pmldoc->metaData('schema') && | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$pmldoc and $pmldoc->metaData("schema") and $pmldoc->metaData("schema")->get_root_name eq "treex_document"
$pmldoc and $pmldoc->metaData("schema")
MC/DC0%0/3
$pmldoc and $pmldoc->metaData("schema") and $pmldoc->metaData("schema")->get_root_name eq "treex_document"
$pmldoc
$pmldoc->metaData("schema")
$pmldoc->metaData("schema")->get_root_name eq "treex_document"
Truth table0%0/4
A and B and C
A= $pmldocB= $pmldoc->metaData("schema")C= $pmldoc->metaData("schema")->get_root_name eq "treex_document"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | $pmldoc->metaData('schema')->get_root_name() eq 'treex_document'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | return if $self->_pmldoc_equals($pmldoc); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $self->pml_doc($pmldoc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $treex_doc = $self->doc_cache->get(refaddr($self->pml_doc)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | unless ($treex_doc) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ( defined $pmldoc->[13]->{_treex_core_document} ) { # if it comes from storable (i.e., already with moose) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $treex_doc = $pmldoc->[13]->{_treex_core_document}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # streex files do not have "wild_dump" filled, but we want to show this in ttred | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $treex_doc->_serialize_all_wild(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $treex_doc = Treex::Core::Document->new( { pmldoc => $pmldoc } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | $self->doc_cache->set(refaddr($self->pml_doc), $treex_doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | $self->treex_doc($treex_doc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # labels, styles and vallex must be created again for each file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $self->_set_labels( Treex::Core::TredView::Labels->new( _treex_doc => $treex_doc ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | $self->_set_styles( Treex::Core::TredView::Styles->new( _treex_doc => $treex_doc ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | $self->_set_vallex( Treex::Core::TredView::Vallex->new( _treex_doc => $treex_doc ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | foreach my $bundle ( $treex_doc->get_bundles() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # If we don't care about slow loading of the whole file, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # we can precompute all bundles now, so browsing through bundles | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # will be a bit faster. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | ▶ | if ( !$self->fast_loading && !$bundle->{_precomputed} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->fast_loading or $bundle->{"_precomputed"}
MC/DC0%0/2
$self->fast_loading or $bundle->{"_precomputed"}
$self->fast_loading
$bundle->{"_precomputed"}
Truth table0%0/3
A or B
A= $self->fast_loadingB= $bundle->{"_precomputed"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | $self->precompute_tree_depths($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | $self->precompute_tree_shifts($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | $self->precompute_visualization($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | $bundle->{_precomputed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # Root style cannot be precomputed lazily, because | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | # root_style_hook is executed after reading the precomputed root style, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | # so there is no hook where to place the lazy precomputation. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $bundle->{_precomputed_root_style} = $self->_styles->bundle_style($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | sub get_value_line_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | ▶ | my ( $self, $fsfile, $treeNo ) = @_; # the unused argument stands for $fsfile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_value_line_hook: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | #return if not $self->pml_doc(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | unless ($self->_pmldoc_equals($fsfile)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | $self->file_opened_hook($fsfile); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $bundle = $self->pml_doc->tree($treeNo); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | if ( !$bundle->{_precomputed_value_line} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $self->precompute_value_line($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return $bundle->{_precomputed_value_line}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | sub value_line_doubleclick_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my ( $self, @tags ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
value_line_doubleclick_hook: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my %tags; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | @tags{@tags} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $bundle = $TredMacro::root; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | my $layout = $self->tree_layout->get_layout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | my %ordering; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | my %visible; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $row = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $found = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | ▶ | while ($found) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $found = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ▶ | for ( my $col = 0; $col < scalar @$layout; $col++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | if ( defined $layout->[$col][$row] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | ▶ | if ( $layout->[$col][$row]->{'visible'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $ordering{ $layout->[$col][$row]->{'label'} } = $i++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $visible{ $layout->[$col][$row]->{'label'} } = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $found = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $row++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | my @trees = sort { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $ordering{ $self->tree_layout->get_tree_label($a) } <=> $ordering{ $self->tree_layout->get_tree_label($b) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } grep { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | exists $visible{ $self->tree_layout->get_tree_label($_) } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } $bundle->get_all_trees; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | for my $tree (@trees) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | for my $node ( $tree->get_descendants ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | next if $node->get_layer eq 'p' and not $node->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$node->get_layer eq "p" and not $node->is_terminal
MC/DC0%0/2
$node->get_layer eq "p" and not $node->is_terminal
$node->get_layer eq "p"
not $node->is_terminal
Truth table0%0/3
A and not(B)
A= $node->get_layer eq "p"B= not $node->is_terminal
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | return $node if exists $tags{"$node"}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | return 'stop'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | # --------------- PRECOMPUTING VISUALIZATION (node labels, styles, coreference links, groups...) --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 1 | my @layers = map {lc} Treex::Core::Types::layers(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # To be run only once when the file is opened. Tree depths never change. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | sub precompute_tree_depths { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | ▶ | my ( $self, $bundle ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
precompute_tree_depths: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | foreach my $zone ( $bundle->get_all_zones ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | foreach my $tree ( ref($zone) eq 'Treex::Core::BundleZone' ? $zone->get_all_trees : () ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $max_depth = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my @front = ( 1, $tree ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | while (@front) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my $cur_depth = shift @front; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | my $node = shift @front; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | $max_depth = $cur_depth if $cur_depth > $max_depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | for my $child ( $node->get_children ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | push @front, $cur_depth + 1, $child; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | $child->{_depth} = $cur_depth + 1 if $child->get_layer eq 'p'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $tree->{_tree_depth} = $max_depth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | sub node_release_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | my ($self, $node, $target, $mod) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_release_hook: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my @roots = map { $_->get_root } $node, $target; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | my @zones = map { $_->get_zone } $node, $target; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | ▶ | if ($self->show_alignment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->show_alignment and $roots[0] != $roots[1] and $zones[0] != $zones[1]
$self->show_alignment and $roots[0] != $roots[1]
MC/DC0%0/3
$self->show_alignment and $roots[0] != $roots[1] and $zones[0] != $zones[1]
$self->show_alignment
$roots[0] != $roots[1]
$zones[0] != $zones[1]
Truth table0%0/4
A and B and C
A= $self->show_alignmentB= $roots[0] != $roots[1]C= $zones[0] != $zones[1]
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | $roots[0] != $roots[1] and $zones[0] != $zones[1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if ($node->is_aligned_to($target, 'alignment')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | $node->delete_aligned_node($target, 'alignment'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $node->add_aligned_node($target, 'alignment'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | # TODO: Is there more treexy way to do it? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | TredMacro::Redraw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | return 'stop'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | # Has to be run whenever the tree layout changes. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | sub precompute_tree_shifts { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | my ( $self, $bundle ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
precompute_tree_shifts: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $layout = $self->tree_layout->get_layout($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my %forest = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | foreach my $zone ( $bundle->get_all_zones ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | foreach my $tree ( ref($zone) eq 'Treex::Core::BundleZone' ? $zone->get_all_trees : () ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $forest{ $self->tree_layout->get_tree_label($tree) } = $tree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | my @trees = ('foo'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $row = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | my $cur_shift = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | ▶ | while (@trees) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | my $max_depth = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | @trees = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | for ( my $col = 0; $col < scalar @$layout; $col++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | if ( defined $layout->[$col][$row] ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | my $label = $layout->[$col][$row]->{'label'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | my $depth = $forest{$label}{_tree_depth}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | push @trees, $label; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | ▶ | $max_depth = $depth if $depth > $max_depth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $forest{$label}{'_shift_right'} = $col; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | for my $label (@trees) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $forest{$label}{'_shift_down'} = $cur_shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $cur_shift += $max_depth; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | $row++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | sub precompute_visualization { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | my ( $self, $bundle ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
precompute_visualization: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $bundle->{_precomputed_node_style} = '#{Node-hide:1}'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | foreach my $zone ( $bundle->get_all_zones ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | foreach my $layer (@layers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | if ( ref($zone) eq 'Treex::Core::BundleZone' && $zone->has_tree($layer) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $zone eq "Treex::Core::BundleZone" and $zone->has_tree($layer)
MC/DC0%0/2
ref $zone eq "Treex::Core::BundleZone" and $zone->has_tree($layer)
ref $zone eq "Treex::Core::BundleZone"
$zone->has_tree($layer)
Truth table0%0/3
A and B
A= ref $zone eq "Treex::Core::BundleZone"B= $zone->has_tree($layer)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $root = $zone->get_tree($layer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $limits = $self->labels->get_limits($layer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $root->{_precomputed_labels} = $self->labels->root_labels($root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $root->{_precomputed_node_style} = $self->_styles->node_style($root); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $root->{_precomputed_hint} = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | if ( $root->get_zone->sentence ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | $root->{_precomputed_hint} = 'sentence: ' . $root->get_zone->sentence; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | foreach my $node ( $root->get_descendants ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $node->{_precomputed_node_style} = $self->_styles->node_style($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | $node->{_precomputed_hint} = $self->node_hint( $node, $layer ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $node->{_precomputed_buffer} = $self->labels->node_labels( $node, $layer ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $self->labels->set_labels($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | if ( !$limits ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | for ( my $i = 0; $i < 3; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | $self->labels->set_limit( $layer, $i, scalar( @{ $node->{_precomputed_buffer}[$i] } ) - 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | $limits = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | sub get_clickable_sentence_for_a_zone { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | my ( $self, $zone, $alignment ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_clickable_sentence_for_a_zone: not called CC=16 SCAR=56.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | return if !$zone->has_atree(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my %refs = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | if ( $zone->has_ttree() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | for my $tnode ( $zone->get_ttree->get_descendants ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | for my $aux ( TredMacro::ListV( $tnode->attr('a/aux.rf') ) ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | push @{ $refs{$aux} }, $tnode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | ▶ | if ( exists $alignment->{ $tnode->get_attr('id') } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | push @{ $refs{$aux} }, @{ $alignment->{ $tnode->get_attr('id') } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if ( $tnode->attr('a/lex.rf') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | push @{ $refs{ $tnode->attr('a/lex.rf') } }, $tnode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | if ( exists $alignment->{ $tnode->get_attr('id') } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | push @{ $refs{ $tnode->attr('a/lex.rf') } }, @{ $alignment->{ $tnode->get_attr('id') } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my @anodes = $zone->get_atree->get_descendants( { ordered => 1 } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | for my $anode (@anodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | my $id = $anode->id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | push @{ $refs{$id} }, $anode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 0 | ▶ | if ( exists $alignment->{$id} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | push @{ $refs{$id} }, @{ $alignment->{$id} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | if ( $anode->attr('p_terminal.rf') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my $pnode = $self->treex_doc->get_node_by_id( $anode->attr('p_terminal.rf') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | push @{ $refs{$id} }, $pnode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | ▶ | while ( $pnode->parent ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $pnode = $pnode->parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | push @{ $refs{$id} }, $pnode; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my @out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | for my $anode (@anodes) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | push @out, [ $anode->form, @{ $refs{ $anode->id } || [] } ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | if ( $anode->clause_number ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | my $clr = $self->_styles->_colors->get_clause_color( $anode->clause_number ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | push @{ $out[-1] }, "-foreground => $clr"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | ▶ | if ( !$anode->no_space_after ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | push @out, [ ' ', 'space' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | push @out, [ "\n", 'newline' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | return \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | sub precompute_value_line { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | ▶ | my ( $self, $bundle ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
precompute_value_line: not called CC=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | my %alignment = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | foreach my $zone ( $bundle->get_all_zones() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | foreach my $layer (@layers) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | if ( $zone->has_tree($layer) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | my $root = $zone->get_tree($layer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | foreach my $node ( $root, $root->get_descendants ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | if ( exists $node->{'alignment'} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | foreach my $ref ( @{ $node->get_attr('alignment') } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | next if !defined $ref || ! defined $ref->{'counterpart.rf'}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $ref and defined $ref->{"counterpart.rf"}
MC/DC0%0/2
defined $ref and defined $ref->{"counterpart.rf"}
defined $ref
defined $ref->{"counterpart.rf"}
Truth table0%0/3
A and B
A= defined $refB= defined $ref->{"counterpart.rf"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | push @{ $alignment{ $node->{id} } }, $self->treex_doc->get_node_by_id( $ref->{'counterpart.rf'} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | push @{ $alignment{ $ref->{'counterpart.rf'} } }, $node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | my @out = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | foreach my $zone ( $bundle->get_all_zones() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | push @out, ( [ '[' . $zone->get_label . ']', 'label' ], [ ' ', 'space' ] ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 0 | ▶ | if ( my $sentence = $self->get_clickable_sentence_for_a_zone( $zone, \%alignment ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | push @out, @$sentence; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | elsif ( defined $zone->sentence ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | push @out, [ $zone->sentence . "\n", 'text' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | push @out, [ "\n", 'newline' ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | $bundle->{_precomputed_value_line} = \@out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # ---- info displayed when mouse stops over a node - "hint" (should return a string, that may contain newlines) --- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | sub node_hint { # silly code just to avoid the need for eval | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | my $layer = pop @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_hint: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | my %subs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | $subs{t} = \&tnode_hint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | $subs{a} = \&anode_hint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $subs{n} = \&nnode_hint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | $subs{p} = \&pnode_hint; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | if ( defined $subs{$layer} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | return &{ $subs{$layer} }(@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | log_fatal "Undefined or unknown layer: $layer"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | sub anode_hint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | my ( $self, $node ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
anode_hint: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 0 | my @lines = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | ▶ | push @lines, "Parenthesis root" if $node->{is_parenthesis_root}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | ▶ | if ( $node->language eq 'cs' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | push @lines, "Full lemma: " . ( $node->{lemma} ? $node->{lemma} : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | ▶ | push @lines, "Full tag: " . ( $node->{tag} ? $node->{tag} : '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | # List all non-empty Interset features. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if ( $node->does('Treex::Core::Node::Interset') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my @ifeat = $node->iset()->get_nonempty_features(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | foreach my $f ( @ifeat ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | my $v = $node->iset()->get_joined($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | push(@lines, "$f: $v"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | return join "\n", @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | sub tnode_hint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | my ( $self, $node ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
tnode_hint: not called CC=10 SCAR=47.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | my @lines = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | if ( ref $node->get_attr('gram') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | foreach my $gram ( keys %{ $node->get_attr('gram') } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | ▶ | push @lines, "gram/$gram : " . ( $node->get_attr( 'gram/' . $gram ) || '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$node->get_attr('gram/' . $gram) || ''
MC/DC0%0/1
$node->get_attr('gram/' . $gram) || ''
$node->get_attr('gram/' . $gram)
Truth table0%0/2
A
A= $node->get_attr('gram/' . $gram)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | push @lines, "Direct speech root" if $node->get_attr('is_dsp_root'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | push @lines, "Parenthesis" if $node->get_attr('is_parenthesis'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | push @lines, "Name of person" if $node->get_attr('is_name_of_person'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | ▶ | push @lines, "Name" if $node->get_attr('is_name'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | ▶ | push @lines, "State" if $node->get_attr('is_state'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | push @lines, "Quotation : " . join ", ", map { $_->{type} } TredMacro::ListV( $node->get_attr('quot') ) if $node->get_attr('quot'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | return join "\n", @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | sub nnode_hint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | my ( $self, $node ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nnode_hint: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | sub pnode_hint { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | ▶ | my ( $self, $node ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pnode_hint: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | my @lines = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | ▶ | if ( $node->is_terminal ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | ▶ | push @lines, map { "$_: " . ( defined $node->{$_} ? $node->{$_} : '' ) } qw(lemma tag form); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | push @lines, "phrase: " . $node->{phrase}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | push @lines, "functions: " . join( ', ', TredMacro::ListV( $node->{functions} ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | return join "\n", @lines; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | # --- arrows ---- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | # copied from TectoMT_TredMacros.mak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | sub node_style_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | ▶ | my ( $self, $node, $styles ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_style_hook: not called CC=23 SCAR=63.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | ▶ | return if ref($node) eq 'Treex::Core::Bundle'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | my %line = TredMacro::GetStyles( $styles, 'Line' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 0 | my @target_ids; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | my @arrow_types; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | foreach my $ref_attr ( 'coref_gram', 'coref_text', 'compl' ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | ▶ | if ( defined $node->attr( $ref_attr . '.rf' ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | foreach my $target_id ( @{ $node->attr( $ref_attr . '.rf' ) } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | push @target_ids, $target_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | push @arrow_types, $ref_attr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | # P-layer indexes and coindexes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | if ( $node->get_layer eq 'p' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my $coindex; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | ▶ | if ( $node->attr('form') and $node->attr('form') =~ m/-(\d+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$node->attr("form") and $node->attr("form") =~ /-(\d+)$/
MC/DC0%0/2
$node->attr("form") and $node->attr("form") =~ /-(\d+)$/
$node->attr("form")
$node->attr("form") =~ /-(\d+)$/
Truth table0%0/3
A and B
A= $node->attr("form")B= $node->attr("form") =~ /-(\d+)$/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | $coindex = $1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | elsif ( $node->attr('coindex') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | 0 | $coindex = $node->attr('coindex'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | if ($coindex) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my $target_node; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | ▶ | if ( exists $self->{'_ptb_index_map'}->{$coindex} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 0 | $target_node = $self->{'_ptb_index_map'}->{$coindex}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | ▶ | elsif ( $node->is_terminal and exists $self->{'_ptb_coindex_map'}->{$coindex} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$node->is_terminal and exists $self->{"_ptb_coindex_map"}{$coindex}
MC/DC0%0/2
$node->is_terminal and exists $self->{"_ptb_coindex_map"}{$coindex}
$node->is_terminal
exists $self->{"_ptb_coindex_map"}{$coindex}
Truth table0%0/3
A and B
A= $node->is_terminalB= exists $self->{"_ptb_coindex_map"}{$coindex}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | $target_node = $self->{'_ptb_coindex_map'}->{$coindex}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | ▶ | if ($target_node) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | push @target_ids, $target_node->{'id'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | push @arrow_types, 'coindex'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | # alignment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | 0 | ▶ | if ( $self->show_alignment and my $links = $node->attr('alignment') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->show_alignment and my $links = $node->attr("alignment")
MC/DC0%0/2
$self->show_alignment and my $links = $node->attr("alignment")
$self->show_alignment
my $links = $node->attr("alignment")
Truth table0%0/3
A and B
A= $self->show_alignmentB= my $links = $node->attr("alignment")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | foreach my $link (@$links) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 0 | push @target_ids, $link->{'counterpart.rf'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | push @arrow_types, $link->{'type'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | $self->_styles->draw_arrows( $node, $styles, \%line, \@target_ids, \@arrow_types, ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | # TODO: Would it be possible to move this code to the "_precomputed_node_style" attr? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | my %n = TredMacro::GetStyles( $styles, 'Node' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 0 | ▶ | TredMacro::AddStyle( $styles, 'Node', -tag => ( $n{-tag} || '' ) . '#' . $node->{id} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$n{'-tag'} || ''
MC/DC0%0/1
$n{'-tag'} || ''
$n{'-tag'}
Truth table0%0/2
A
A= $n{'-tag'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | my $xadj = $node->root->{'_shift_right'} * 50; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | if (ref($node) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
ref($node) =~ /^Treex::Core::Node/ and $node->get_layer eq "p" and not $node->is_root and scalar $node->parent->children == 1
ref($node) =~ /^Treex::Core::Node/ and $node->get_layer eq "p" and not $node->is_root
ref($node) =~ /^Treex::Core::Node/ and $node->get_layer eq "p"
MC/DC0%0/4
ref($node) =~ /^Treex::Core::Node/ and $node->get_layer eq "p" and not $node->is_root and scalar $node->parent->children == 1
ref($node) =~ /^Treex::Core::Node/
$node->get_layer eq "p"
not $node->is_root
scalar $node->parent->children == 1
Truth table0%0/5
A and B and not(C) and D
A= ref($node) =~ /^Treex::Core::Node/B= $node->get_layer eq "p"C= not $node->is_rootD= scalar $node->parent->children == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | =~ m/^Treex::Core::Node/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | and $node->get_layer eq 'p' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | and not $node->is_root and scalar $node->parent->children == 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | $xadj += 15; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | ▶ | TredMacro::AddStyle( $styles, 'Node', -xadj => $xadj ) if $xadj; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | sub root_style_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 0 | ▶ | my ( $self, $bundle, $styles ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
root_style_hook: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # Sometimes TrEd calls this on e.g. t-nodes (after node_click_hook) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 0 | ▶ | return if !$bundle->isa('Treex::Core::Bundle'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | ▶ | return if $bundle->{_precomputed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | $self->precompute_tree_depths($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | $self->precompute_tree_shifts($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | $self->precompute_visualization($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | $bundle->{_precomputed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | # ---- END OF PRECOMPUTING VISUALIZATION ------ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | sub conf_dialog { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
conf_dialog: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | if ( $self->tree_layout->conf_dialog() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | foreach my $bundle ( $self->treex_doc->get_bundles() ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | if ( !$self->fast_loading ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $bundle->{_precomputed_root_style} = $self->_styles->bundle_style($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 0 | $self->precompute_tree_shifts($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | $self->precompute_visualization($bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 0 | $bundle->{_precomputed} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | $bundle->{_precomputed} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | sub _divide_clause_string { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | ▶ | my ( $self, $anode ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_divide_clause_string: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | if ( !$anode->clause_number ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | return [ $anode->form,, ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 0 | my @forms = map { $_->form } $anode->get_clause_nodes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my $forms_per_line = int( @forms / 3 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | return [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | ( join ' ', @forms[ 0 .. $forms_per_line ] ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | ( join ' ', @forms[ $forms_per_line + 1 .. 2 * $forms_per_line ] ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | ( join ' ', @forms[ 2 * $forms_per_line + 1 .. $#forms ] ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | sub toggle_clause_collapsing { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | ▶ | my ( $self, $bundle ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toggle_clause_collapsing: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 0 | $self->clause_collapsing( not $self->clause_collapsing ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | 0 | $bundle->{_is_collapsed} = $self->clause_collapsing; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | print "Toggle: " . $self->clause_collapsing . "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | # fold clauses - display word from the clause instead of node labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 0 | foreach my $zone ( $bundle->get_all_zones ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | 0 | ▶ | if ( $zone->has_tree('a') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | my $aroot = $zone->get_atree; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 0 | foreach my $anode ( $aroot->get_descendants ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | # fold clauses - display word from the clause instead of node labels | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | 0 | ▶ | if ( $self->clause_collapsing ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 0 | $anode->{_parent_backup} = $anode->get_parent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 0 | $anode->{_precomputed_labels_backup} = $anode->{_precomputed_labels}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 0 | $anode->{_precomputed_labels} = $self->_divide_clause_string($anode); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | # unfold clauses - return to full attribute labes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 0 | $anode->{_precomputed_labels} = $anode->{_precomputed_labels_backup}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | $anode->set_parent( $anode->{_parent_backup} ) if $anode->{_parent_backup}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | sub toggle_alignment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toggle_alignment: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | $self->show_alignment( not $self->show_alignment ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | sub toggle_tree_wrapping { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | ▶ | my ( $self, $node ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toggle_tree_wrapping: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | my $signature = $self->_tree_type_signature($node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | $self->tree_type_to_wrap->{$signature} = not $self->tree_type_to_wrap->{$signature}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | print "Toggle wrapping of trees of type: $signature\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | sub _tree_type_signature { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | ▶ | my ( $self, $node) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tree_type_signature: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 0 | my $zone = $node->get_root->get_zone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | 0 | ▶ | return join "-", ( ref($node), $zone->language, $zone->selector()||''); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$zone->selector || ''
MC/DC0%0/1
$zone->selector || ''
$zone->selector
Truth table0%0/2
A
A= $zone->selector
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 1 | ▶ | use Treex::Core::TredView::AnnotationCommand; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | sub run_annotation_command { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | ▶ | my ( $self, $command, $node ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_annotation_command: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | Treex::Core::TredView::AnnotationCommand::run( $command, $node ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | $self->recompute_visualization($node->get_bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 1 | my $HIGHLIGHT_STYLE = '#{Line-decoration:shape=oval;coords=-20,-10,20,10;outline=#ff0000;width=3;dash=5,5 }'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 1 | my $HIGHLIGHT_TEXT = '-background => #ffbbaa'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 1 | my @highlighted = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | sub node_click_hook { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | ▶ | my ( $self, $node, $modifier, $xevent ) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
node_click_hook: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | my $ali_id = eval {$node->wild->{ali_root}}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | if ($ali_id){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | # remove all highlighting | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 0 | foreach my $n (@highlighted){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 0 | $n->{_precomputed_node_style} =~ s/\Q$HIGHLIGHT_STYLE\E//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 0 | @highlighted = (); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | # add new highlighted nodes (a minimal treelet consistent with alignment) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my $al_node = $self->treex_doc->get_node_by_id($ali_id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | my @queue = ($node, $al_node); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | ▶ | while (@queue){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | my $n = shift @queue; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | push @highlighted, $n; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | push @queue, grep {!$_->wild->{ali_root}} $n->get_children(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | foreach my $n (@highlighted){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | $n->{_precomputed_node_style} .= $HIGHLIGHT_STYLE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | # highlight also the relevant words in the text window above trees | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | my $bundle = $node->get_bundle(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | my %h; $h{$_}=1 for (@highlighted); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 0 | foreach my $token (@{$bundle->{_precomputed_value_line}}){ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | pop @$token if $token->[-1] eq $HIGHLIGHT_TEXT; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | push @$token, $HIGHLIGHT_TEXT if $h{$token->[1]}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | TredMacro::Redraw(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | =encoding utf-8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | =for Pod::Coverage precompute_visualization | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | Treex::Core::TredView - visualization of Treex files in TrEd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | =head1 VERSION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | version 2.20151210 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | This module is used only in an extension of the Tree editor TrEd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | developed for displaying .treex files. The TrEd extension is contained | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | in the same distribution as this module. The extension itself | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | is very thin. It only creates an instance of C<Treex::Core::TredView> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | and then forwards calls of hooks (subroutines with predefined | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | names called by TrEd at certain events) to this instance. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | This module defines what information (especially which node attributes) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | should be displayed below nodes in the individual types of trees | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | and what visual style (e.g. node and edge color, node size, edge | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | thickness) should be used for them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | The TrEd visualization is precomputed statically after a file is loaded, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | therefore the extension can be currently used only for browsing, not for | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | editing the treex files. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | =head2 Methods called from the TrEd extension | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | Methods called directly from the hooks in the TrEd extension: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | =item file_opened_hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | Building L<Treex::Core::Document> structure on the top of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | L<Treex::PML::Document> structure which was provided by TrEd. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | =item get_nodelist_hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | =item get_value_line_hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | =item value_line_doubleclick_hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | =item node_style_hook | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | =item conf_dialog | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | =item toggle_clause_collapsing | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | =back | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | =head1 AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | Zdeněk Žabokrtský <zabokrtsky@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | David Mareček <marecek@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | Josef Toman <toman@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | Martin Popel <popel@ufal.mff.cuni.cz> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles University in Prague | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||