Treex/Core/TredView/Labels.pm

filter: Statementstmt 7.1% 14 / 195 Branchbran 0.0% 0 / 116 Conditioncond 0.0% 0 / 32 MC/DCmcdc 0.0% 0 / 18 Subroutinesub 15.7% 3 / 19 Podpod 85.7% 6 / 7 totaltotal 5.9% 23 / 387 CC 78 SCAR 57.9
CC
78
Cov
4%
_anode_labels
702.0
_tnode_labels
506.0
shift_labels
110.0
CRAP 326.2
« Treex/Core/TredView/Styles.pm ↑ Summary Treex/Core/Phrase/Coordination.pm »
1 package Treex::Core::TredView::Labels;
2 2 $Treex::Core::TredView::Labels::VERSION = '2.20210102';
3 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Treex::Core::TredView::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Treex::Core::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 has '_label_variants' => (
8 is => 'rw',
9 isa => 'HashRef[ArrayRef[Int]]',
10 builder => '_build_label_variants'
11 );
12 2 has '_treex_doc' => (
13 is => 'ro',
14 isa => 'Treex::Core::Document',
15 weak_ref => 1,
16 required => 1
17 );
18 has '_colors' => (
19 is => 'ro',
20 isa => 'Treex::Core::TredView::Colors',
21 0 ▶ default => sub { Treex::Core::TredView::Colors->new() }
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 2 );
23  
24 0 ▶sub _build_label_variants {
Subroutine _build_label_variants: not called CC=1 SCAR=6.9
25 return {
26 0 'p' => [ 0, 0, 0 ],
27 'a' => [ 0, 0, 0 ],
28 't' => [ 0, 0, 0 ],
29 'n' => [ 0, 0, 0 ]
30 }
31 }
32  
33 0 ▶sub _get_label_variant {
Subroutine _get_label_variant: not called CC=4 SCAR=30.0
34 0 my $self = shift;
35 0 my ( $obj, $line ) = @_;
36  
37 0 ▶ if ( ref $obj and not exists $obj->{_label_variants} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $obj and not exists $obj->{"_label_variants"}) 0 0 0
Condition0%0/3
ref $obj and not exists $obj->{"_label_variants"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $obj and not exists $obj->{"_label_variants"}
ref $obj not exists $obj->{"_label_variants"}
Truth table0%0/3
A and not(B)
A= ref $objB= not exists $obj->{"_label_variants"}
ABresult
0X0
100
111
38 0 $obj = $obj->get_layer;
39 }
40  
41 0 ▶ if ( ref $obj ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $obj) { } 0 0 0
42  
43 # $obj is a single node
44 0 return $obj->{_label_variants}[$line];
45 }
46 else {
47  
48 # $obj is the name of a layer
49 0 return $self->{_label_variants}{$obj}[$line];
50 }
51 }
52  
53 # a) $obj is a node => rotating label variant of the given node
54 # b) $obj is the name of a layer => rotating label variant of all nodes on the given layer
55 0 ▶sub _rotate_label_variant {
Subroutine _rotate_label_variant: not called CC=7 SCAR=40.3
56 0 my ( $self, $obj, $line ) = @_;
57 0 my $layer;
58 my $current;
59 0 my $new;
60  
61 0 ▶ if ( ref $obj ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $obj) { } 0 0 0
62 0 $layer = $obj->get_layer;
63 0 ▶ if ( not exists $obj->{_label_variants} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $obj->{"_label_variants"}) 0 0 0
64 0 ▶ for ( my $i = 0; $i < 3; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 3) 0 0 0
65 0 $obj->{_label_variants}[$i] = $self->_get_label_variant( $layer, $i );
66 }
67 }
68 0 $current = $obj->{_label_variants}[$line];
69 }
70 else {
71 0 $layer = $obj;
72 0 $current = $self->_get_label_variant( $obj, $line );
73 }
74 0 my $limit = $self->_label_variants->{ $layer . '_limit' }[$line];
75 0 ▶ $new = $current >= $limit ? 0 : $current + 1;
Branch: 1 branch
BranchTrueFalseTotal
$current >= $limit ? : 0 0 0
76  
77 0 ▶ return if $current == $new;
Branch: 1 branch
BranchTrueFalseTotal
if $current == $new 0 0 0
78  
79 0 ▶ if ( ref $obj ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $obj) { } 0 0 0
80 0 $obj->{_label_variants}[$line] = $new
81 }
82 else {
83 0 $self->{_label_variants}{$layer}[$line] = $new
84 }
85  
86 0 return 1;
87 }
88  
89 0 ▶sub set_labels {
Subroutine set_labels: not called CC=2 SCAR=17.9
Pod documented
90 0 my ( $self, $node ) = @_;
91  
92 0 my $buf = $node->{_precomputed_buffer};
93 0 ▶ for ( my $i = 0; $i < 3; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < 3) 0 0 0
94 0 $node->{_precomputed_labels}[$i] = $buf->[$i][ $self->_get_label_variant( $node, $i ) ];
95 }
96 0 return;
97 }
98  
99 0 ▶sub shift_labels {
Subroutine shift_labels: not called CC=10 SCAR=47.0
Pod documented
100 0 my ( $self, $line, $mode ) = @_;
101 0 my $node = Treex::Core::TredView::Common::cur_node();
102 0 ▶ return if $node->is_root and $mode eq 'node';
Branch: 1 branch
BranchTrueFalseTotal
if $node->is_root and $mode eq "node" 0 0 0
Condition0%0/3
$node->is_root and $mode eq "node"
!ll&&!rl&&r
000
MC/DC0%0/2
$node->is_root and $mode eq "node"
$node->is_root $mode eq "node"
Truth table0%0/3
A and B
A= $node->is_rootB= $mode eq "node"
ABresult
0X0
100
111
103  
104 0 my $layer = $node->get_layer;
105 0 my @nodes;
106 0 ▶ if ( $mode eq 'node' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq 'node') { } 0 0 0
107 0 ▶ return if !$self->_rotate_label_variant( $node, $line );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_rotate_label_variant($node, $line) 0 0 0
108 0 @nodes = ($node);
109 }
110 else {
111 0 ▶ return if !$self->_rotate_label_variant( $layer, $line );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_rotate_label_variant($layer, $line) 0 0 0
112 0 foreach my $bundle ( $self->_treex_doc->get_bundles ) {
113 0 foreach my $zone ( $bundle->get_all_zones ) {
114 0 ▶ if ( $zone->has_tree($layer) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($zone->has_tree($layer)) 0 0 0
115 0 push @nodes, $zone->get_tree($layer)->get_descendants;
116 }
117 }
118 }
119 0 @nodes = grep { not exists $_->{_label_variants} } @nodes;
120 }
121  
122 0 for my $node (@nodes) {
123 0 $self->set_labels($node);
124 }
125 0 return;
126 }
127  
128 0 ▶sub reset_labels {
Subroutine reset_labels: not called CC=4 SCAR=30.0
Pod documented
129 0 my ( $self, $mode ) = @_;
130 0 my $node = Treex::Core::TredView::Common::cur_node();
131 0 ▶ return if $node->is_root;
Branch: 1 branch
BranchTrueFalseTotal
if $node->is_root 0 0 0
132  
133 0 my @nodes;
134 0 ▶ if ( $mode eq 'node' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mode eq 'node') { } 0 0 0
135 0 @nodes = ($node);
136 }
137 else {
138 0 @nodes = $node->get_root->get_descendants;
139 }
140  
141 0 for my $n (@nodes) {
142 0 delete $n->{_label_variants};
143 0 $self->set_labels($n);
144 }
145 0 return;
146 }
147  
148 0 ▶sub set_limit {
Subroutine set_limit: not called CC=1 SCAR=6.9
Pod documented
149 0 my ( $self, $layer, $line, $limit ) = @_;
150 0 return $self->_label_variants->{ $layer . '_limit' }[$line] = $limit;
151 }
152  
153 0 ▶sub get_limits {
Subroutine get_limits: not called CC=1 SCAR=6.9
Pod undocumented
154 0 my ( $self, $layer ) = @_;
155 0 return $self->_label_variants->{ $layer . '_limit' };
156 }
157  
158 0 ▶sub root_labels {
Subroutine root_labels: not called CC=2 SCAR=17.9
Pod documented
159 0 my ( $self, $root ) = @_;
160  
161 0 ▶ if ( $root->get_layer eq 'p' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($root->get_layer eq 'p') { } 0 0 0
162 0 my $buf = $self->_pnode_labels($root);
163 0 return [ $buf->[0][0], $buf->[1][0], $buf->[2][0] ];
164 }
165 else {
166 return [
167 0 $root->get_layer . "-tree",
168 "zone=" . $root->get_zone->get_label,
169 ''
170 ];
171 }
172 }
173  
174 0 ▶sub node_labels {
Subroutine node_labels: not called CC=2 SCAR=17.9
Pod documented
175 0 my ( $self, $node ) = @_;
176 0 my $layer = $node->get_layer;
177 0 my %subs;
178  
179 0 $subs{t} = \&_tnode_labels;
180 0 $subs{a} = \&_anode_labels;
181 0 $subs{n} = \&_nnode_labels;
182 0 $subs{p} = \&_pnode_labels;
183 0 ▶ if ( defined $subs{$layer} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $subs{$layer}) { } 0 0 0
184 0 return &{ $subs{$layer} }( $self, $node );
185 }
186 else {
187 0 log_fatal "Undefined or unknown layer: $layer";
188 }
189 }
190  
191 0 ▶sub _anode_labels {
Subroutine _anode_labels: not called CC=26 SCAR=65.5
192 0 my ( $self, $node ) = @_;
193  
194 0 my $line1 = '';
195 0 my $par = 0;
196 0 my $n = $node;
197 0 ▶ while ( ( not $par ) and $n ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $par and $n) 0 0 0
Condition0%0/3
not $par and $n
!ll&&!rl&&r
000
MC/DC0%0/2
not $par and $n
not $par $n
Truth table0%0/3
not(A) and B
A= not $parB= $n
ABresult
0X0
100
111
198 0 ▶ if ( $n->{is_parenthesis_root} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n->{"is_parenthesis_root"}) 0 0 0
199 0 $par = 1;
200 }
201 0 $n = $n->parent;
202 }
203 0 ▶ if ($par) {
Branch: 1 branch
BranchTrueFalseTotal
if ($par) 0 0 0
204 0 $line1 = $self->_colors->get( 'parenthesis', 1 );
205 }
206 0 ▶ if ( defined($node->form) ){
Branch: 2 branches
BranchTrueFalseTotal
if (defined $node->form) { } 0 0 0
elsif (defined $node->lemma) { } 0 0 0
207 0 $line1 .= $node->form;
208 }
209 elsif ( defined($node->lemma) ){
210 0 $line1 .= $self->_colors->get( 'error', 1 ) . $node->lemma;
211 }
212  
213 0 ▶ my $edge_label = $node->deprel || $node->afun || $node->conll_deprel;
Condition0%0/6
$node->deprel || $node->afun || $node->conll_deprel
l!l&&r!l&&!r
000
$node->deprel or $node->afun
l!l&&r!l&&!r
000
MC/DC0%0/3
$node->deprel || $node->afun || $node->conll_deprel
$node->deprel $node->afun $node->conll_deprel
Truth table0%0/4
A or B || C
A= $node->deprelB= $node->afunC= $node->conll_deprel
ABCresult
1XX1
01X1
0011
0000
214 0 ▶ my $color = $edge_label && $edge_label ne 'NR' ? $self->_colors->get( 'afun', 1 ) : $self->_colors->get( 'error', 1 );
Branch: 1 branch
BranchTrueFalseTotal
$edge_label && $edge_label ne 'NR' ? : 0 0 0
Condition0%0/3
$edge_label and $edge_label ne "NR"
!ll&&!rl&&r
000
MC/DC0%0/2
$edge_label and $edge_label ne "NR"
$edge_label $edge_label ne "NR"
Truth table0%0/3
A and B
A= $edge_labelB= $edge_label ne "NR"
ABresult
0X0
100
111
215 0 ▶ my $line2 = $color . ( $edge_label || '!!' );
Condition0%0/2
$edge_label || '!!'
l!l
00
MC/DC0%0/1
$edge_label || '!!'
$edge_label
Truth table0%0/2
A
A= $edge_label
Aresult
11
00
216 0 ▶ if ( $node->is_member ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_member) 0 0 0
217 0 my $parent = $node->parent;
218 0 ▶ while ( $parent && ( ( $parent->afun || '' ) =~ m/^Aux[CP]$/ ) ) #skip AuxCP
Branch: 1 branch
BranchTrueFalseTotal
if ($parent and ($parent->afun || "") =~ /^Aux[CP]$/) 0 0 0
Condition0%0/5
$parent and ($parent->afun || "") =~ /^Aux[CP]$/
!ll&&!rl&&r
000
$parent->afun || ''
l!l
00
MC/DC0%0/2
$parent and ($parent->afun || "") =~ /^Aux[CP]$/
$parent $parent->afun
Truth table0%0/3
A and B
A= $parentB= $parent->afun
ABresult
0X0
100
111
219 {
220 0 $parent = $parent->parent;
221 }
222 0 my $pafun = $parent->afun();
223 0 ▶ $pafun = $parent->deprel() if(!defined($pafun));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pafun 0 0 0
224 0 ▶ $pafun = '' if(!defined($pafun));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $pafun 0 0 0
225 0 ▶ if ( $pafun =~ m/^(Ap)os|(Co)ord/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pafun =~ /^(Ap)os|(Co)ord/) 0 0 0
226 0 ▶ $line2 .= '_' . $self->_colors->get( 'member', 1 ) . ( $1 ? $1 : $2 );
Branch: 1 branch
BranchTrueFalseTotal
$1 ? : 0 0 0
227 }
228 }
229 0 ▶ if ( $node->translit ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->translit) 0 0 0
230 0 $line2 .= ' ' . $self->_colors->get( 'translit', 1 ) . $node->translit;
231 }
232 0 ▶ if ( $node->gloss ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->gloss) 0 0 0
233 0 $line2 .= ' ' . $self->_colors->get( 'gloss', 1 ) . $node->gloss;
234 }
235  
236 0 ▶ my $line3_1 = $node->tag ? $node->tag : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->tag ? : 0 0 0
237 0 ▶ my $line3_2 = $node->lemma ? $node->lemma : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->lemma ? : 0 0 0
238  
239 # DZ: This hack tries to distinguish Dan's CoNLL trees from Pepa's PEDT trees
240 # so that Czech tags don't get crippled in the former.
241 # if ( $node->language eq 'cs' ) {
242 0 ▶ if ( $node->language eq 'cs' && !$node->conll_cpos ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->language eq "cs" and not $node->conll_cpos) 0 0 0
Condition0%0/3
$node->language eq "cs" and not $node->conll_cpos
!ll&&!rl&&r
000
MC/DC0%0/2
$node->language eq "cs" and not $node->conll_cpos
$node->language eq "cs" not $node->conll_cpos
Truth table0%0/3
A and not(B)
A= $node->language eq "cs"B= not $node->conll_cpos
ABresult
0X0
100
111
243 0 $line3_1 = $self->_shorten_czech_tag( $line3_1 );
244 0 $line3_2 =~ s/(.)(?:-[1-9][0-9]*)?(?:(?:`|_[:;,^]).*)?$/$1/;
245 }
246  
247 0 $line3_1 = $self->_colors->get( 'tag', 1 ) . $line3_1;
248  
249 return [
250 0 [$line1],
251 [$line2],
252 [ $line3_1, $line3_2 ]
253 ];
254 }
255  
256 0 ▶sub _shorten_czech_tag {
Subroutine _shorten_czech_tag: not called CC=4 SCAR=30.0
257 0 my ($self, $tag) = @_;
258
259 # nouns, adjectives, pronouns, declinable numerals: gender, number, case
260 0 ▶ if ($tag =~ m/^(N|C[adhjklnrwyz\?]|P|A)/){
Branch: 3 branches
BranchTrueFalseTotal
if ($tag =~ /^(N|C[adhjklnrwyz\?]|P|A)/) { } 0 0 0
elsif ($tag =~ /^R/) { } 0 0 0
elsif ($tag =~ /^V[^cf]/) { } 0 0 0
261 0 $tag = substr( $tag, 0, 2 ) . $self->_colors->get( 'tag_feat', 1 ) . substr( $tag, 2, 3 );
262 }
263 # prepositions: just case
264 elsif ($tag =~ m/^R/ ){
265 0 $tag = substr( $tag, 0, 2 ) . $self->_colors->get( 'tag_feat', 1 ) . substr( $tag, 4, 1 );
266 }
267 # verbs (except infinitives, conditionals): gender, number, person, tense, voice
268 elsif ($tag =~ m/^V[^cf]/ ){
269 0 $tag = substr( $tag, 0, 2) . $self->_colors->get( 'tag_feat', 1 )
270 . substr( $tag, 2, 2 ) . substr( $tag, 7, 2 ) . substr( $tag, 11, 1 );
271 }
272 else {
273 0 $tag = substr( $tag, 0, 2 );
274 }
275 0 return $tag;
276 }
277  
278 0 ▶sub _tnode_labels {
Subroutine _tnode_labels: not called CC=22 SCAR=62.3
279 0 my ( $self, $node ) = @_;
280  
281 0 my $line1 = $node->t_lemma;
282 0 ▶ if ( $node->is_parenthesis ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_parenthesis) 0 0 0
283 0 $line1 = $self->_colors->get( 'parenthesis', 1 ) . $line1;
284 }
285 0 ▶ if ( $node->sentmod ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->sentmod) 0 0 0
286 0 $line1 .= $self->_colors->get( 'sentmod', 1 ) . '.' . $node->sentmod;
287 }
288  
289 0 foreach my $type ( 'compl', 'coref_text', 'coref_gram', 'bridging' ) {
290 0 ▶ if ( defined $node->{ $type . '.rf' } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $$node{$type . '.rf'}) { } 0 0 0
elsif (defined $node->{$type}) { } 0 0 0
291 0 foreach my $ref ( TredMacro::ListV( $node->{ $type . '.rf' } ) ) {
292 0 my $ref_node = $self->_treex_doc->get_node_by_id($ref);
293 0 ▶ if ( $node->get_bundle->get_position() != $ref_node->get_bundle->get_position() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->get_bundle->get_position != $ref_node->get_bundle->get_position) 0 0 0
294 0 $line1 .= ' ' . $self->_colors->get( $type, 1 ) . $ref_node->{t_lemma};
295 }
296 }
297 }
298 elsif ( defined $node->{ $type } ) {
299 0 foreach my $ref ( map {$_->{ 'target_node.rf' }} TredMacro::ListV( $node->{ $type } ) ) {
300 0 my $ref_node = $self->_treex_doc->get_node_by_id($ref);
301 0 ▶ if ( $node->get_bundle->get_position() != $ref_node->get_bundle->get_position() ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->get_bundle->get_position != $ref_node->get_bundle->get_position) 0 0 0
302 0 $line1 .= ' ' . $self->_colors->get( $type, 1 ) . $ref_node->{t_lemma};
303 }
304 }
305 }
306 }
307  
308 0 my $line2 = $node->{functor};
309 0 ▶ $line2 .= $self->_colors->get( 'subfunctor', 1 ) . '.' . $node->{subfunctor} if $node->{subfunctor};
Branch: 1 branch
BranchTrueFalseTotal
if $node->{"subfunctor"} 0 0 0
310 0 ▶ $line2 .= $self->_colors->get( 'subfunctor', 1 ) . '.state' if $node->{is_state};
Branch: 1 branch
BranchTrueFalseTotal
if $node->{"is_state"} 0 0 0
311 0 ▶ $line2 .= $self->_colors->get( 'subfunctor', 1 ) . '.dsp_root' if $node->{is_dsp_root};
Branch: 1 branch
BranchTrueFalseTotal
if $node->{"is_dsp_root"} 0 0 0
312 0 ▶ $line2 .= $self->_colors->get( 'member', 1 ) . '.member' if $node->{is_member};
Branch: 1 branch
BranchTrueFalseTotal
if $node->{"is_member"} 0 0 0
313 0 ▶ $line2 .= $self->_colors->get( 'formeme', 1 ) . ' ' . $node->formeme if $node->formeme;
Branch: 1 branch
BranchTrueFalseTotal
if $node->formeme 0 0 0
314  
315 0 my @a_nodes = ();
316 0 my $line3_1 = '';
317 0 ▶ if ( defined $node->attr('a/aux.rf') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->attr("a/aux.rf")) 0 0 0
318 0 @a_nodes = TredMacro::ListV( $node->attr('a/aux.rf') );
319 0 @a_nodes = map { $self->_treex_doc->get_node_by_id($_) } @a_nodes;
320 0 @a_nodes = map { { form => $_->{form}, ord => $_->{ord}, type => 'aux' } } @a_nodes;
321 }
322 0 ▶ if ( defined $node->attr('a/lex.rf') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $node->attr("a/lex.rf")) 0 0 0
323 0 my $a_node = $self->_treex_doc->get_node_by_id( $node->attr('a/lex.rf') );
324 0 push @a_nodes, { form => $a_node->{form}, ord => $a_node->{ord}, type => 'lex' };
325 }
326 0 ▶ if (@a_nodes) {
Branch: 1 branch
BranchTrueFalseTotal
if (@a_nodes) 0 0 0
327 0 @a_nodes = sort { $a->{ord} <=> $b->{ord} } @a_nodes;
328 0 ▶ @a_nodes = map { ( $_->{type} eq 'lex' ? $self->_colors->get( 'lex', 1 ) : $self->_colors->get( 'aux', 1 ) ) . ( $_->{form} // '' ) } @a_nodes; #/
Branch: 1 branch
BranchTrueFalseTotal
$_->{'type'} eq 'lex' ? : 0 0 0
Condition0%0/2
$_->{"form"} // ""
l!l
00
MC/DC0%0/1
$_->{"form"} // ""
$_->{"form"}
Truth table0%0/2
A
A= $_->{"form"}
Aresult
11
00
329 0 $line3_1 = join " ", @a_nodes;
330 }
331  
332 0 ▶ my $line3_2 = $self->_colors->get( 'nodetype', 1 ) . ($node->{nodetype} || '');
Condition0%0/2
$node->{'nodetype'} || ''
l!l
00
MC/DC0%0/1
$node->{'nodetype'} || ''
$node->{'nodetype'}
Truth table0%0/2
A
A= $node->{'nodetype'}
Aresult
11
00
333 0 ▶ $line3_2 .= $self->_colors->get( 'sempos', 1 ) . '.' . $node->attr('gram/sempos') if $node->attr('gram/sempos');
Branch: 1 branch
BranchTrueFalseTotal
if $node->attr("gram/sempos") 0 0 0
334  
335 return [
336 0 [$line1],
337 [$line2],
338 [ $line3_1, $line3_2 ]
339 ];
340 }
341  
342 0 ▶sub _nnode_labels {
Subroutine _nnode_labels: not called CC=1 SCAR=6.9
343 0 my ( $self, $node ) = @_;
344 return [
345 [ $node->{normalized_name} ],
346 0 [ $node->{ne_type} ],
347 []
348 ];
349 }
350  
351 0 ▶sub _pnode_labels {
Subroutine _pnode_labels: not called CC=5 SCAR=34.0
352 0 my ( $self, $node ) = @_;
353  
354 # my $terminal = $node->get_pml_type_name eq 'p-terminal.type' ? 1 : 0;
355  
356 0 my $line1 = '';
357 0 my $line2 = '';
358 0 ▶ my $edgelabel = $node->edgelabel() ? '/'.$node->edgelabel() : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->edgelabel ? : 0 0 0
359 # print "$node is_leaf ".$node->is_leaf."\n";
360 0 ▶ if ( $node->is_leaf ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->is_leaf) { } 0 0 0
361 0 $line1 = $node->{form};
362 0 $line2 = $node->{tag}.$edgelabel;
363 0 ▶ $line2 = '-' if $line2 eq '-NONE-';
Branch: 1 branch
BranchTrueFalseTotal
if $line2 eq "-NONE-" 0 0 0
364 }
365 else {
366 0 ▶ my $phrase = $node->{phrase} ? $node->{phrase} : '';
Branch: 1 branch
BranchTrueFalseTotal
$node->{'phrase'} ? : 0 0 0
367 0 $line1 = $self->_colors->get( 'phrase', 1 ) . $phrase.$edgelabel . '#{black}' . join( '', map {"-$_"} TredMacro::ListV( $node->{functions} ) );
368 }
369  
370 return [
371 0 [$line1],
372 [$line2],
373 ['']
374 ];
375 }
376  
377 2 1;
378  
379 __END__
« Treex/Core/TredView/Styles.pm ↑ Summary Treex/Core/Phrase/Coordination.pm »