line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Treex::Tool::Parser::MSTperl::Edge; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$Treex::Tool::Parser::MSTperl::Edge::VERSION = '0.11949'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5581
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Treex::Tool::Parser::MSTperl::Node; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has config => ( |
11
|
|
|
|
|
|
|
isa => 'Treex::Tool::Parser::MSTperl::Config', |
12
|
|
|
|
|
|
|
is => 'rw', |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has parent => ( |
16
|
|
|
|
|
|
|
isa => 'Treex::Tool::Parser::MSTperl::Node', |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has child => ( |
22
|
|
|
|
|
|
|
isa => 'Treex::Tool::Parser::MSTperl::Node', |
23
|
|
|
|
|
|
|
is => 'ro', |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has first => ( |
28
|
|
|
|
|
|
|
isa => 'Treex::Tool::Parser::MSTperl::Node', |
29
|
|
|
|
|
|
|
is => 'rw', |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has second => ( |
33
|
|
|
|
|
|
|
isa => 'Treex::Tool::Parser::MSTperl::Node', |
34
|
|
|
|
|
|
|
is => 'rw', |
35
|
|
|
|
|
|
|
); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has sentence => ( |
38
|
|
|
|
|
|
|
isa => 'Treex::Tool::Parser::MSTperl::Sentence', |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
required => 1, |
41
|
|
|
|
|
|
|
weak_ref => 1, |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has features => ( |
45
|
|
|
|
|
|
|
is => 'rw', |
46
|
|
|
|
|
|
|
isa => 'Maybe[ArrayRef[Str]]', |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub BUILD { |
50
|
|
|
|
|
|
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
if ( $self->parent->ord < $self->child->ord ) { |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# parent precedes child |
55
|
|
|
|
|
|
|
$self->first( $self->parent ); |
56
|
|
|
|
|
|
|
$self->second( $self->child ); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
} else { |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# parent follows child |
61
|
|
|
|
|
|
|
$self->first( $self->child ); |
62
|
|
|
|
|
|
|
$self->second( $self->parent ); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->config( $self->parent->config ); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub signature { |
71
|
|
|
|
|
|
|
my ($self) = @_; |
72
|
|
|
|
|
|
|
return |
73
|
|
|
|
|
|
|
$self->sentence->id . |
74
|
|
|
|
|
|
|
'#' . $self->parent->ord . |
75
|
|
|
|
|
|
|
'#' . $self->child->ord . |
76
|
|
|
|
|
|
|
'#' . $self->child->label; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# all features, including dynamic if applicable, for labelling only |
80
|
|
|
|
|
|
|
sub features_all_labeller { |
81
|
|
|
|
|
|
|
my ($self) = @_; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $ALGORITHM = $self->config->labeller_algorithm; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
if ( $ALGORITHM < 20 ) { |
86
|
|
|
|
|
|
|
return $self->features; |
87
|
|
|
|
|
|
|
} else { |
88
|
|
|
|
|
|
|
if ( keys %{ $self->config->labelledFeaturesControl->dynamic_features } ) { |
89
|
|
|
|
|
|
|
my @features = @{ $self->features }; |
90
|
|
|
|
|
|
|
push @features, |
91
|
|
|
|
|
|
|
@{ |
92
|
|
|
|
|
|
|
$self->config->labelledFeaturesControl->get_all_features( |
93
|
|
|
|
|
|
|
$self, 1 |
94
|
|
|
|
|
|
|
) |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
return \@features; |
97
|
|
|
|
|
|
|
} else { |
98
|
|
|
|
|
|
|
return $self->features; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__END__ |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=pod |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=for Pod::Coverage BUILD |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=encoding utf-8 |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 NAME |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Treex::Tool::Parser::MSTperl::Edge |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 VERSION |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
version 0.11949 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 DESCRIPTION |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Represents a dependency edge (i.e. a pair of nodes where one of them |
124
|
|
|
|
|
|
|
is a parent to the other one which is its child). |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 FIELDS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=over 4 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item child |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
The child (dependent) node (L<Treex::Tool::Parser::MSTperl::Node>) of the edge. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item parent |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
The parent (governing, head) node of the edge. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item first |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The one of C<child> and C<parent> which comes first in the sentence |
141
|
|
|
|
|
|
|
(L<Treex::Tool::Parser::MSTperl::Node/ord>). |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Filled automatically when edge is created. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item second |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
The one of C<child> and C<parent> which comes second in the sentence |
148
|
|
|
|
|
|
|
(i.e. the one which is not in the C<first> field) |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Filled automatically when edge is created. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item sentence |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
The sentence (L<Treex::Tool::Parser::MSTperl::Sentence>) which contains |
155
|
|
|
|
|
|
|
the nodes (C<child> and C<parent>). |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=back |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 METHODS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=over 4 |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item my $edge = Treex::Tool::Parser::MSTperl::Edge->new( |
164
|
|
|
|
|
|
|
child => $child_node, |
165
|
|
|
|
|
|
|
parent => $parent_node, |
166
|
|
|
|
|
|
|
sentence => $sentence, |
167
|
|
|
|
|
|
|
); |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Initializes an instance of an edge between the C<child> node |
170
|
|
|
|
|
|
|
and the C<parent> node |
171
|
|
|
|
|
|
|
(instances of L<Treex::Tool::Parser::MSTperl::Node>) |
172
|
|
|
|
|
|
|
in the given C<sentence> (L<Treex::Tool::Parser::MSTperl::Sentence>). |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=item my $edge_signature = $edge->signature() |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
String uniquely identifying the edge, composed of sentence C<id> |
177
|
|
|
|
|
|
|
(L<Treex::Tool::Parser::MSTperl::Sentence/id>), C<ord>s of the edge nodes |
178
|
|
|
|
|
|
|
(L<Treex::Tool::Parser::MSTperl::Node/ord>) |
179
|
|
|
|
|
|
|
and label of the edge (which is stored with the child node - |
180
|
|
|
|
|
|
|
L<Treex::Tool::Parser::MSTperl::Node/label>). |
181
|
|
|
|
|
|
|
Used to identify the edge |
182
|
|
|
|
|
|
|
in the edge features |
183
|
|
|
|
|
|
|
cache (L<Treex::Tool::Parser::MSTperl::FeaturesControl/edge_features_cache>). |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 AUTHORS |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Rudolf Rosa <rosa@ufal.mff.cuni.cz> |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
Copyright © 2011 by Institute of Formal and Applied Linguistics, Charles |
194
|
|
|
|
|
|
|
University in Prague |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
This module is free software; you can redistribute it and/or modify it under |
197
|
|
|
|
|
|
|
the same terms as Perl itself. |