| 1 | package Lingua::PT::Actants; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: compute verb actants for Portuguese | ||||||||||||||||||||||||||||
| 3 | 3 | $Lingua::PT::Actants::VERSION = '0.03'; | |||||||||||||||||||||||||||
| 4 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | sub new { | ||||||||||||||||||||||||||||
| 8 | 5 | ▶ | my ($class, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 9 | 5 | my $data; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # input is in conll* format | ||||||||||||||||||||||||||||
| 12 | 5 | ▶ | if (exists($args{conll})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 4 | $data = _conll2data($args{conll}); | |||||||||||||||||||||||||||
| 14 | } | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 5 | my $self = bless({ data=>$data }, $class); | |||||||||||||||||||||||||||
| 17 | 5 | return $self; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | sub _conll2data { | ||||||||||||||||||||||||||||
| 21 | 4 | ▶ | my ($input) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_conll2data: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 4 | my @data; | |||||||||||||||||||||||||||
| 24 | 4 | foreach my $line (split /\n/, $input) { | |||||||||||||||||||||||||||
| 25 | 26 | ▶ | next if $line =~ m/^\s*$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 26 | my @l = split /\s+/, $line; | |||||||||||||||||||||||||||
| 28 | 26 | push @data, { | |||||||||||||||||||||||||||
| 29 | id=>$l[0], form=>$l[1], pos=>$l[3], dep=>$l[6], rule=>$l[7] | ||||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 4 | return [@data]; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub text { | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
text: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 0 | return join(' ', map {$_->{form}} @{$self->{data}}); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | sub actants { | ||||||||||||||||||||||||||||
| 43 | 3 | ▶ | my ($self, %args) = @_; | ||||||||||||||||||||||||||
|
Subroutine
actants: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 3 | my ($cores, $ranks) = $self->acts_cores($self->{data}); | |||||||||||||||||||||||||||
| 46 | 3 | $self->{cores} = $cores; | |||||||||||||||||||||||||||
| 47 | 3 | $self->{ranks} = $ranks; | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 3 | my @acts = $self->acts_syntagmas($cores, $self->{data}); | |||||||||||||||||||||||||||
| 50 | 3 | $self->{acts} = [@acts]; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 3 | return $self->{acts}; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | # compute actant cores | ||||||||||||||||||||||||||||
| 56 | sub acts_cores { | ||||||||||||||||||||||||||||
| 57 | 7 | ▶ | my ($self) = @_; | ||||||||||||||||||||||||||
|
Subroutine
acts_cores: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||
| 58 | 7 | my $data = $self->{data}; | |||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | # compute main verbs in the sentence | ||||||||||||||||||||||||||||
| 61 | 7 | my @verbs = _main_verbs($data); | |||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 7 | my @ranks; | |||||||||||||||||||||||||||
| 64 | 7 | foreach my $v (@verbs) { | |||||||||||||||||||||||||||
| 65 | 7 | my @result; | |||||||||||||||||||||||||||
| 66 | 7 | foreach (@$data) { | |||||||||||||||||||||||||||
| 67 | 47 | my $score = _score($_, $v); | |||||||||||||||||||||||||||
| 68 | 47 | ▶ | if ($score >= 0) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | 47 | push @result, { token => $_, score => $score }; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | # normalize results | ||||||||||||||||||||||||||||
| 74 | 7 | my $total = 0; | |||||||||||||||||||||||||||
| 75 | 7 | $total += $_->{score} foreach @result; | |||||||||||||||||||||||||||
| 76 | 7 | $_->{score} = $_->{score}/$total foreach @result; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # sort results by score | ||||||||||||||||||||||||||||
| 79 | 7 | @result = sort {$b->{score} <=> $a->{score}} @result; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 7 | push @ranks, { verb => $v, rank => [@result] }; | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 7 | my @cores; | |||||||||||||||||||||||||||
| 85 | 7 | foreach (@ranks) { | |||||||||||||||||||||||||||
| 86 | 7 | my ($verb, @rank) = ( $_->{verb}, @{ $_->{rank} } ); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | # trim cores in rank | ||||||||||||||||||||||||||||
| 89 | 7 | my @final; | |||||||||||||||||||||||||||
| 90 | 7 | my $ac = 0; | |||||||||||||||||||||||||||
| 91 | 7 | foreach (@rank) { | |||||||||||||||||||||||||||
| 92 | 47 | ▶ | next if ($ac > 0.9 or $_->{score} < 0.1); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ac > "0.9" or $_->{"score"} < "0.1"
MC/DC50%1/2
$ac > "0.9" or $_->{"score"} < "0.1"
$ac > "0.9"
$_->{"score"} < "0.1"
Truth table66%2/3
A or B
A= $ac > "0.9"B= $_->{"score"} < "0.1"
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 14 | push @final, $_; | |||||||||||||||||||||||||||
| 95 | 14 | $ac += $_->{score}; | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | # sort cores by token position in sentence | ||||||||||||||||||||||||||||
| 99 | 7 | @final = sort { $a->{token}->{id} <=> $b->{token}->{id} } @final; | |||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | # set to simple list of tokens | ||||||||||||||||||||||||||||
| 102 | 7 | @final = map {$_->{token}} @final; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 7 | push @cores, { verb => $verb, cores => [@final] }; | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 7 | return ([@cores], [@ranks]); | |||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | sub _main_verbs { | ||||||||||||||||||||||||||||
| 111 | 7 | ▶ | my ($data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_main_verbs: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 112 | 7 | my @verbs; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | my $i; | ||||||||||||||||||||||||||||
| 115 | 7 | my @tmp; | |||||||||||||||||||||||||||
| 116 | 7 | ▶ | for ($i = 0; $i < @$data-1; $i++) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | 40 | my ($a, $b) = ($data->[$i], $data->[$i+1]); | |||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 40 | ▶ | unless ($a->{pos} eq 'VERB' and $b->{pos} eq 'VERB') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$a->{"pos"} eq "VERB" and $b->{"pos"} eq "VERB"
MC/DC100%2/2
$a->{"pos"} eq "VERB" and $b->{"pos"} eq "VERB"
$a->{"pos"} eq "VERB"
$b->{"pos"} eq "VERB"
Truth table100%3/3
A and B
A= $a->{"pos"} eq "VERB"B= $b->{"pos"} eq "VERB"
| |||||||||||||||||||||||||||||
| 120 | 36 | push @tmp, $a; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | 40 | ▶ | push @tmp, $b if ($i >= @$data); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 7 | foreach (@tmp) { | |||||||||||||||||||||||||||
| 126 | 36 | ▶ | push @verbs, $_ if (lc($_->{pos}) eq 'verb'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 7 | return @verbs; | |||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | sub acts_syntagmas { | ||||||||||||||||||||||||||||
| 133 | 3 | ▶ | my ($self, $cores, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
acts_syntagmas: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 3 | my @acts; | |||||||||||||||||||||||||||
| 136 | 3 | foreach (@$cores) { | |||||||||||||||||||||||||||
| 137 | 3 | my ($verb, @tokens) = ($_->{verb}, @{ $_->{cores} }); | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 3 | my @list; | |||||||||||||||||||||||||||
| 140 | 3 | foreach my $t (@tokens) { | |||||||||||||||||||||||||||
| 141 | 6 | my @child = $self->_child($t); | |||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | # remove tokens that are cores from child list | ||||||||||||||||||||||||||||
| 144 | 6 | my @tmp; | |||||||||||||||||||||||||||
| 145 | 6 | foreach (@child) { | |||||||||||||||||||||||||||
| 146 | 12 | ▶ | push @tmp, $_ unless $self->_is_core($_); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 147 | 12 | ▶ | push @tmp, $_ if $_->{id} == $t->{id}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 6 | @child = @tmp; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 6 | ▶ | next unless @child; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 6 | push @list, { tokens=>[@child] }; | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | 3 | push @acts, { verb=>$verb, acts=>[@list] }; | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 3 | return @acts; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | sub _score { | ||||||||||||||||||||||||||||
| 161 | 47 | ▶ | my ($token, $verb) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_score: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 162 | 47 | my $score = 0; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 47 | $score = _score_token($token, $verb); | |||||||||||||||||||||||||||
| 165 | 47 | my $dist = _dist($token, $verb); | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 47 | ▶ | return ($dist ? $score/sqrt($dist) : 0); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | sub _score_token { | ||||||||||||||||||||||||||||
| 171 | 47 | ▶ | my ($token) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_score_token: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||
| 173 | 47 | my $score = (_score_pos($token->{pos}) + _score_rule($token->{rule})) / 2; | |||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 47 | return $score; | |||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | sub _score_pos { | ||||||||||||||||||||||||||||
| 179 | 47 | ▶ | my ($pos) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_score_pos: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 47 | ▶ | return 0.8 if ($pos =~ m/^(noun|propn|prop)$/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 182 | 33 | ▶ | return 0 if ($pos =~ m/^(punct)$/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 26 | return 0; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | sub _score_rule { | ||||||||||||||||||||||||||||
| 188 | 47 | ▶ | my ($rule) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_score_rule: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||
| 190 | 47 | ▶ | return 0.8 if ($rule =~ m/^(nsubj|nsubjpass)$/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 191 | 40 | ▶ | return 0.6 if ($rule =~ m/^(dobj)$/i); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 33 | return 0; | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | sub _dist { | ||||||||||||||||||||||||||||
| 197 | 47 | ▶ | my ($token, $verb) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_dist: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 47 | my $dist = 0; | |||||||||||||||||||||||||||
| 200 | 47 | $dist = $token->{id} - $verb->{id}; | |||||||||||||||||||||||||||
| 201 | 47 | ▶ | $dist *= -1 if $dist < 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||
| 203 | 47 | return $dist; | |||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | sub _child { | ||||||||||||||||||||||||||||
| 207 | 6 | ▶ | my ($self, $node) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_child: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 208 | 6 | my @child = (); | |||||||||||||||||||||||||||
| 209 | 6 | my $data = $self->{data}; | |||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 6 | my $id_tree = {}; | |||||||||||||||||||||||||||
| 212 | 6 | $id_tree = _id_tree($id_tree, $node, $data); | |||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 6 | foreach my $id (sort keys %$id_tree) { | |||||||||||||||||||||||||||
| 215 | 12 | foreach (@$data) { | |||||||||||||||||||||||||||
| 216 | 84 | ▶ | push @child, $_ if $_->{id} == $id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 6 | return @child; | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | sub _id_tree { | ||||||||||||||||||||||||||||
| 224 | 12 | ▶ | my ($id_tree, $node, $data) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_id_tree: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 12 | $id_tree->{$node->{id}}++; | |||||||||||||||||||||||||||
| 227 | 12 | foreach (@$data) { | |||||||||||||||||||||||||||
| 228 | 84 | ▶ | if ($node->{id} == $_->{dep}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | 6 | $id_tree = _id_tree($id_tree, $_, $data) | |||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | 12 | return $id_tree; | |||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | sub _is_core { | ||||||||||||||||||||||||||||
| 237 | 12 | ▶ | my ($self, $token) = @_; | ||||||||||||||||||||||||||
|
Subroutine
_is_core: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 12 | foreach my $i (@{$self->{cores}}) { | |||||||||||||||||||||||||||
| 240 | 12 | foreach (@{$i->{cores}}) { | |||||||||||||||||||||||||||
| 241 | 21 | ▶ | return 1 if ($token->{id} == $_->{id}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | } | ||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||
| 245 | 6 | return 0; | |||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | sub pp_acts_cores { | ||||||||||||||||||||||||||||
| 249 | 0 | ▶ | my ($self, $cores) = @_; | ||||||||||||||||||||||||||
|
Subroutine
pp_acts_cores: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 250 | 0 | ▶ | $cores = $self->{cores} unless $cores; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | my $r = "# Actants syntagma cores\n"; | |||||||||||||||||||||||||||
| 253 | 0 | foreach (@$cores) { | |||||||||||||||||||||||||||
| 254 | 0 | my ($verb, @tokens) = ($_->{verb}, @{$_->{cores}} ); | |||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 0 | $r .= " Verb: $verb->{form}\n"; | |||||||||||||||||||||||||||
| 257 | 0 | foreach (@tokens) { | |||||||||||||||||||||||||||
| 258 | #$r .= sprintf " %.6f | %s\n", $_->{score}, $_->{form}; | ||||||||||||||||||||||||||||
| 259 | 0 | $r .= sprintf " + %s\n", $_->{form}; | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 0 | return $r; | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | sub pp_acts_syntagmas { | ||||||||||||||||||||||||||||
| 267 | 0 | ▶ | my ($self, $acts) = @_; | ||||||||||||||||||||||||||
|
Subroutine
pp_acts_syntagmas: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||
| 268 | 0 | ▶ | $acts = $self->{acts} unless $acts; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 0 | my $r = "# Actants syntagmas\n"; | |||||||||||||||||||||||||||
| 271 | 0 | foreach (@$acts) { | |||||||||||||||||||||||||||
| 272 | 0 | my ($verb, @list) = ($_->{verb}, @{ $_->{acts} }); | |||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 0 | $r .= " Verb: $verb->{form}\n"; | |||||||||||||||||||||||||||
| 275 | 0 | my $i = 1; | |||||||||||||||||||||||||||
| 276 | 0 | foreach (@list) { | |||||||||||||||||||||||||||
| 277 | $r .= sprintf " %s: %s\n", | ||||||||||||||||||||||||||||
| 278 | "A$i", | ||||||||||||||||||||||||||||
| 279 | 0 | join(' ', map {$_->{form}} @{ $_->{tokens}}); | |||||||||||||||||||||||||||
| 280 | 0 | $i++; | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 0 | return $r; | |||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | sub pp_acts_ranks { | ||||||||||||||||||||||||||||
| 288 | 0 | ▶ | my ($self, $ranks) = @_; | ||||||||||||||||||||||||||
|
Subroutine
pp_acts_ranks: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 289 | 0 | ▶ | $ranks = $self->{ranks} unless $ranks; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 0 | my $r = "# Actants cores ranks\n"; | |||||||||||||||||||||||||||
| 292 | 0 | foreach (@$ranks) { | |||||||||||||||||||||||||||
| 293 | 0 | my ($verb, @rank) = ($_->{verb}, @{$_->{rank}} ); | |||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | 0 | $r .= " Verb: $verb->{form}\n"; | |||||||||||||||||||||||||||
| 296 | 0 | foreach (@rank) { | |||||||||||||||||||||||||||
| 297 | 0 | $r .= sprintf " %.6f | %s\n", $_->{score}, $_->{token}->{form}; | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||
| 301 | 0 | return $r; | |||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 3 | 1; | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | __END__ | ||||||||||||||||||||||||||||