#!/usr/local/bin/perl -w

my %hash;
my $curref;

while (<>) {
  if (/^Should be (\w+), but marked (\w+)\:/) {
    my ($correct, $bad) = ($1, $2);
    push @{$hash{$correct}{$bad}}, "";
    #print "BIZ", @{$hash{$correct}{$bad}}, "BOZ\n";
    $curref = \${$hash{$correct}{$bad}}[-1];
    #print ref($curref);
  } else {
    #print "FOO" . $$curref . "BAR" . $_ . "BAZ";
    ${$curref} .= $_;
  }
}

foreach my $correct (sort keys %hash) {
  print "\nTreebank has $correct " . '='x40 . "\n";
  foreach my $bad (sort keys %{$hash{$correct}}) {
    print "\nParser had $bad " . '-'x20 . "\n";
    foreach my $example (@{$hash{$correct}{$bad}}) {
      print $example;
    }
  }
}
