#!/usr/local/bin/perl
# scan referee reports for ISCA #20

# pno = paper number
# ptl = paper title
# cnf = confidence rating
# imp = importance
# qty = quality
# tch = technical 
# act = action
# rnm = referee name
# raf = referee affiliatio

sub INIT {
    &OUTPUT if ($dirty);
    # initialize state for new paper
    $pno = "???";
    $ptl = "???";
    $cnf = "???";
    $imp = "???";
    $qty = "???";
    $tch = "???";
    $act = "???";
    $rnm = "???";
    $raf = "???";
}

sub OUTPUT {
    print $pno,$cnf,$imp,$qty,$tch,$act,$rnm,$ptl,"\n";
    $dirty = 0;
}

$, = ":%:";
$dirty = 0;
&INIT;
while(<>) {
    chop;
  MAIN: {
      if (/^\s*1993 ISCA #20--Electronic Referee\'s Report\s*$/) {
	  &INIT;
	  last MAIN;
      }				
      if (/Paper Number:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($pno == "???");
	  $dirty = 1;
	  /:\s*(\d+)/;
	  $pno = sprintf("%03d",$1);
	  die "Invalid data at $. in $ARGV\n" unless (1 <= $pno && $pno <= 1000);
	  last MAIN;
      }
      if (/Paper Title:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($ptl == "???");
	  $dirty = 1;
	  ($junk,$ptl) = split(/:\s*/);
	  last MAIN;
      }
      if (/Confidence in your evaluation:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($cnf == "???");
	  $dirty = 1;
	  /:\s*(\d+\.?\d*)/;
	  $cnf = $1;
	  die "Invalid data at $. in $ARGV\n" unless (0 <= $cnf && $cnf <= 5);
	  last MAIN;
      }
      if (/Interest\/Importance to ISCA:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($imp == "???");
	  $dirty = 1;
	  /:\s*(\d+\.?\d*)/;
	  $imp = $1;
	  die "Invalid data at $. in $ARGV\n" unless (0 <= $imp && $imp <= 5);
	  last MAIN;
      }
      if (/Quality of presentation:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($qty == "???");
	  $dirty = 1;
	  /:\s*(\d+\.?\d*)/;
	  $qty = $1;
	  $qty = $1;
	  die "Invalid data at $. in $ARGV\n" unless (0 <= $qty && $qty <= 5);
	  last MAIN;
      }
      if (/Technical contribution of paper:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($tch == "???");
	  $dirty = 1;
	  /:\s*(\d+\.?\d*)/;
	  $tch = $1;
	  die "Invalid data at $. in $ARGV\n" unless (0 <= $tch && $tch <= 5);
	  last MAIN;
      }
      if (/Recommended action for paper:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($act == "???");
	  $dirty = 1;
	  /:\s*(\d+\.?\d*)/;
	  $act = $1;
	  die "Invalid data at $. in $ARGV\n" unless (0 <= $act && $act <= 5);
	  last MAIN;
      }
      if (/Referee\'s name:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($rnm == "???");
	  $dirty = 1;
	  ($junk,$rnm) = split(/:\s*/);
	  last MAIN;
      }
      if (/Referee\'s affiliation:/i) {
	  die "Redundent data at $. in $ARGV\n" unless ($raf == "???");
	  $dirty = 1;
	  ($junk,$raf) = split(/:\s*/);
	  last MAIN;
      }
      if (/\+{10,}/) {		# 10 or more pluses
	  &INIT;
	  last MAIN;
      }
  }
    
    if (eof)
    {
	close(ARGV);	# reset line numbering
	&INIT;
    }
}

