File size: 1,146 Bytes
ee0ec3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

for d in ${@:-*/}; do
  l=`basename "$d"`

  for f in $l/*.dev; do
    [ -f "$f" ] || continue
    base=${f%.dev}
    [ -s "$base.model" ] || continue
    echo -n "$l "
    perl -ne '
      sub extract_from_log() {
        if ($ARGV =~ /^(.*).dev$/) {
          open (my $f, "<", "$1.log");
          my @s;
          while (<$f>) {
            /Epoch (\d+).*heldout tokens: (\S+), sentences: (\S+)/ and $s[$1] = "$2 $3 ";
            /Choosing parameters from epoch (\d+)/ and print $s[$1];
          }
          close $f;
        } else {
          print "0P/0R/0 0P/0R/0 ";
        }
      }
      #extract_from_log();

      #/No SpaceAfter/ && extract_from_log();
      #/multiwords/ && next;
      /^Tokenizer (?:words|sentences).*precision: ([0-9.]*%).*recall: ([0-9.]*%).*f1: ([0-9.]*%)/ && print "$1P/$2R/$3 ";
      #/ sentences/ && extract_from_log();
    ' $base.dev $base.test
    echo $base
#  done | sort -srV -t/ -k5
  done | perl -aF'/[\s\/]/' -ne 'push @l,$_; $l{$_}=2*$F[3]+$F[6];END{foreach (sort {$l{$b}<=>$l{$a}} @l) {print}}'
  echo
done | perl -pe 's/(\d+\.\d+)%/sprintf "%.2f", $1/ge' | column -te | less -S