5 Einträge, 1 Seite |
1
2
3
4
5
6
7
8
9
10
@array =
(
{ utterance => 'ja', score => 0.27 },
{ utterance => 'nein', score => 0.75 },
{ utterance => 'nein', score => 0.83 },
{ utterance => 'ja', score => 0.53 },
{ utterance => 'ja', score => 0.69 },
{ utterance => 'nicht wirklich', score => 0.59 },
...
);
1
2
3
utterance: 'ja', anzahl: 3, sum_score: 1.49, min_score: 0.27, max_score: 0.69
utterance: 'nein', anzahl: 2, sum_score: 1.58, min_score: 0.75, max_score: 0.83
utterance: 'nicht wirklich', anzahl: 1, sum_score: 0.59, min_score: 0.59, max_score: 0.59
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
my @array =
(
{ utterance => 'ja', score => 0.27 },
{ utterance => 'nein', score => 0.75 },
{ utterance => 'nein', score => 0.83 },
{ utterance => 'ja', score => 0.53 },
{ utterance => 'ja', score => 0.69 },
{ utterance => 'nicht wirklich', score => 0.59 },
);
my %result;
for my $elem(@array){
my $key = $elem->{utterance};
my $score = $elem->{score};
$result{$key} = {score => 0, max_score => 0, min_score => 10_000} unless exists $result{$key};
$result{$key}->{score} += $score;
if($result{$key}->{max_score} < $score){
$result{$key}->{max_score} = $score;
}
if($result{$key}->{min_score} > $score){
$result{$key}->{min_score} = $score;
}
}
print Dumper(\%result);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
~/entwicklung 135> perl scores.pl
$VAR1 = {
'nein' => {
'max_score' => '0.83',
'score' => '1.58',
'min_score' => '0.75'
},
'nicht wirklich' => {
'max_score' => '0.59',
'score' => '0.59',
'min_score' => '0.59'
},
'ja' => {
'max_score' => '0.69',
'score' => '1.49',
'min_score' => '0.27'
}
};
5 Einträge, 1 Seite |