Treex/Core/Node/T.pm

filter: Statementstmt 30.1% 63 / 209 Branchbran 28.2% 13 / 46 Conditioncond 6.6% 1 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 19.1% 14 / 73 Podpod 29.0% 18 / 62 totaltotal 26.3% 109 / 413 CC 33 SCAR 19.5
CC
33
Cov
29%
_update_list
30.0
get_anodes
30.0
get_aux_anodes
20.0
CRAP 7.0
« Treex/Core/Document.pm ↑ Summary Treex/Core/Node/EffectiveRelations.pm »
1 package Treex::Core::Node::T;
2 36 $Treex::Core::Node::T::VERSION = '2.20151210';
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 sub get_pml_type_name {
23 81 ▶ my ($self) = @_;
Subroutine get_pml_type_name: called CC=2 SCAR=6.9
Pod documented
24 81 ▶ return $self->is_root() ? 't-root.type' : 't-node.type';
Branch: 1 branch
BranchTrueFalseTotal
$self->is_root ? : 27 54 81
25 }
26  
27 # the node is a root of a coordination/apposition construction
28 # analogy of PML_T::IsCoord
29 sub is_coap_root {
30 42 ▶ my ($self) = @_;
Subroutine is_coap_root: called CC=3 SCAR=11.7
Pod documented
31 42 ▶ log_fatal("Incorrect number of arguments") if @_ != 1;
Branch: 1 branch
BranchTrueFalseTotal
if @_ != 1 0 42 42
32 42 ▶ return ( $self->functor || '' ) =~ /^(CONJ|CONFR|DISJ|GRAD|ADVS|CSQ|REAS|CONTRA|APPS|OPER)$/;
Condition50%1/2
$self->functor || ''
l!l
420
MC/DC0%0/1
$self->functor || ''
$self->functor
Truth table50%1/2
A
A= $self->functor
Aresult
11
00
33 }
34  
35 #----------- helpers for reference lists ------------
36  
37 sub _get_node_list {
38 3 ▶ my ( $self, $list, $arg_ref ) = @_;
Subroutine _get_node_list: called CC=3 SCAR=11.0
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 ? : 1 2 3
43 }
44  
45 sub _set_node_list {
46 0 ▶ my $self = shift;
Subroutine _set_node_list: not called CC=1 SCAR=6.9
47 0 my $list = shift;
48 0 $self->set_attr( $list, [ map { $_->get_attr('id') } @_ ] );
49 0 return;
50 }
51  
52 sub _add_to_node_list {
53 1 ▶ my $self = shift;
Subroutine _add_to_node_list: called CC=2 SCAR=7.1
54 1 my $list = shift;
55  
56 # get the current elements of the list
57 1 my $cur_ref = $self->get_attr($list);
58 1 ▶ 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 sub _remove_from_node_list {
72 0 ▶ my $self = shift;
Subroutine _remove_from_node_list: not called CC=3 SCAR=24.8
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 sub _update_list {
89  
90 0 ▶ my ( $self, $list ) = @_;
Subroutine _update_list: not called CC=5 SCAR=34.0
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 sub get_lex_anode {
114 5 ▶ my ($self) = @_;
Subroutine get_lex_anode: called CC=2 SCAR=6.9
Pod documented
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 sub set_lex_anode {
122 4 ▶ my ( $self, $lex_anode ) = @_;
Subroutine set_lex_anode: called CC=2 SCAR=7.0
Pod documented
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 sub get_aux_anodes {
129 0 ▶ my ( $self, $arg_ref ) = @_;
Subroutine get_aux_anodes: not called CC=4 SCAR=30.0
Pod documented
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 sub set_aux_anodes {
138 0 ▶ my $self = shift;
Subroutine set_aux_anodes: not called CC=1 SCAR=6.9
Pod documented
139 0 return $self->_set_node_list( 'a/aux.rf', @_ );
140 }
141  
142 sub add_aux_anodes {
143 0 ▶ my $self = shift;
Subroutine add_aux_anodes: not called CC=1 SCAR=6.9
Pod documented
144 0 return $self->_add_to_node_list( 'a/aux.rf', @_ );
145 }
146  
147 sub remove_aux_anodes {
148 0 ▶ my $self = shift;
Subroutine remove_aux_anodes: not called CC=1 SCAR=6.9
Pod documented
149 0 return $self->_remove_from_node_list( 'a/aux.rf', @_ );
150 }
151  
152 sub get_anodes {
153 0 ▶ my ( $self, $arg_ref ) = @_;
Subroutine get_anodes: not called CC=5 SCAR=34.0
Pod documented
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 nodes -------------------
163  
164 sub get_coref_nodes {
165 0 ▶ my ( $self, $arg_ref ) = @_;
Subroutine get_coref_nodes: not called CC=3 SCAR=24.8
Pod documented
166
167 # process coreference parameters
168 0 my $with_types = $arg_ref->{with_types};
169 0 delete $arg_ref->{with_types};
170
171 0 my @gram_nodes = $self->_get_node_list('coref_gram.rf');
172
173 # textual coreference in PDT2.0 and 2.5 style
174 0 my @text_nodes = $self->_get_node_list('coref_text.rf');
175 0 ▶ return $self->_process_switches( $arg_ref, (@gram_nodes, @text_nodes) ) if (@text_nodes);
Branch: 1 branch
BranchTrueFalseTotal
if @text_nodes 0 0 0
176  
177 # textual coreference in PDT3.0 style
178 0 ▶ my $pdt30_text_coref_rf = $self->get_attr('coref_text') // [];
Condition0%0/2
$self->get_attr("coref_text") // []
l!l
00
MC/DC0%0/1
$self->get_attr("coref_text") // []
$self->get_attr("coref_text")
Truth table0%0/2
A
A= $self->get_attr("coref_text")
Aresult
11
00
179 0 my @pdt30_gram_coref = map {{'target_node.rf' => $_->id, 'type' => undef}} @gram_nodes;
180 0 return $self->_get_pdt30_coref([@pdt30_gram_coref, @$pdt30_text_coref_rf], $with_types, $arg_ref);
181 }
182  
183 sub get_coref_gram_nodes {
184 2 ▶ my ( $self, $arg_ref ) = @_;
Subroutine get_coref_gram_nodes: called CC=1 SCAR=0.0
Pod documented
185 2 return $self->_get_node_list( 'coref_gram.rf', $arg_ref );
186 }
187  
188 sub get_coref_text_nodes {
189 1 ▶ my ( $self, $arg_ref ) = @_;
Subroutine get_coref_text_nodes: called CC=3 SCAR=13.5
Pod documented
190
191 # process coreference parameters
192 1 my $with_types = $arg_ref->{with_types};
193 1 delete $arg_ref->{with_types};
194
195 # textual coreference in PDT2.0 and 2.5 style
196 1 my @nodes = $self->_get_node_list( 'coref_text.rf', $arg_ref );
197 1 ▶ return @nodes if (@nodes);
Branch: 1 branch
BranchTrueFalseTotal
if @nodes 1 0 1
198
199 # textual coreference in PDT3.0 style
200 0 ▶ my $pdt30_coref_rf = $self->get_attr('coref_text') // [];
Condition0%0/2
$self->get_attr("coref_text") // []
l!l
00
MC/DC0%0/1
$self->get_attr("coref_text") // []
$self->get_attr("coref_text")
Truth table0%0/2
A
A= $self->get_attr("coref_text")
Aresult
11
00
201  
202 0 return $self->_get_pdt30_coref($pdt30_coref_rf, $with_types, $arg_ref);
203 }
204  
205 sub _get_pdt30_coref {
206 0 ▶ my ($self, $coref_rf, $with_types, $arg_ref) = @_;
Subroutine _get_pdt30_coref: not called CC=3 SCAR=24.8
207
208 0 my $document = $self->get_document;
209
210 0 my @nodes = map {$document->get_node_by_id( $_->{'target_node.rf'} )} @$coref_rf;
211 ## get_node_by_id() will fatally fail if target is not defined!
212 #my @targetrfs = grep {defined($_)} map {$_->{'target_node.rf'}} @{$coref_rf};
213 #my @nodes = map {$document->get_node_by_id($_)} @targetrfs;
214
215 0 my @filtered_nodes = $self->_process_switches( $arg_ref, @nodes );
216 0 ▶ return @filtered_nodes if (!$with_types);
Branch: 1 branch
BranchTrueFalseTotal
unless $with_types 0 0 0
217
218 # return both nodes and types (as list references - similar to alignments)
219 0 my %node_id_to_index = map {$nodes[$_]->id => $_} 0 .. $#nodes;
220 0 my @types = map { $_->{'type'} } @$coref_rf;
221 my @filtered_types = map {
222 0 my $idx = $node_id_to_index{$_->id};
223 0 ▶ defined $idx ? $types[$idx] : undef
Branch: 1 branch
BranchTrueFalseTotal
defined $idx ? : 0 0 0
224 } @filtered_nodes;
225 0 return (\@filtered_nodes, \@filtered_types);
226 }
227  
228 # it doesn't return a complete chain, just the members which are accessible
229 # from the current node
230 # TODO: with backrefs the whole chain is accessible now
231 sub get_coref_chain {
232 0 ▶ my ( $self, $arg_ref ) = @_;
Subroutine get_coref_chain: not called CC=4 SCAR=30.0
Pod undocumented
233  
234 0 my %visited_nodes = ();
235 0 my @nodes;
236 0 my @queue = ( $self->_get_node_list('coref_gram.rf'), $self->_get_node_list('coref_text.rf') );
237 0 ▶ while ( my $node = shift @queue ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $node = shift @queue) 0 0 0
238 0 $visited_nodes{$node} = 1;
239 0 push @nodes, $node;
240 0 my @antes = ( $node->_get_node_list('coref_gram.rf'), $node->_get_node_list('coref_text.rf') );
241 0 foreach my $ante (@antes) {
242 0 ▶ if ( !defined $visited_nodes{$ante} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $visited_nodes{$ante}) 0 0 0
243 0 push @queue, $ante;
244 }
245 }
246 }
247  
248 0 return $self->_process_switches( $arg_ref, @nodes );
249 }
250  
251 sub add_coref_gram_nodes {
252 1 ▶ my $self = shift;
Subroutine add_coref_gram_nodes: called CC=1 SCAR=0.0
Pod documented
253 1 return $self->_add_to_node_list( 'coref_gram.rf', @_ );
254 }
255  
256 sub add_coref_text_nodes {
257 0 ▶ my $self = shift;
Subroutine add_coref_text_nodes: not called CC=1 SCAR=6.9
Pod undocumented
258 0 return $self->_add_to_node_list( 'coref_text.rf', @_ );
259 }
260  
261 sub remove_coref_nodes {
262 0 ▶ my $self = shift;
Subroutine remove_coref_nodes: not called CC=1 SCAR=6.9
Pod documented
263 0 $self->_remove_from_node_list( 'coref_gram.rf', @_ );
264 0 $self->_remove_from_node_list( 'coref_text.rf', @_ );
265 0 return;
266 }
267  
268 # remove unindexed IDs from coreference lists
269 sub update_coref_nodes {
270 0 ▶ my $self = shift;
Subroutine update_coref_nodes: not called CC=1 SCAR=6.9
Pod documented
271  
272 0 $self->_update_list('coref_gram.rf');
273 0 $self->_update_list('coref_text.rf');
274 0 return;
275 }
276  
277 # ----------- complement nodes -------------
278  
279 sub get_compl_nodes {
280 0 ▶ my ( $self, $arg_ref ) = @_;
Subroutine get_compl_nodes: not called CC=1 SCAR=6.9
Pod undocumented
281 0 return $self->_get_node_list( 'compl.rf', $arg_ref );
282 }
283  
284 sub add_compl_nodes {
285 0 ▶ my $self = shift;
Subroutine add_compl_nodes: not called CC=1 SCAR=6.9
Pod undocumented
286 0 return $self->_add_to_node_list( 'compl.rf', @_ );
287 }
288  
289 sub remove_compl_nodes {
290 0 ▶ my $self = shift;
Subroutine remove_compl_nodes: not called CC=1 SCAR=6.9
Pod undocumented
291 0 $self->_remove_from_node_list( 'compl.rf', @_ );
292 0 return;
293 }
294  
295 sub update_compl_nodes {
296 0 ▶ my $self = shift;
Subroutine update_compl_nodes: not called CC=1 SCAR=6.9
Pod undocumented
297 0 $self->_update_list('compl.rf');
298 0 return;
299 }
300  
301 #----------- n-layer (named entity) nodes -------------
302  
303 sub get_n_node {
304 2 ▶ my ($self) = @_;
Subroutine get_n_node: called CC=2 SCAR=7.1
Pod documented
305 2 ▶ my $lex_anode = $self->get_lex_anode() or return;
Branch: 1 branch
BranchTrueFalseTotal
my $lex_anode = $self->get_lex_anode or return 0 2 2
306 2 return $lex_anode->n_node();
307 }
308  
309 #----------- source t-layer (source-language in MT) nodes -------------
310  
311 sub src_tnode {
312 0 ▶ my ($self) = @_;
Subroutine src_tnode: not called CC=2 SCAR=17.9
Pod documented
313 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
314 0 return $self->get_document->get_node_by_id($source_node_id);
315 }
316  
317 sub set_src_tnode {
318 0 ▶ my ( $self, $source_node ) = @_;
Subroutine set_src_tnode: not called CC=1 SCAR=6.9
Pod documented
319 0 $self->set_attr( 'src_tnode.rf', $source_node->id );
320 0 return;
321 }
322  
323 # ---- attributes that contain references
324  
325 override '_get_reference_attrs' => sub {
326  
327 103 ▶ my ($self) = @_;
Subroutine __ANON__: called CC=1 SCAR=0.0
328 103 return ('a/lex.rf', 'original_parent.rf', 'src_tnode.rf', 'a/aux.rf', 'compl.rf', 'coref_gram.rf', 'coref_text.rf');
329 36 };
330  
331 #----------- grammatemes -------------
332  
333 #TODO: make these real Moose attributes
334 0 ▶sub gram_sempos { return $_[0]->get_attr('gram/sempos'); }
Subroutine gram_sempos: not called CC=1 SCAR=6.9
Pod undocumented
335 0 ▶sub gram_gender { return $_[0]->get_attr('gram/gender'); }
Subroutine gram_gender: not called CC=1 SCAR=6.9
Pod undocumented
336 0 ▶sub gram_number { return $_[0]->get_attr('gram/number'); }
Subroutine gram_number: not called CC=1 SCAR=6.9
Pod undocumented
337 0 ▶sub gram_degcmp { return $_[0]->get_attr('gram/degcmp'); }
Subroutine gram_degcmp: not called CC=1 SCAR=6.9
Pod undocumented
338 0 ▶sub gram_verbmod { return $_[0]->get_attr('gram/verbmod'); }
Subroutine gram_verbmod: not called CC=1 SCAR=6.9
Pod undocumented
339 0 ▶sub gram_deontmod { return $_[0]->get_attr('gram/deontmod'); }
Subroutine gram_deontmod: not called CC=1 SCAR=6.9
Pod undocumented
340 0 ▶sub gram_tense { return $_[0]->get_attr('gram/tense'); }
Subroutine gram_tense: not called CC=1 SCAR=6.9
Pod undocumented
341 0 ▶sub gram_aspect { return $_[0]->get_attr('gram/aspect'); }
Subroutine gram_aspect: not called CC=1 SCAR=6.9
Pod undocumented
342 0 ▶sub gram_resultative { return $_[0]->get_attr('gram/resultative'); }
Subroutine gram_resultative: not called CC=1 SCAR=6.9
Pod undocumented
343 0 ▶sub gram_dispmod { return $_[0]->get_attr('gram/dispmod'); }
Subroutine gram_dispmod: not called CC=1 SCAR=6.9
Pod undocumented
344 0 ▶sub gram_iterativeness { return $_[0]->get_attr('gram/iterativeness'); }
Subroutine gram_iterativeness: not called CC=1 SCAR=6.9
Pod undocumented
345 0 ▶sub gram_indeftype { return $_[0]->get_attr('gram/indeftype'); }
Subroutine gram_indeftype: not called CC=1 SCAR=6.9
Pod undocumented
346 0 ▶sub gram_person { return $_[0]->get_attr('gram/person'); }
Subroutine gram_person: not called CC=1 SCAR=6.9
Pod undocumented
347 0 ▶sub gram_numertype { return $_[0]->get_attr('gram/numertype'); }
Subroutine gram_numertype: not called CC=1 SCAR=6.9
Pod undocumented
348 0 ▶sub gram_politeness { return $_[0]->get_attr('gram/politeness'); }
Subroutine gram_politeness: not called CC=1 SCAR=6.9
Pod undocumented
349 0 ▶sub gram_negation { return $_[0]->get_attr('gram/negation'); }
Subroutine gram_negation: not called CC=1 SCAR=6.9
Pod undocumented
350 0 ▶sub gram_definiteness { return $_[0]->get_attr('gram/definiteness'); }
Subroutine gram_definiteness: not called CC=1 SCAR=6.9
Pod undocumented
351 0 ▶sub gram_diathesis { return $_[0]->get_attr('gram/diathesis'); }
Subroutine gram_diathesis: not called CC=1 SCAR=6.9
Pod undocumented
352  
353 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
354 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
355 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
356 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
357 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
358 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
359 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
360 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
361 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
362 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
363 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
364 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
365 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
366 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
367 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
368 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
369 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
370 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
371  
372 #------------- valency frame reference -----
373  
374 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
375 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
376  
377 36 1;
378  
379 __END__
380  
381 =encoding utf-8
382  
383 =head1 NAME
384  
385 Treex::Core::Node::T
386  
387 =head1 VERSION
388  
389 version 2.20151210
390  
391 =head1 DESCRIPTION
392  
393 t-layer (tectogrammatical) node
394  
395  
396 =head1 METHODS
397  
398 =head2 Access to a-layer (analytical nodes)
399  
400 =over
401  
402 =item $node->add_aux_anodes(@aux_anodes)
403  
404 Add auxiliary a-nodes (to C<a/aux.rf>)
405  
406 =item @anodes = $node->get_anodes()
407  
408 Return a-nodes (both auxiliary and lexical, ie. C<a/aux.rf> and C<a/lex.rf>)
409  
410 =item @aux_anodes = $node->get_aux_anodes()
411  
412 Return auxiliary a-nodes (from C<a/aux.rf>).
413  
414 =item $lex_anod = $node->get_lex_anode()
415  
416 Return the lexical a-nodes (from C<a/lex.rf>).
417  
418 =item $node->set_aux_anodes(@aux_anodes)
419  
420 Set the auxiliary a-nodes (to C<a/aux.rf>).
421  
422 =item set_lex_anode
423  
424 Set the lexical a-node (to C<a/lex.rf>).
425  
426 =item $node->remove_aux_anodes(@to_remove)
427  
428 Remove the specified a-nodes from C<a/aux.rf> (if they are contained in it).
429  
430 =item $node->get_coref_nodes()
431  
432 Return textual and grammatical coreference nodes (from C<coref_gram.rf> and C<coref_text.rf>).
433 If the document follows the PDT3.0 annotation style, the same steps as for C<$node->get_coref_text_nodes()> are applied.
434  
435 =item $node->get_coref_gram_nodes()
436  
437 Return grammatical coreference nodes (from C<coref_gram.rf>).
438  
439 =item $node->get_coref_text_nodes()
440  
441 Return textual coreference nodes (from C<coref_text.rf> if the document follows the PDT2.0 annotation style).
442 If the document follows the PDT3.0 annotation style, the list of nodes is extracted from C<coref_text/target_node.rf>.
443 If the C<with_types> parameter is set in C<arg_ref>, two list references are returned: the first one refers to a list of nodes
444 extracted from C<coref_text/target_node.rf>, the second one to a list of types from C<coref_text/type>.
445  
446 =item $node->add_coref_gram_nodes(@nodes)
447  
448 Add grammatical coreference nodes (to C<coref_gram.rf>).
449  
450 =item $node->add_coref_gram_nodes(@nodes)
451  
452 Add textual coreference nodes (to C<coref_text.rf>).
453  
454 =item $node->remove_coref_nodes()
455  
456 Remove the specified nodes from C<coref_gram.rf> or C<coref_text.rf> (if they are contained in one or both of them).
457  
458 =item $node->update_coref_nodes()
459  
460 Remove all invalid coreferences from C<coref_gram.rf> and C<coref_text.rf>.
461  
462 =back
463  
464 =head2 Access to source language t-layer (in MT)
465  
466 =over
467  
468 =item $src_tnode = $node->src_tnode()
469  
470 Return the source language (in MT) t-node (from C<src_tnode.rf>).
471  
472 =item set_src_tnode
473  
474 Set the source language (in MT) t-node (to C<src_tnode.rf>).
475  
476 =back
477  
478 =head2 Access to n-layer (named entity nodes)
479  
480 Note there is no C<set_n_node> method.
481 You must set the link from n-node to a a-node.
482  
483 =over
484  
485 =item $node->get_n_node()
486  
487 This is a shortcut for C<< $self->get_lex_anode()->n_node; >>
488 If this t-node is a part of a named entity,
489 this method returns the corresponding n-node (L<Treex::Core::Node::N>).
490 If this node is a part of more than one named entities,
491 only the most nested one is returned.
492 For example: "Bank of China"
493  
494 $n_node_for_china = $t_node_china->get_n_node();
495 print $n_node_for_china->get_attr('normalized_name'); # China
496 $n_node_for_bank_of_china = $n_node_for_china->get_parent();
497 print $n_node_for_bank_of_china->get_attr('normalized_name'); # Bank of China
498  
499  
500 =back
501  
502 =head2 Other methods
503  
504 =over
505  
506 =item is_coap_root
507  
508 Is this node a root (or head) of a coordination/apposition construction?
509 On t-layer this is decided based on C<functor =~ /^(CONJ|CONFR|DISJ|GRAD|ADVS|CSQ|REAS|CONTRA|APPS|OPER)/>.
510  
511 =back
512  
513  
514 =head1 AUTHOR
515  
516 Zdeněk Žabokrtský <zabokrtsky@ufal.mff.cuni.cz>
517  
518 Martin Popel <popel@ufal.mff.cuni.cz>
519  
520 Ondřej Dušek <odusek@ufal.mff.cuni.cz>
521  
522 =head1 COPYRIGHT AND LICENSE
523  
524 Copyright © 2011-2012 by Institute of Formal and Applied Linguistics, Charles University in Prague
525  
526 This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
« Treex/Core/Document.pm ↑ Summary Treex/Core/Node/EffectiveRelations.pm »