~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to storage/myisam/ftbench/Ereport.pl

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
die "Use: $0 eval_output qrels_file\n" unless @ARGV==2;
 
4
 
 
5
open(EOUT,$eout=shift) || die "Cannot open $eout: $!";
 
6
open(RELJ,$relj=shift) || die "Cannot open $relj: $!";
 
7
 
 
8
$_=<EOUT>;
 
9
die "$eout must start with a number!\n "unless /^[1-9][0-9]*\n/;
 
10
$ndocs=$_+0;
 
11
 
 
12
$qid=0;
 
13
$relj_str=<RELJ>;
 
14
$eout_str=<EOUT>;
 
15
 
 
16
while(!eof(RELJ) || !eof(EOUT)) {
 
17
  ++$qid;
 
18
  %dq=();
 
19
  $A=$B=$AB=0;
 
20
  $Ravg=$Pavg=0;
 
21
 
 
22
  while($relj_str =~ /^0*$qid\s+(\d+)/) {
 
23
    ++$A;
 
24
    $dq{$1+0}=1;
 
25
    last unless $relj_str=<RELJ>;
 
26
  }
 
27
  # Favg measure = 1/(a/Pavg+(1-a)/Ravg)
 
28
sub Favg { my $a=shift; $Pavg*$Ravg ? 1/($a/$Pavg+(1-$a)/$Ravg) : 0; }
 
29
  # F0    : a=0                 -- ignore precision
 
30
  # F5    : a=0.5
 
31
  # F1    : a=1                 -- ignore recall
 
32
  while($eout_str =~ /^$qid\s+(\d+)\s+(\d+(?:\.\d+)?)/) {
 
33
    $B++;
 
34
    $AB++ if $dq{$1+0};
 
35
    $Ravg+=$AB;
 
36
    $Pavg+=$AB/$B;
 
37
    last unless $eout_str=<EOUT>;
 
38
  }
 
39
  next unless $A;
 
40
 
 
41
  $Ravg/=$B*$A if $B;
 
42
  $Pavg/=$B    if $B;
 
43
 
 
44
  printf "%5d %1.12f %1.12f %1.12f\n", $qid, Favg(0),Favg(0.5),Favg(1);
 
45
}
 
46
 
 
47
exit 0;
 
48
 
 
49