# reads a result file from STDIN from the rtw_test_hit mechanical turk
# HIT and sums the votes for each item.  

while (<>) {
  chomp;
  @toks = split("\t", $_);
  foreach $tok (@toks) {
    if ($tok =~ m/"false\.(.*)"/) {
	  $all{$1} = 1;
	  $f{$1}++;
	}
    if ($tok =~ m/"true\.(.*)"/) {
	  $all{$1} = 1;
	  $t{$1}++;
	}
  }
}

foreach $k (keys %all) {
  $total = $t{$k} + $f{$k};
  $trues = 0;
  if (exists $t{$k}) {
    $trues = $t{$k};
  }
  $falses = 0;
  if (exists $f{$k}) {
    $falses = $f{$k};
  }
  print "$k\t$trues\t$falses\n";
}
