| 1 | package Treex::Tool::Parser::MSTperl::Sentence; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | { | ||||||||||||||||||||||||||||||||||||||||||
| 3 | 7 | $Treex::Tool::Parser::MSTperl::Sentence::VERSION = '0.11949'; | |||||||||||||||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 7 | ▶ | use Moose; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use Treex::Tool::Parser::MSTperl::Node; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 7 | ▶ | use Treex::Tool::Parser::MSTperl::RootNode; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 7 | has config => ( | |||||||||||||||||||||||||||||||||||||||||
| 12 | isa => 'Treex::Tool::Parser::MSTperl::Config', | ||||||||||||||||||||||||||||||||||||||||||
| 13 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 14 | required => '1', | ||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # unique for each sentence, where sentence means sequence of words | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # (i.e. stays the same for copies of the same sentence) | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # needed for caching of features when training the parser | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # (can be undef if not needed) | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 7 | has id => ( | |||||||||||||||||||||||||||||||||||||||||
| 22 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||
| 23 | isa => 'Maybe[Int]', | ||||||||||||||||||||||||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 7 | has nodes => ( | |||||||||||||||||||||||||||||||||||||||||
| 27 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 28 | isa => 'ArrayRef[Treex::Tool::Parser::MSTperl::Node]', | ||||||||||||||||||||||||||||||||||||||||||
| 29 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | # root node added | ||||||||||||||||||||||||||||||||||||||||||
| 33 | 7 | has nodes_with_root => ( | |||||||||||||||||||||||||||||||||||||||||
| 34 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 35 | isa => 'ArrayRef[Treex::Tool::Parser::MSTperl::Node]', | ||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | # used only in unlabelled parsing | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 7 | has features => ( | |||||||||||||||||||||||||||||||||||||||||
| 40 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 41 | isa => 'Maybe[ArrayRef[Str]]', | ||||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | # TODO | ||||||||||||||||||||||||||||||||||||||||||
| 45 | # has betweenFeatureValues => ( | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # isa => 'HashRef', | ||||||||||||||||||||||||||||||||||||||||||
| 47 | # is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | # default => sub { {} }, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # ); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 7 | has edges => ( | |||||||||||||||||||||||||||||||||||||||||
| 52 | is => 'rw', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | isa => 'Maybe[ArrayRef[Treex::Tool::Parser::MSTperl::Edge]]', | ||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 44 | ▶ | sub BUILD { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 44 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | #add root | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 44 | my $root = Treex::Tool::Parser::MSTperl::RootNode->new( | |||||||||||||||||||||||||||||||||||||||||
| 61 | fields => $self->config->root_field_values, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | config => $self->config | ||||||||||||||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 44 | my @nodes_with_root; | |||||||||||||||||||||||||||||||||||||||||
| 65 | 44 | push @nodes_with_root, $root; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 44 | push @nodes_with_root, @{ $self->nodes }; | |||||||||||||||||||||||||||||||||||||||||
| 67 | 44 | $self->nodes_with_root( [@nodes_with_root] ); | |||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | # fill node ords | ||||||||||||||||||||||||||||||||||||||||||
| 70 | 44 | my $ord = 1; | |||||||||||||||||||||||||||||||||||||||||
| 71 | 44 | foreach my $node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 72 | 601 | $node->ord($ord); | |||||||||||||||||||||||||||||||||||||||||
| 73 | 601 | $ord++; | |||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | 44 | return; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 21 | ▶ | sub fill_fields_after_parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fill_fields_after_parse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | 21 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | #compute edges | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 21 | $self->compute_edges(); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | #compute features | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 21 | $self->compute_features( $self->config->unlabelledFeaturesControl ); | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 21 | return; | |||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | 24 | ▶ | sub fill_fields_before_labelling { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fill_fields_before_labelling: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | 24 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 24 | ▶ | if ( $self->config->DEBUG >= 3 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | print $self->id . " fill_fields_before_labelling()\n"; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | #compute edges | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 24 | $self->compute_edges(); | |||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | #compute features | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 24 | $self->compute_features( $self->config->labelledFeaturesControl ); | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | # sub fill_fields_after_labelling { | ||||||||||||||||||||||||||||||||||||||||||
| 110 | # | ||||||||||||||||||||||||||||||||||||||||||
| 111 | # my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||
| 112 | # | ||||||||||||||||||||||||||||||||||||||||||
| 113 | # seems there is nothing to compute here | ||||||||||||||||||||||||||||||||||||||||||
| 114 | # (provided that the labels are somewhat extra, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | # i.e. not part of the feature values) | ||||||||||||||||||||||||||||||||||||||||||
| 116 | # | ||||||||||||||||||||||||||||||||||||||||||
| 117 | # return; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | # compute node parents and the array of edges | ||||||||||||||||||||||||||||||||||||||||||
| 121 | # used both in fill_fields_after_parse and fill_fields_before_labelling methods | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 45 | ▶ | sub compute_edges { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compute_edges: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 45 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 45 | my @edges; | |||||||||||||||||||||||||||||||||||||||||
| 126 | 45 | foreach my $node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # fill node parent | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # (it can be set either in parent or in parentOrd field) | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 599 | ▶ | if ( $node->parent ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 276 | $node->parentOrd( $node->parent->ord ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } else { # $node->parentOrd | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 323 | $node->parent( $self->getNodeByOrd( $node->parentOrd ) ); | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 599 | ▶ | if ( $self->config->DEBUG >= 3 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | print $node->parentOrd | |||||||||||||||||||||||||||||||||||||||||
| 138 | . '(' . $node->parent->fields->[1] . ')' | ||||||||||||||||||||||||||||||||||||||||||
| 139 | . ' -> ' | ||||||||||||||||||||||||||||||||||||||||||
| 140 | . $node->ord | ||||||||||||||||||||||||||||||||||||||||||
| 141 | . '(' . $node->fields->[1] . ')' | ||||||||||||||||||||||||||||||||||||||||||
| 142 | . "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | # add a new edge | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 599 | my $edge = Treex::Tool::Parser::MSTperl::Edge->new( | |||||||||||||||||||||||||||||||||||||||||
| 147 | child => $node, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | parent => $node->parent, | ||||||||||||||||||||||||||||||||||||||||||
| 149 | sentence => $self | ||||||||||||||||||||||||||||||||||||||||||
| 150 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 599 | push @edges, $edge; | |||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | # add edge to the parent's list of children | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 599 | push @{ $node->parent->children }, $edge; | |||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 45 | $self->edges( [@edges] ); | |||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | 45 | return; | |||||||||||||||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | # compute edge features and join them into sentence features | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 45 | ▶ | sub compute_features { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compute_features: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 45 | my ( $self, $featuresControl ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 45 | my @features; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 45 | foreach my $edge ( @{ $self->edges } ) { | |||||||||||||||||||||||||||||||||||||||||
| 169 | 599 | my $edge_features; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 599 | my $ALGORITHM = $self->config->labeller_algorithm; | |||||||||||||||||||||||||||||||||||||||||
| 171 | 599 | ▶ | if ( $ALGORITHM < 20 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 599 | $edge_features = $featuresControl->get_all_features($edge); | |||||||||||||||||||||||||||||||||||||||||
| 173 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $edge_features = $featuresControl->get_all_features( $edge, -1 ); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 599 | $edge->features($edge_features); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 599 | push @features, @{$edge_features}; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | # (TODO) used only in unlabelled parsing | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 45 | $self->features( [@features] ); | |||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||
| 183 | 45 | return; | |||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | sub clear_parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clear_parse: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | #clear node parents and labels | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | foreach my $node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $node->parent(undef); | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $node->parentOrd(0); | |||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $node->label('_'); | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | #clear edges | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | $self->edges(undef); | |||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | #clear features | ||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | $self->features(undef); | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 17 | ▶ | sub copy_nonparsed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_nonparsed: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | #copy nodes | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 17 | my @nodes; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 17 | foreach my $node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 211 | 231 | my $node_copy = $node->copy_nonparsed(); | |||||||||||||||||||||||||||||||||||||||||
| 212 | 231 | push @nodes, $node_copy; | |||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | #create a new instance | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 17 | my $copy = Treex::Tool::Parser::MSTperl::Sentence->new( | |||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||
| 218 | # TODO: maybe should get a different ID for the sake of labelling | ||||||||||||||||||||||||||||||||||||||||||
| 219 | # (but this is curently not used anyway) | ||||||||||||||||||||||||||||||||||||||||||
| 220 | id => $self->id, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | nodes => [@nodes], | ||||||||||||||||||||||||||||||||||||||||||
| 222 | config => $self->config, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 17 | return $copy; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 17 | ▶ | sub copy_nonlabelled { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
copy_nonlabelled: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | #copy nodes | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 17 | my @nodes; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 17 | foreach my $node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 234 | 231 | my $node_copy = $node->copy_nonlabelled(); | |||||||||||||||||||||||||||||||||||||||||
| 235 | 231 | push @nodes, $node_copy; | |||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | #create a new instance | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 17 | my $copy = Treex::Tool::Parser::MSTperl::Sentence->new( | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | # TODO: maybe should get a different ID for the sake of labelling | ||||||||||||||||||||||||||||||||||||||||||
| 242 | # (but this is curently not used anyway) | ||||||||||||||||||||||||||||||||||||||||||
| 243 | id => $self->id, | ||||||||||||||||||||||||||||||||||||||||||
| 244 | nodes => [@nodes], | ||||||||||||||||||||||||||||||||||||||||||
| 245 | config => $self->config, | ||||||||||||||||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 17 | return $copy; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 231 | ▶ | sub setChildParent { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
setChildParent: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||
| 253 | # (Int $childOrd, Int $parentOrd) | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 231 | my ( $self, $childOrd, $parentOrd ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | 231 | my $child = $self->getNodeByOrd($childOrd); | |||||||||||||||||||||||||||||||||||||||||
| 257 | 231 | my $parent = $self->getNodeByOrd($parentOrd); | |||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 231 | $child->parent($parent); | |||||||||||||||||||||||||||||||||||||||||
| 260 | 231 | $child->parentOrd($parentOrd); | |||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | 231 | return; | |||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | 43388 | ▶ | sub len { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
len: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 266 | 43388 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 267 | 43388 | return scalar( @{ $self->nodes } ) | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | 43690 | ▶ | sub getNodeByOrd { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getNodeByOrd: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||
| 272 | # (Int $ord) | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 43690 | my ( $self, $ord ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 43690 | ▶ | if ( $ord >= 0 && $ord <= $self->len() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$ord >= 0 and $ord <= $self->len
MC/DC100%2/2
$ord >= 0 and $ord <= $self->len
$ord >= 0
$ord <= $self->len
Truth table100%3/3
A and B
A= $ord >= 0B= $ord <= $self->len
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 42869 | return $self->nodes_with_root->[$ord]; | |||||||||||||||||||||||||||||||||||||||||
| 277 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 821 | return; # undef | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 17 | ▶ | sub count_errors_attachement { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_errors_attachement: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | # (Treex::Tool::Parser::MSTperl::Sentence $correct_sentence) | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 17 | my ( $self, $correct_sentence ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 17 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | #assert that nodes in the sentences with the same ords | ||||||||||||||||||||||||||||||||||||||||||
| 290 | # are corresponding nodes | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 17 | foreach my $my_node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 292 | 231 | my $my_parent = $my_node->parentOrd; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 231 | my $correct_node = $correct_sentence->getNodeByOrd( $my_node->ord ); | |||||||||||||||||||||||||||||||||||||||||
| 294 | 231 | my $correct_parent = $correct_node->parentOrd; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 231 | ▶ | if ( $my_parent != $correct_parent ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | 103 | ▶ | if ( $self->config->lossFunction ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $errors += | |||||||||||||||||||||||||||||||||||||||||
| 298 | $self->attachement_error( | ||||||||||||||||||||||||||||||||||||||||||
| 299 | $my_node, $my_node->parent, $correct_node->parent | ||||||||||||||||||||||||||||||||||||||||||
| 300 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 103 | $errors++; | |||||||||||||||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||||||||||||||||
| 308 | 17 | return $errors; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub attachement_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attachement_error: not called CC=32 SCAR=69.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my ( $self, $node, $assignedParent, $correctParent ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | # TODO how do the undefines happen? | ||||||||||||||||||||||||||||||||||||||||||
| 315 | # they only seem to occur during testing, not during training | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | return 1 if ( !defined $assignedParent || !defined $correctParent ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $assignedParent and defined $correctParent
MC/DC0%0/2
defined $assignedParent and defined $correctParent
defined $assignedParent
defined $correctParent
Truth table0%0/3
A and B
A= defined $assignedParentB= defined $correctParent
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | my $error = 1; | |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | my $lossFunction = $self->config->lossFunction; | |||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if ( $lossFunction eq 'J' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 8 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | if ( defined $correctParent ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | if ( $correctParent->fields->[4] =~ /^J/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | $error = 10; | |||||||||||||||||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | elsif ( $lossFunction eq 'A' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | if ( $node->fields->[4] =~ /^A/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | $error = 10; | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | elsif ( $lossFunction eq 'NA' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | if ( defined $correctParent ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | ▶ | if ($node->fields->[4] =~ /^A/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$node->fields->[4] =~ /^A/ and $correctParent->fields->[4] =~ /^N/
MC/DC0%0/2
$node->fields->[4] =~ /^A/ and $correctParent->fields->[4] =~ /^N/
$node->fields->[4] =~ /^A/
$correctParent->fields->[4] =~ /^N/
Truth table0%0/3
A and B
A= $node->fields->[4] =~ /^A/B= $correctParent->fields->[4] =~ /^N/
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | && $correctParent->fields->[4] =~ /^N/ | ||||||||||||||||||||||||||||||||||||||||||
| 338 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 339 | { | ||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $error = 10; | |||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | elsif ( $lossFunction eq 'NA2' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||||||||||||||||
| 346 | # if the child is A | ||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if ( $node->fields->[4] =~ /^A/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | # and the assigned or correct parent is N | ||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | if ( $correctParent->fields->[4] =~ /^N/ || $assignedParent->fields->[4] =~ /^N/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$correctParent->fields->[4] =~ /^N/ or $assignedParent->fields->[4] =~ /^N/
MC/DC0%0/2
$correctParent->fields->[4] =~ /^N/ or $assignedParent->fields->[4] =~ /^N/
$correctParent->fields->[4] =~ /^N/
$assignedParent->fields->[4] =~ /^N/
Truth table0%0/3
A or B
A= $correctParent->fields->[4] =~ /^N/B= $assignedParent->fields->[4] =~ /^N/
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $error = 10; | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | elsif ( $lossFunction eq 'JNA' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | if ( defined $correctParent ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | ▶ | if ($node->fields->[4] =~ /^A/ | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$node->fields->[4] =~ /^A/ and $correctParent->fields->[4] =~ /^N/ || $correctParent->fields->[4] =~ /^J/
$correctParent->fields->[4] =~ /^N/ or $correctParent->fields->[4] =~ /^J/
MC/DC0%0/3
$node->fields->[4] =~ /^A/ and $correctParent->fields->[4] =~ /^N/ || $correctParent->fields->[4] =~ /^J/
$node->fields->[4] =~ /^A/
$correctParent->fields->[4] =~ /^N/
$correctParent->fields->[4] =~ /^J/
Truth table0%0/4
A and B or C
A= $node->fields->[4] =~ /^A/B= $correctParent->fields->[4] =~ /^N/C= $correctParent->fields->[4] =~ /^J/
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | && | ||||||||||||||||||||||||||||||||||||||||||
| 359 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 360 | $correctParent->fields->[4] =~ /^N/ | ||||||||||||||||||||||||||||||||||||||||||
| 361 | || $correctParent->fields->[4] =~ /^J/ | ||||||||||||||||||||||||||||||||||||||||||
| 362 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 363 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 364 | { | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | $error = 10; | |||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | elsif ( $lossFunction eq 'NR2' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | # if the child is N | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | if ( $node->fields->[4] =~ /^N/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | # and the assigned or correct parent is R | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | if ( $correctParent->fields->[4] =~ /^R/ || $assignedParent->fields->[4] =~ /^R/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$correctParent->fields->[4] =~ /^R/ or $assignedParent->fields->[4] =~ /^R/
MC/DC0%0/2
$correctParent->fields->[4] =~ /^R/ or $assignedParent->fields->[4] =~ /^R/
$correctParent->fields->[4] =~ /^R/
$assignedParent->fields->[4] =~ /^R/
Truth table0%0/3
A or B
A= $correctParent->fields->[4] =~ /^R/B= $assignedParent->fields->[4] =~ /^R/
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | $error = 10; | |||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | elsif ( $lossFunction eq 'JNR2' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | # if the child is N or J | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | if ( $node->fields->[4] =~ /^[NJ]/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | # and the assigned or correct parent is R | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | if ( $correctParent->fields->[4] =~ /^R/ || $assignedParent->fields->[4] =~ /^R/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$correctParent->fields->[4] =~ /^R/ or $assignedParent->fields->[4] =~ /^R/
MC/DC0%0/2
$correctParent->fields->[4] =~ /^R/ or $assignedParent->fields->[4] =~ /^R/
$correctParent->fields->[4] =~ /^R/
$assignedParent->fields->[4] =~ /^R/
Truth table0%0/3
A or B
A= $correctParent->fields->[4] =~ /^R/B= $assignedParent->fields->[4] =~ /^R/
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | $error = 10; | |||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | elsif ( $lossFunction eq 'J2' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | # if the assigned or correct parent is J | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | ▶ | if ( $correctParent->fields->[4] =~ /^J/ || $assignedParent->fields->[4] =~ /^J/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$correctParent->fields->[4] =~ /^J/ or $assignedParent->fields->[4] =~ /^J/
MC/DC0%0/2
$correctParent->fields->[4] =~ /^J/ or $assignedParent->fields->[4] =~ /^J/
$correctParent->fields->[4] =~ /^J/
$assignedParent->fields->[4] =~ /^J/
Truth table0%0/3
A or B
A= $correctParent->fields->[4] =~ /^J/B= $assignedParent->fields->[4] =~ /^J/
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $error = 10; | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | return $error; | |||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | ▶ | sub count_errors_labelling { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_errors_labelling: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | # (Treex::Tool::Parser::MSTperl::Sentence $correct_sentence) | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 3 | my ( $self, $correct_sentence ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 3 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | my @correct_labels = | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 3 | map { $_->label } @{ $correct_sentence->nodes }; | |||||||||||||||||||||||||||||||||||||||||
| 411 | my @my_labels = | ||||||||||||||||||||||||||||||||||||||||||
| 412 | 3 | map { $_->label } @{ $self->nodes }; | |||||||||||||||||||||||||||||||||||||||||
| 413 | 3 | ▶ | for ( my $i = 0; $i < @correct_labels; $i++ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 47 | ▶ | if ( $correct_labels[$i] ne $my_labels[$i] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 415 | 18 | $errors++; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | } | ||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | return $errors; | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | ▶ | sub count_errors_attachement_and_labelling { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
count_errors_attachement_and_labelling: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | # (Treex::Tool::Parser::MSTperl::Sentence $correct_sentence) | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | my ( $self, $correct_sentence ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | my $errors = 0; | |||||||||||||||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||||||||||||||||
| 429 | #assert that nodes in the sentences with the same ords | ||||||||||||||||||||||||||||||||||||||||||
| 430 | # are corresponding nodes | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | foreach my $my_node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my $my_parent = $my_node->parentOrd; | |||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $my_label = $my_node->label; | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $correct_node = $correct_sentence->getNodeByOrd( $my_node->ord ); | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $correct_parent = $correct_node->parentOrd; | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my $correct_label = $correct_node->label; | |||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | ▶ | if ( $my_parent != $correct_parent || $my_label ne $correct_label ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$my_parent != $correct_parent or $my_label ne $correct_label
MC/DC0%0/2
$my_parent != $correct_parent or $my_label ne $correct_label
$my_parent != $correct_parent
$my_label ne $correct_label
Truth table0%0/3
A or B
A= $my_parent != $correct_parentB= $my_label ne $correct_label
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $errors++; | |||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | return $errors; | |||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | sub toParentOrdsArray { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toParentOrdsArray: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | my @parents; | |||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | foreach my $node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | push @parents, $node->parentOrd; | |||||||||||||||||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | return [@parents]; | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | sub toLabelsArray { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
toLabelsArray: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | my @labels; | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | foreach my $node ( @{ $self->nodes } ) { | |||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | push @labels, $node->label; | |||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | return [@labels]; | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||
| 467 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | __END__ | ||||||||||||||||||||||||||||||||||||||||||