-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathposAggregate.pl
executable file
·49 lines (44 loc) · 1.61 KB
/
posAggregate.pl
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/perl
## Aggregates adjacent LAST matches into a single result/match line
use warnings;
use strict;
my ($oldquery, $oldtarget, $olddir, $oldqs, $oldqe, $oldqml,
$oldql, $oldqpct, $oldts, $oldte, $oldtml, $oldtl, $oldtpct) =
("") x 13;
while(<>){
chomp;
my ($query, $target, $dir, $qs, $qe, $qml,
$ql, $qpct, $ts, $te, $tml, $tl, $tpct) =
split(/,/);
if(/^query/){
print($_."\n");
next;
}
if(($query eq $oldquery) && ($target eq $oldtarget) &&
($olddir eq $dir) &&
((($dir eq "+") && ($oldts <= $ts)) ||
(($dir eq "-") && ($oldte >= $te)))){
$qs = $oldqs;
$qml += $oldqml;
$qpct = (($oldqpct * $oldqml) + ($qpct * $qml)) / ($oldqml + $qml);
$ts = $oldts if ($dir eq "+");
$te = $oldte if ($dir eq "-");
$tml += $oldtml;
$tpct = (($oldtpct * $oldtml) + ($tpct * $tml)) / ($oldtml + $tml);
} elsif($oldquery ne "") {
$qpct = sprintf("%0.2f", $qpct);
$tpct = sprintf("%0.2f", $tpct);
print(join(",",($oldquery, $oldtarget, $olddir,
$oldqs, $oldqe, $oldqml, $oldql, $oldqpct,
$oldts, $oldte, $oldtml, $oldtl, $oldtpct))."\n");
}
($oldquery, $oldtarget, $olddir, $oldqs, $oldqe, $oldqml,
$oldql, $oldqpct, $oldts, $oldte, $oldtml, $oldtl, $oldtpct) =
($query, $target, $dir, $qs, $qe, $qml,
$ql, $qpct, $ts, $te, $tml, $tl, $tpct);
}
$oldqpct = sprintf("%0.2f", $oldqpct);
$oldtpct = sprintf("%0.2f", $oldtpct);
print(join(",",($oldquery, $oldtarget, $olddir,
$oldqs, $oldqe, $oldqml, $oldql, $oldqpct,
$oldts, $oldte, $oldtml, $oldtl, $oldtpct))."\n");