Treex/Core/Node/T.pm

filter: Statementstmt 43.0% 121 / 281 Branchbran 37.8% 25 / 66 Conditioncond 29.4% 15 / 51 MC/DCmcdc 4.0% 1 / 25 Subroutinesub 23.2% 20 / 86 Podpod 29.1% 21 / 72 totaltotal 34.9% 203 / 581 CC 57 SCAR 21.8
CC
57
Cov
40%
get_appos_expansion
31.6
_update_list
30.0
get_anodes
30.0
CRAP 8.9
« Treex/Core/Config.pm ↑ Summary Treex/Core/Node/EffectiveRelations.pm »
1 package Treex::Core::Node::T;
2 36 $Treex::Core::Node::T::VERSION = '2.20210102';
3 36 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 36 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 36 ▶use Treex::Core::Common;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 36 extends 'Treex::Core::Node';
8 36 with 'Treex::Core::Node::Ordered';
9 36 with 'Treex::Core::Node::InClause';
10 36 with 'Treex::Core::Node::EffectiveRelations';
11 36 with 'Treex::Core::Node::Interset' => { interset_attribute => 'dset' };
12  
13 # t-layer attributes
14 36 has [
15 qw( nodetype t_lemma functor subfunctor formeme tfa
16 is_dsp_root sentmod is_parenthesis is_passive is_generated
17 is_relclause_head is_name_of_person voice
18 t_lemma_origin formeme_origin is_infin
19 )
20 ] => ( is => 'rw' );
21  
22 83 ▶sub get_pml_type_name {
Subroutine get_pml_type_name: called CC=2 SCAR=6.9
Pod documented
23 83 my ($self) = @_;
24 83 ▶ return $self->is_root() ? 't-root.type' : 't-node.type';
Branch: 1 branch
BranchTrueFalseTotal
$self->is_root ? : 27 56 83
25 }
26  
27 # the node is a root of a coordination/apposition construction
28 # analogy of PML_T::IsCoord
29 47 ▶sub is_coap_root {
Subroutine is_coap_root: called CC=3 SCAR=11.1
Pod documented
30 47 my ($self) = @_;
31 47 ▶ log_fatal("Incorrect number of arguments") if @_ != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ != 1 0 47 47
32 47 ▶ return ( $self->functor || '' ) =~ /^(CONJ|CONFR|DISJ|GRAD|ADVS|CSQ|REAS|CONTRA|APPS|OPER)$/;
Condition100%2/2
$self->functor || ''
l!l
425
MC/DC100%1/1
$self->functor || ''
$self->functor
Truth table100%2/2
A
A= $self->functor
Aresult
11
00
33 }
34  
35 #----------- helpers for reference lists ------------
36  
37 3 ▶sub _get_node_list {
Subroutine _get_node_list: called CC=3 SCAR=11.0
38 3 my ( $self, $list, $arg_ref ) = @_;
39 3 $list = $self->get_attr($list);
40 3 my $doc = $self->get_document();
41 3 ▶ my @nodes = $list ? ( map { $doc->get_node_by_id($_) } @{$list} ) : ();
Branch: 1 branch
BranchTrueFalseTotal
$list ? : 2 1 3
42 3 ▶ return $arg_ref ? $self->_process_switches( $arg_ref, @nodes ) : @nodes;
Branch: 1 branch
BranchTrueFalseTotal
$arg_ref ? : 0 3 3
43 }
44  
45 0 ▶sub _set_node_list {
Subroutine _set_node_list: not called CC=1 SCAR=6.9
46 0 my $self = shift;
47 0 my $list = shift;
48 0 $self->set_attr( $list, [ map { $_->get_attr('id') } @_ ] );
49 0 return;
50 }
51  
52 1 ▶sub _add_to_node_list {
Subroutine _add_to_node_list: called CC=2 SCAR=7.1
53 1 my $self = shift;
54 1 my $list = shift;
55  
56 # get the current elements of the list
57 1 my $cur_ref = $self->get_attr($list);
58 0 ▶ my @cur = $cur_ref ? @{$cur_ref} : ();
Branch: 1 branch
BranchTrueFalseTotal
$cur_ref ? : 0 1 1
59  
60 # grep only those that aren't already in the list
61 my @new = grep {
62 1 my $id = $_;
63 0 ▶ !any { $_ eq $id } @cur
Subroutine __ANON__: not called CC=1 SCAR=6.9
64 1 } map { $_->get_attr('id') } @_;
65  
66 # set the new list value
67 1 $self->set_attr( $list, [ @cur, @new ] );
68 1 return;
69 }
70  
71 0 ▶sub _remove_from_node_list {
Subroutine _remove_from_node_list: not called CC=3 SCAR=24.8
72 0 my $self = shift;
73 0 my $list = shift;
74 0 my @prev = $self->_get_node_list($list);
75 0 my @remain;
76  
77 0 foreach my $node (@prev) {
78 0 ▶ if ( !grep { $_ == $node } @_ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ == $node;} @_) 0 0 0
79 0 push @remain, $node;
80 }
81 }
82 0 $self->_set_node_list( $list, @remain );
83 0 return;
84 }
85  
86 # TODO: with backrefs this method is no more needed
87 # remove unindexed IDs from a list attribute
88 0 ▶sub _update_list {
Subroutine _update_list: not called CC=5 SCAR=34.0
89  
90 0 my ( $self, $list ) = @_;
91 0 my $doc = $self->get_document();
92  
93 0 my $ref = $self->get_attr($list);
94 0 my (@nodes, @invalid);
95  
96 0 ▶ return if (!$ref);
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 0 0
97  
98 0 foreach my $id (@{$ref}){
99 0 ▶ if ($doc->id_is_indexed($id)){
Branch: 1 branch
BranchTrueFalseTotal
if ($doc->id_is_indexed($id)) { } 0 0 0
100 0 push @nodes, $id;
101 }
102 else {
103 0 push @invalid, $id;
104 }
105 }
106  
107 0 ▶ $self->set_attr( $list, @nodes > 0 ? [@nodes] : undef );
Branch: 1 branch
BranchTrueFalseTotal
@nodes > 0 ? : 0 0 0
108 0 return;
109 }
110  
111 #----------- a-layer (analytical) nodes -------------
112  
113 5 ▶sub get_lex_anode {
Subroutine get_lex_anode: called CC=2 SCAR=6.9
Pod documented
114 5 my ($self) = @_;
115 5 my $lex_rf = $self->get_attr('a/lex.rf');
116 5 my $document = $self->get_document();
117 5 ▶ return $document->get_node_by_id($lex_rf) if $lex_rf;
Branch: 1 branch
BranchTrueFalseTotal
if $lex_rf 4 1 5
118 1 return;
119 }
120  
121 4 ▶sub set_lex_anode {
Subroutine set_lex_anode: called CC=2 SCAR=7.0
Pod documented
122 4 my ( $self, $lex_anode ) = @_;
123 4 ▶ my $new_id = defined $lex_anode ? $lex_anode->get_attr('id') : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $lex_anode ? : 4 0 4
124 4 $self->set_attr( 'a/lex.rf', $new_id );
125 4 return;
126 }
127  
128 0 ▶sub get_aux_anodes {
Subroutine get_aux_anodes: not called CC=4 SCAR=30.0
Pod documented
129 0 my ( $self, $arg_ref ) = @_;
130  
131 log_fatal('Switches preceding_only and following_only cannot be used with get_aux_anodes (t-nodes vs. a-nodes).')
132 0 ▶ if $arg_ref and ( $arg_ref->{preceding_only} or $arg_ref->{following_only} );
Branch: 1 branch
BranchTrueFalseTotal
if $arg_ref and $arg_ref->{"preceding_only"} || $arg_ref->{"following_only"} 0 0 0
Condition0%0/6
$arg_ref and $arg_ref->{"preceding_only"} || $arg_ref->{"following_only"}
!ll&&!rl&&r
000
$arg_ref->{"preceding_only"} or $arg_ref->{"following_only"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$arg_ref and $arg_ref->{"preceding_only"} || $arg_ref->{"following_only"}
$arg_ref $arg_ref->{"preceding_only"} $arg_ref->{"following_only"}
Truth table0%0/4
A and B or C
A= $arg_refB= $arg_ref->{"preceding_only"}C= $arg_ref->{"following_only"}
ABCresult
0XX0
1000
11X1
1011
133  
134 0 return $self->_get_node_list( 'a/aux.rf', $arg_ref );
135 }
136  
137 0 ▶sub set_aux_anodes {
Subroutine set_aux_anodes: not called CC=1 SCAR=6.9
Pod documented
138 0 my $self = shift;
139 0 return $self->_set_node_list( 'a/aux.rf', @_ );
140 }
141  
142 0 ▶sub add_aux_anodes {
Subroutine add_aux_anodes: not called CC=1 SCAR=6.9
Pod documented
143 0 my $self = shift;
144 0 return $self->_add_to_node_list( 'a/aux.rf', @_ );
145 }
146  
147 0 ▶sub remove_aux_anodes {
Subroutine remove_aux_anodes: not called CC=1 SCAR=6.9
Pod documented
148 0 my $self = shift;
149 0 return $self->_remove_from_node_list( 'a/aux.rf', @_ );
150 }
151  
152 0 ▶sub get_anodes {
Subroutine get_anodes: not called CC=5 SCAR=34.0
Pod documented
153 0 my ( $self, $arg_ref ) = @_;
154 0 my $lex_anode = $self->get_lex_anode();
155 0 ▶ my @nodes = ( ( defined $lex_anode ? ($lex_anode) : () ), $self->get_aux_anodes() );
Branch: 1 branch
BranchTrueFalseTotal
defined $lex_anode ? : 0 0 0
156 0 ▶ return @nodes if !$arg_ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $arg_ref 0 0 0
157 log_fatal('Switches preceding_only and following_only cannot be used with get_anodes (t-nodes vs. a-nodes).')
158 0 ▶ if $arg_ref->{preceding_only} || $arg_ref->{following_only};
Branch: 1 branch
BranchTrueFalseTotal
if $arg_ref->{"preceding_only"} or $arg_ref->{"following_only"} 0 0 0
Condition0%0/3
$arg_ref->{"preceding_only"} or $arg_ref->{"following_only"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$arg_ref->{"preceding_only"} or $arg_ref->{"following_only"}
$arg_ref->{"preceding_only"} $arg_ref->{"following_only"}
Truth table0%0/3
A or B
A= $arg_ref->{"preceding_only"}B= $arg_ref->{"following_only"}
ABresult
1X1
011
000
159 0 return $self->_process_switches( $arg_ref, @nodes );
160 }
161  
162 #------------ coreference and bridging nodes -------------------
163  
164 5 ▶sub get_appos_expansion {
Subroutine get_appos_expansion: called CC=10 SCAR=34.5
Pod documented
165 5 my ($self, $arg_ref ) = @_;
166 5 ▶ if ($self->is_coap_root && $self->functor eq "APPS") {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->is_coap_root and $self->functor eq 'APPS') { } 0 5 5
Condition33%1/3
$self->is_coap_root and $self->functor eq "APPS"
!ll&&!rl&&r
500
MC/DC0%0/2
$self->is_coap_root and $self->functor eq "APPS"
$self->is_coap_root $self->functor eq "APPS"
Truth table33%1/3
A and B
A= $self->is_coap_rootB= $self->functor eq "APPS"
ABresult
0X0
100
111
167 0 ▶ return ($self->get_coap_members({direct_only => 1}), $arg_ref->{with_appos_root} ? $self : ());
Branch: 1 branch
BranchTrueFalseTotal
$arg_ref->{'with_appos_root'} ? : 0 0 0
168 }
169 else {
170 5 my $par = $self->get_parent;
171 5 ▶ if (defined $par && !$par->is_root && $par->is_coap_root && $par->functor eq "APPS" && $self->is_member ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $par and not $par->is_root and $par->is_coap_root and $par->functor eq "APPS" and $self->is_member) 0 5 5
Condition33%4/12
defined $par and not $par->is_root and $par->is_coap_root and $par->functor eq "APPS" and $self->is_member
!ll&&!rl&&r
500
defined $par and not $par->is_root and $par->is_coap_root and $par->functor eq "APPS"
!ll&&!rl&&r
500
defined $par and not $par->is_root and $par->is_coap_root
!ll&&!rl&&r
500
defined $par and not $par->is_root
!ll&&!rl&&r
050
MC/DC0%0/5
defined $par and not $par->is_root and $par->is_coap_root and $par->functor eq "APPS" and $self->is_member
defined $par not $par->is_root $par->is_coap_root $par->functor eq "APPS" $self->is_member
Truth table16%1/6
A and not(B) and C and D and E
A= defined $parB= not $par->is_rootC= $par->is_coap_rootD= $par->functor eq "APPS"E= $self->is_member
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
172 0 ▶ return ($par->get_coap_members({direct_only => 1}), $arg_ref->{with_appos_root} ? $par : ());
Branch: 1 branch
BranchTrueFalseTotal
$arg_ref->{'with_appos_root'} ? : 0 0 0
173 }
174 }
175 5 return $self;
176 }
177  
178 # types are not allowed for the time being
179 3 ▶sub _unfold_appos {
Subroutine _unfold_appos: called CC=3 SCAR=11.9
180 3 my ( $self, $type ) = @_;
181  
182 3 my @appos_nodes_not_self = grep {$_ != $self} $self->get_appos_expansion({with_appos_root => 1});
183  
184 3 my @member_antes = ();
185 # type = { text, gram, all }
186 3 ▶ if ($type eq "gram") {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'gram') { } 2 1 3
elsif ($type eq 'text') { } 1 0 1
187 0 @member_antes = map {$_->get_coref_gram_nodes({appos_aware => 0})} @appos_nodes_not_self;
188 }
189 elsif ($type eq "text") {
190 0 @member_antes = map {$_->get_coref_text_nodes({appos_aware => 0})} @appos_nodes_not_self;
191 }
192 else {
193 0 @member_antes = map {$_->get_coref_nodes({appos_aware => 0})} @appos_nodes_not_self;
194 }
195 3 return @member_antes;
196 }
197  
198 3 ▶sub _replace_appos_antes {
Subroutine _replace_appos_antes: called CC=1 SCAR=0.0
199 3 my (@antes) = @_;
200 3 my @new_antes = map {$_->get_appos_expansion({with_appos_root => 0})} @antes;
201 3 my %seen = ();
202 3 my @unique_antes = grep { !$seen{$_->id}++ } @new_antes;
203 3 return @unique_antes;
204 }
205  
206 3 ▶sub _get_coref_nodes {
Subroutine _get_coref_nodes: called CC=11 SCAR=27.1
207 3 my ($self, $type, $arg_ref) = @_;
208  
209 3 ▶ my $appos_aware = $arg_ref->{appos_aware} // 1;
Condition50%1/2
$arg_ref->{"appos_aware"} // 1
l!l
03
MC/DC0%0/1
$arg_ref->{"appos_aware"} // 1
$arg_ref->{"appos_aware"}
Truth table50%1/2
A
A= $arg_ref->{"appos_aware"}
Aresult
11
00
210 3 ▶ my $with_types = $arg_ref->{with_types} // 0;
Condition50%1/2
$arg_ref->{"with_types"} // 0
l!l
03
MC/DC0%0/1
$arg_ref->{"with_types"} // 0
$arg_ref->{"with_types"}
Truth table50%1/2
A
A= $arg_ref->{"with_types"}
Aresult
11
00
211 3 delete $arg_ref->{$_} foreach (qw/appos_aware with_types/);
212  
213 3 my @antes = ();
214 3 my @types = ();
215  
216 3 ▶ if ($type ne 'text') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "text") 2 1 3
217 2 my @gram_nodes = $self->_get_node_list('coref_gram.rf');
218 2 push @antes, @gram_nodes;
219 2 push @types, map {undef} @gram_nodes;
220 }
221 3 ▶ if ($type ne 'gram') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "gram") 1 2 3
222 # textual coreference in PDT2.0 and 2.5 style
223 1 my @text_nodes = $self->_get_node_list('coref_text.rf');
224 1 push @antes, @text_nodes;
225 1 push @types, map {undef} @text_nodes;
226 # textual coreference in PDT3.0 style
227 1 ▶ my $pdt30_text_coref_rf = $self->get_attr('coref_text') // [];
Condition50%1/2
$self->get_attr("coref_text") // []
l!l
01
MC/DC0%0/1
$self->get_attr("coref_text") // []
$self->get_attr("coref_text")
Truth table50%1/2
A
A= $self->get_attr("coref_text")
Aresult
11
00
228 0 @text_nodes = map {$self->get_document->get_node_by_id( $_->{'target_node.rf'} )} @$pdt30_text_coref_rf;
229 0 my @text_types = map { $_->{'type'} } @$pdt30_text_coref_rf;
230 1 push @antes, @text_nodes;
231 1 push @types, @text_types;
232 }
233  
234 # for the time being, apposition-aware handling is disabled if types are demanded
235 3 ▶ if (!$with_types && $appos_aware) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $with_types and $appos_aware) 3 0 3
Condition33%1/3
not $with_types and $appos_aware
!ll&&!rl&&r
003
MC/DC0%0/2
not $with_types and $appos_aware
not $with_types $appos_aware
Truth table33%1/3
not(A) and B
A= not $with_typesB= $appos_aware
ABresult
0X0
100
111
236 3 push @antes, $self->_unfold_appos($type);
237 3 @antes = _replace_appos_antes(@antes);
238 }
239  
240 3 my @filtered_antes = $self->_process_switches( $arg_ref, @antes );
241 3 ▶ return @filtered_antes if (!$with_types);
Branch: 1 branch
BranchTrueFalseTotal
unless $with_types 3 0 3
242  
243 # return both nodes and types (as list references - similar to alignments)
244 0 my %node_id_to_index = map {$antes[$_]->id => $_} 0 .. $#antes;
245 my @filtered_types = map {
246 0 my $idx = $node_id_to_index{$_->id};
247 0 ▶ defined $idx ? $types[$idx] : undef
Branch: 1 branch
BranchTrueFalseTotal
defined $idx ? : 0 0 0
248 } @filtered_antes;
249 0 return (\@filtered_antes, \@filtered_types);
250 }
251  
252  
253 0 ▶sub get_coref_nodes {
Subroutine get_coref_nodes: not called CC=1 SCAR=6.9
Pod documented
254 0 my ( $self, $arg_ref ) = @_;
255 0 return $self->_get_coref_nodes('all', $arg_ref);
256 }
257  
258 2 ▶sub get_coref_gram_nodes {
Subroutine get_coref_gram_nodes: called CC=1 SCAR=0.0
Pod documented
259 2 my ( $self, $arg_ref ) = @_;
260 2 return $self->_get_coref_nodes('gram', $arg_ref);
261 }
262  
263 1 ▶sub get_coref_text_nodes {
Subroutine get_coref_text_nodes: called CC=1 SCAR=0.0
Pod documented
264 1 my ( $self, $arg_ref ) = @_;
265 1 return $self->_get_coref_nodes('text', $arg_ref);
266 }
267  
268  
269 # it doesn't return a complete chain, just the members which are accessible
270 # from the current node
271 # TODO: with backrefs the whole chain is accessible now
272 0 ▶sub get_coref_chain {
Subroutine get_coref_chain: not called CC=4 SCAR=30.0
Pod undocumented
273 0 my ( $self, $arg_ref ) = @_;
274  
275 0 my %visited_nodes = ();
276 0 my @nodes;
277 0 my %sub_args = map {$_ => $arg_ref->{$_}} qw/appos_aware with_types/;
278 0 my @queue = $self->get_coref_nodes(\%sub_args);
279 0 ▶ while ( my $node = shift @queue ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $node = shift @queue) 0 0 0
280 0 $visited_nodes{$node} = 1;
281 0 push @nodes, $node;
282 0 my @antes = $node->get_coref_nodes(\%sub_args);
283 0 foreach my $ante (@antes) {
284 0 ▶ if ( !defined $visited_nodes{$ante} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $visited_nodes{$ante}) 0 0 0
285 0 push @queue, $ante;
286 }
287 }
288 }
289  
290 0 return $self->_process_switches( $arg_ref, @nodes );
291 }
292  
293 2 ▶sub select_node_if_apps {
Subroutine select_node_if_apps: called CC=6 SCAR=24.2
Pod undocumented
294 2 my ($node) = @_;
295 2 my $par = $node->get_parent;
296 2 ▶ if (defined $par && !$par->is_root && $par->is_coap_root && $par->functor eq "APPS" && $node->is_member ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $par and not $par->is_root and $par->is_coap_root and $par->functor eq "APPS" and $node->is_member) 0 2 2
Condition33%4/12
defined $par and not $par->is_root and $par->is_coap_root and $par->functor eq "APPS" and $node->is_member
!ll&&!rl&&r
200
defined $par and not $par->is_root and $par->is_coap_root and $par->functor eq "APPS"
!ll&&!rl&&r
200
defined $par and not $par->is_root and $par->is_coap_root
!ll&&!rl&&r
200
defined $par and not $par->is_root
!ll&&!rl&&r
020
MC/DC0%0/5
defined $par and not $par->is_root and $par->is_coap_root and $par->functor eq "APPS" and $node->is_member
defined $par not $par->is_root $par->is_coap_root $par->functor eq "APPS" $node->is_member
Truth table16%1/6
A and not(B) and C and D and E
A= defined $parB= not $par->is_rootC= $par->is_coap_rootD= $par->functor eq "APPS"E= $node->is_member
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
297 0 return $par;
298 }
299 2 return $node;
300 }
301  
302 1 ▶sub _add_coref_nodes {
Subroutine _add_coref_nodes: called CC=3 SCAR=11.2
303 1 my ($self, $type, @antes) = @_;
304  
305 # if called on a member of an apposition, call it on the apposition root
306 1 my $anaph = select_node_if_apps($self);
307 1 ▶ if ($anaph != $self) {
Branch: 1 branch
BranchTrueFalseTotal
if ($anaph != $self) 0 1 1
308 0 return $anaph->_add_coref_nodes($type, @antes);
309 }
310  
311 # antes must be apposition roots if in apposition
312 1 @antes = map {select_node_if_apps($_)} @antes;
313  
314 # avoid link repeating and self-reference
315 1 my %seen;
316 1 @antes = grep {$_ != $self} grep {!$seen{$_->id}++} @antes;
317 1 ▶ return if (!@antes);
Branch: 1 branch
BranchTrueFalseTotal
unless @antes 0 1 1
318  
319 1 $self->_add_to_node_list( "coref_$type.rf", @antes );
320 }
321  
322 1 ▶sub add_coref_gram_nodes {
Subroutine add_coref_gram_nodes: called CC=1 SCAR=0.0
Pod documented
323 1 my $self = shift;
324 1 $self->_add_coref_nodes('gram', @_);
325 }
326  
327 0 ▶sub add_coref_text_nodes {
Subroutine add_coref_text_nodes: not called CC=1 SCAR=6.9
Pod undocumented
328 0 my $self = shift;
329 0 $self->_add_coref_nodes('text', @_);
330 }
331  
332 0 ▶sub remove_coref_nodes {
Subroutine remove_coref_nodes: not called CC=1 SCAR=6.9
Pod documented
333 0 my $self = shift;
334 0 $self->_remove_from_node_list( 'coref_gram.rf', @_ );
335 0 $self->_remove_from_node_list( 'coref_text.rf', @_ );
336 0 return;
337 }
338  
339 # remove unindexed IDs from coreference lists
340 0 ▶sub update_coref_nodes {
Subroutine update_coref_nodes: not called CC=1 SCAR=6.9
Pod documented
341 0 my $self = shift;
342  
343 0 $self->_update_list('coref_gram.rf');
344 0 $self->_update_list('coref_text.rf');
345 0 return;
346 }
347  
348 0 ▶sub get_bridging_nodes {
Subroutine get_bridging_nodes: not called CC=2 SCAR=17.9
Pod documented
349 0 my ($self, $arg_ref) = @_;
350 0 ▶ my $bridging = $self->get_attr('bridging') // [];
Condition0%0/2
$self->get_attr("bridging") // []
l!l
00
MC/DC0%0/1
$self->get_attr("bridging") // []
$self->get_attr("bridging")
Truth table0%0/2
A
A= $self->get_attr("bridging")
Aresult
11
00
351 0 my $doc = $self->get_document;
352 0 my @nodes = map {$doc->get_node_by_id($_->{'target_node.rf'})} @$bridging;
353 0 my @types = map {$_->{'type'}} @$bridging;
354 0 return (\@nodes, \@types);
355 }
356  
357 0 ▶sub add_bridging_node {
Subroutine add_bridging_node: not called CC=2 SCAR=17.9
Pod documented
358 0 my ( $self, $node, $type ) = @_;
359 0 my $links_rf = $self->get_attr('bridging');
360 0 ▶ my %new_link = ( 'target_node.rf' => $node->id, 'type' => $type // ''); #/ so we have no undefs
Condition0%0/2
$type // ""
l!l
00
MC/DC0%0/1
$type // ""
$type
Truth table0%0/2
A
A= $type
Aresult
11
00
361 0 push( @$links_rf, \%new_link );
362 0 $self->set_attr( 'bridging', $links_rf );
363 0 return;
364 }
365  
366 # ----------- complement nodes -------------
367  
368 0 ▶sub get_compl_nodes {
Subroutine get_compl_nodes: not called CC=1 SCAR=6.9
Pod undocumented
369 0 my ( $self, $arg_ref ) = @_;
370 0 return $self->_get_node_list( 'compl.rf', $arg_ref );
371 }
372  
373 0 ▶sub add_compl_nodes {
Subroutine add_compl_nodes: not called CC=1 SCAR=6.9
Pod undocumented
374 0 my $self = shift;
375 0 return $self->_add_to_node_list( 'compl.rf', @_ );
376 }
377  
378 0 ▶sub remove_compl_nodes {
Subroutine remove_compl_nodes: not called CC=1 SCAR=6.9
Pod undocumented
379 0 my $self = shift;
380 0 $self->_remove_from_node_list( 'compl.rf', @_ );
381 0 return;
382 }
383  
384 0 ▶sub update_compl_nodes {
Subroutine update_compl_nodes: not called CC=1 SCAR=6.9
Pod undocumented
385 0 my $self = shift;
386 0 $self->_update_list('compl.rf');
387 0 return;
388 }
389  
390 #----------- n-layer (named entity) nodes -------------
391  
392 2 ▶sub get_n_node {
Subroutine get_n_node: called CC=2 SCAR=7.1
Pod documented
393 2 my ($self) = @_;
394 2 ▶ my $lex_anode = $self->get_lex_anode() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $lex_anode = $self->get_lex_anode or return 2 0 2
395 2 return $lex_anode->n_node();
396 }
397  
398 #----------- source t-layer (source-language in MT) nodes -------------
399  
400 0 ▶sub src_tnode {
Subroutine src_tnode: not called CC=2 SCAR=17.9
Pod documented
401 0 my ($self) = @_;
402 0 ▶ my $source_node_id = $self->get_attr('src_tnode.rf') or return;
Branch: 1 branch
BranchTrueFalseTotal
my $source_node_id = $self->get_attr("src_tnode.rf") or return 0 0 0
403 0 return $self->get_document->get_node_by_id($source_node_id);
404 }
405  
406 0 ▶sub set_src_tnode {
Subroutine set_src_tnode: not called CC=1 SCAR=6.9
Pod documented
407 0 my ( $self, $source_node ) = @_;
408 0 $self->set_attr( 'src_tnode.rf', $source_node->id );
409 0 return;
410 }
411  
412 # ---- attributes that contain references
413  
414 105 ▶override '_get_reference_attrs' => sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
415  
416 105 my ($self) = @_;
417 105 return ('a/lex.rf', 'original_parent.rf', 'src_tnode.rf', 'a/aux.rf', 'compl.rf', 'coref_gram.rf', 'coref_text.rf');
418 36 };
419  
420 #----------- grammatemes -------------
421  
422 #TODO: make these real Moose attributes
423 0 ▶sub gram_sempos { return $_[0]->get_attr('gram/sempos'); }
Subroutine gram_sempos: not called CC=1 SCAR=6.9
Pod undocumented
424 0 ▶sub gram_gender { return $_[0]->get_attr('gram/gender'); }
Subroutine gram_gender: not called CC=1 SCAR=6.9
Pod undocumented
425 0 ▶sub gram_number { return $_[0]->get_attr('gram/number'); }
Subroutine gram_number: not called CC=1 SCAR=6.9
Pod undocumented
426 0 ▶sub gram_degcmp { return $_[0]->get_attr('gram/degcmp'); }
Subroutine gram_degcmp: not called CC=1 SCAR=6.9
Pod undocumented
427 0 ▶sub gram_verbmod { return $_[0]->get_attr('gram/verbmod'); }
Subroutine gram_verbmod: not called CC=1 SCAR=6.9
Pod undocumented
428 0 ▶sub gram_deontmod { return $_[0]->get_attr('gram/deontmod'); }
Subroutine gram_deontmod: not called CC=1 SCAR=6.9
Pod undocumented
429 0 ▶sub gram_factmod { return $_[0]->get_attr('gram/factmod'); }
Subroutine gram_factmod: not called CC=1 SCAR=6.9
Pod undocumented
430 0 ▶sub gram_tense { return $_[0]->get_attr('gram/tense'); }
Subroutine gram_tense: not called CC=1 SCAR=6.9
Pod undocumented
431 0 ▶sub gram_aspect { return $_[0]->get_attr('gram/aspect'); }
Subroutine gram_aspect: not called CC=1 SCAR=6.9
Pod undocumented
432 0 ▶sub gram_resultative { return $_[0]->get_attr('gram/resultative'); }
Subroutine gram_resultative: not called CC=1 SCAR=6.9
Pod undocumented
433 0 ▶sub gram_dispmod { return $_[0]->get_attr('gram/dispmod'); }
Subroutine gram_dispmod: not called CC=1 SCAR=6.9
Pod undocumented
434 0 ▶sub gram_iterativeness { return $_[0]->get_attr('gram/iterativeness'); }
Subroutine gram_iterativeness: not called CC=1 SCAR=6.9
Pod undocumented
435 0 ▶sub gram_indeftype { return $_[0]->get_attr('gram/indeftype'); }
Subroutine gram_indeftype: not called CC=1 SCAR=6.9
Pod undocumented
436 0 ▶sub gram_person { return $_[0]->get_attr('gram/person'); }
Subroutine gram_person: not called CC=1 SCAR=6.9
Pod undocumented
437 0 ▶sub gram_numertype { return $_[0]->get_attr('gram/numertype'); }
Subroutine gram_numertype: not called CC=1 SCAR=6.9
Pod undocumented
438 0 ▶sub gram_politeness { return $_[0]->get_attr('gram/politeness'); }
Subroutine gram_politeness: not called CC=1 SCAR=6.9
Pod undocumented
439 0 ▶sub gram_negation { return $_[0]->get_attr('gram/negation'); }
Subroutine gram_negation: not called CC=1 SCAR=6.9
Pod undocumented
440 0 ▶sub gram_definiteness { return $_[0]->get_attr('gram/definiteness'); }
Subroutine gram_definiteness: not called CC=1 SCAR=6.9
Pod undocumented
441 0 ▶sub gram_diathesis { return $_[0]->get_attr('gram/diathesis'); }
Subroutine gram_diathesis: not called CC=1 SCAR=6.9
Pod undocumented
442 0 ▶sub gram_diatgram { return $_[0]->get_attr('gram/diatgram'); }
Subroutine gram_diatgram: not called CC=1 SCAR=6.9
Pod undocumented
443 0 ▶sub gram_typgroup { return $_[0]->get_attr('gram/typgroup'); }
Subroutine gram_typgroup: not called CC=1 SCAR=6.9
Pod undocumented
444  
445 0 ▶sub set_gram_sempos { return $_[0]->set_attr( 'gram/sempos', $_[1] ); }
Subroutine set_gram_sempos: not called CC=1 SCAR=6.9
Pod undocumented
446 0 ▶sub set_gram_gender { return $_[0]->set_attr( 'gram/gender', $_[1] ); }
Subroutine set_gram_gender: not called CC=1 SCAR=6.9
Pod undocumented
447 0 ▶sub set_gram_number { return $_[0]->set_attr( 'gram/number', $_[1] ); }
Subroutine set_gram_number: not called CC=1 SCAR=6.9
Pod undocumented
448 0 ▶sub set_gram_degcmp { return $_[0]->set_attr( 'gram/degcmp', $_[1] ); }
Subroutine set_gram_degcmp: not called CC=1 SCAR=6.9
Pod undocumented
449 0 ▶sub set_gram_verbmod { return $_[0]->set_attr( 'gram/verbmod', $_[1] ); }
Subroutine set_gram_verbmod: not called CC=1 SCAR=6.9
Pod undocumented
450 0 ▶sub set_gram_deontmod { return $_[0]->set_attr( 'gram/deontmod', $_[1] ); }
Subroutine set_gram_deontmod: not called CC=1 SCAR=6.9
Pod undocumented
451 0 ▶sub set_gram_factmod { return $_[0]->set_attr( 'gram/factmod', $_[1] ); }
Subroutine set_gram_factmod: not called CC=1 SCAR=6.9
Pod undocumented
452 0 ▶sub set_gram_tense { return $_[0]->set_attr( 'gram/tense', $_[1] ); }
Subroutine set_gram_tense: not called CC=1 SCAR=6.9
Pod undocumented
453 0 ▶sub set_gram_aspect { return $_[0]->set_attr( 'gram/aspect', $_[1] ); }
Subroutine set_gram_aspect: not called CC=1 SCAR=6.9
Pod undocumented
454 0 ▶sub set_gram_resultative { return $_[0]->set_attr( 'gram/resultative', $_[1] ); }
Subroutine set_gram_resultative: not called CC=1 SCAR=6.9
Pod undocumented
455 0 ▶sub set_gram_dispmod { return $_[0]->set_attr( 'gram/dispmod', $_[1] ); }
Subroutine set_gram_dispmod: not called CC=1 SCAR=6.9
Pod undocumented
456 0 ▶sub set_gram_iterativeness { return $_[0]->set_attr( 'gram/iterativeness', $_[1] ); }
Subroutine set_gram_iterativeness: not called CC=1 SCAR=6.9
Pod undocumented
457 0 ▶sub set_gram_indeftype { return $_[0]->set_attr( 'gram/indeftype', $_[1] ); }
Subroutine set_gram_indeftype: not called CC=1 SCAR=6.9
Pod undocumented
458 0 ▶sub set_gram_person { return $_[0]->set_attr( 'gram/person', $_[1] ); }
Subroutine set_gram_person: not called CC=1 SCAR=6.9
Pod undocumented
459 0 ▶sub set_gram_numertype { return $_[0]->set_attr( 'gram/numertype', $_[1] ); }
Subroutine set_gram_numertype: not called CC=1 SCAR=6.9
Pod undocumented
460 0 ▶sub set_gram_politeness { return $_[0]->set_attr( 'gram/politeness', $_[1] ); }
Subroutine set_gram_politeness: not called CC=1 SCAR=6.9
Pod undocumented
461 0 ▶sub set_gram_negation { return $_[0]->set_attr( 'gram/negation', $_[1] ); }
Subroutine set_gram_negation: not called CC=1 SCAR=6.9
Pod undocumented
462 0 ▶sub set_gram_definiteness { return $_[0]->set_attr( 'gram/definiteness', $_[1] ); }
Subroutine set_gram_definiteness: not called CC=1 SCAR=6.9
Pod undocumented
463 0 ▶sub set_gram_diathesis { return $_[0]->set_attr( 'gram/diathesis', $_[1] ); }
Subroutine set_gram_diathesis: not called CC=1 SCAR=6.9
Pod undocumented
464 0 ▶sub set_gram_diatgram { return $_[0]->set_attr( 'gram/diatgram', $_[1] ); }
Subroutine set_gram_diatgram: not called CC=1 SCAR=6.9
Pod undocumented
465 0 ▶sub set_gram_typgroup { return $_[0]->set_attr( 'gram/typgroup', $_[1] ); }
Subroutine set_gram_typgroup: not called CC=1 SCAR=6.9
Pod undocumented
466  
467 #------------- valency frame reference -----
468  
469 0 ▶sub val_frame_rf { return $_[0]->get_attr('val_frame.rf'); }
Subroutine val_frame_rf: not called CC=1 SCAR=6.9
Pod undocumented
470 0 ▶sub set_val_frame_rf { return $_[0]->set_attr('val_frame.rf', $_[1]); }
Subroutine set_val_frame_rf: not called CC=1 SCAR=6.9
Pod undocumented
471  
472 36 1;
473  
474 __END__
« Treex/Core/Config.pm ↑ Summary Treex/Core/Node/EffectiveRelations.pm »