|
|
|
|
|
|
|
|
|
|
|
|
|
use utf8; |
|
use open ':utf8'; |
|
binmode(STDIN, ':utf8'); |
|
binmode(STDOUT, ':utf8'); |
|
binmode(STDERR, ':utf8'); |
|
|
|
my $system_unpacked_folder = '/home/zeman/iwpt2020/_private/data/sysoutputs'; |
|
|
|
|
|
my %languages = |
|
( |
|
'ar' => 'Arabic', |
|
'bg' => 'Bulgarian', |
|
'cs' => 'Czech', |
|
'nl' => 'Dutch', |
|
'en' => 'English', |
|
'et' => 'Estonian', |
|
'fi' => 'Finnish', |
|
'fr' => 'French', |
|
'it' => 'Italian', |
|
'lv' => 'Latvian', |
|
'lt' => 'Lithuanian', |
|
'pl' => 'Polish', |
|
'ru' => 'Russian', |
|
'sk' => 'Slovak', |
|
'sv' => 'Swedish', |
|
'ta' => 'Tamil', |
|
'uk' => 'Ukrainian' |
|
); |
|
my @languages = sort {$languages{$a} cmp $languages{$b}} (keys(%languages)); |
|
|
|
my %dev_treebanks = |
|
( |
|
'ar' => ['Arabic-PADT'], |
|
'bg' => ['Bulgarian-BTB'], |
|
'cs' => ['Czech-FicTree', 'Czech-CAC', 'Czech-PDT'], |
|
'nl' => ['Dutch-Alpino', 'Dutch-LassySmall'], |
|
'en' => ['English-EWT'], |
|
'et' => ['Estonian-EDT'], |
|
'fi' => ['Finnish-TDT'], |
|
'fr' => ['French-Sequoia'], |
|
'it' => ['Italian-ISDT'], |
|
'lv' => ['Latvian-LVTB'], |
|
'lt' => ['Lithuanian-ALKSNIS'], |
|
'pl' => ['Polish-LFG', 'Polish-PDB'], |
|
'ru' => ['Russian-SynTagRus'], |
|
'sk' => ['Slovak-SNK'], |
|
'sv' => ['Swedish-Talbanken'], |
|
'ta' => ['Tamil-TTB'], |
|
'uk' => ['Ukrainian-IU'] |
|
); |
|
my %test_treebanks = |
|
( |
|
'ar' => ['Arabic-PADT'], |
|
'bg' => ['Bulgarian-BTB'], |
|
'cs' => ['Czech-FicTree', 'Czech-CAC', 'Czech-PDT', 'Czech-PUD'], |
|
'nl' => ['Dutch-Alpino', 'Dutch-LassySmall'], |
|
'en' => ['English-EWT', 'English-PUD'], |
|
'et' => ['Estonian-EDT', 'Estonian-EWT'], |
|
'fi' => ['Finnish-TDT', 'Finnish-PUD'], |
|
'fr' => ['French-Sequoia', 'French-FQB'], |
|
'it' => ['Italian-ISDT'], |
|
'lv' => ['Latvian-LVTB'], |
|
'lt' => ['Lithuanian-ALKSNIS'], |
|
'pl' => ['Polish-LFG', 'Polish-PDB', 'Polish-PUD'], |
|
'ru' => ['Russian-SynTagRus'], |
|
'sk' => ['Slovak-SNK'], |
|
'sv' => ['Swedish-Talbanken', 'Swedish-PUD'], |
|
'ta' => ['Tamil-TTB'], |
|
'uk' => ['Ukrainian-IU'] |
|
); |
|
|
|
my %enhancements = |
|
( |
|
'Arabic-PADT' => 'no xsubj', |
|
'Bulgarian-BTB' => '', |
|
'Czech-FicTree' => '', |
|
'Czech-CAC' => '', |
|
'Czech-PDT' => '', |
|
'Czech-PUD' => 'no codepend', |
|
'Dutch-Alpino' => '', |
|
'Dutch-LassySmall' => '', |
|
'English-EWT' => '', |
|
'English-PUD' => '', |
|
'Estonian-EDT' => 'no xsubj', |
|
'Estonian-EWT' => 'no codepend, no xsubj', |
|
'Finnish-TDT' => '', |
|
'Finnish-PUD' => 'no codepend, no xsubj', |
|
'French-Sequoia' => 'no gapping, relcl, case', |
|
'French-FQB' => 'no gapping, relcl, case', |
|
'Italian-ISDT' => '', |
|
'Latvian-LVTB' => '', |
|
'Lithuanian-ALKSNIS' => '', |
|
'Polish-LFG' => 'no gapping', |
|
'Polish-PDB' => '', |
|
'Polish-PUD' => '', |
|
'Russian-SynTagRus' => '', |
|
'Slovak-SNK' => '', |
|
'Swedish-Talbanken' => '', |
|
'Swedish-PUD' => '', |
|
'Tamil-TTB' => 'no gapping, xsubj, relcl', |
|
'Ukrainian-IU' => '', |
|
); |
|
|
|
if(scalar(@ARGV)!=3) |
|
{ |
|
die("Three arguments expected: team name, submission id, and dev|test"); |
|
} |
|
my $team = $ARGV[0]; |
|
my $submid = $ARGV[1]; |
|
my $portion = $ARGV[2]; |
|
if($team !~ m/^[a-z0-9_]+$/) |
|
{ |
|
die("Invalid team name '$team': must be [a-z0-9_]+"); |
|
} |
|
if($submid !~ m/^[a-z0-9_]+$/) |
|
{ |
|
die("Invalid submission id '$submid': must be [a-z0-9_]+"); |
|
} |
|
if($portion !~ m/^(dev|test)$/) |
|
{ |
|
die("Unknown data portion '$portion', should be 'dev' or 'test'"); |
|
} |
|
my $submission_folder = "$system_unpacked_folder/$team/$submid"; |
|
my %treebanks = $portion eq 'dev' ? %dev_treebanks : %test_treebanks; |
|
|
|
foreach my $language (@languages) |
|
{ |
|
|
|
my $file = "$submission_folder/$language.eval.log"; |
|
if(-f $file) |
|
{ |
|
open(EVAL, $file) or die("Cannot read '$file': $!"); |
|
while(<EVAL>) |
|
{ |
|
s/\r?\n$//; |
|
if(m/^\w+.*\|.*\d+/) |
|
{ |
|
my @f = split(/\s*\|\s*/, $_); |
|
my $metric = shift(@f); |
|
my $p = shift(@f); |
|
my $r = shift(@f); |
|
my $f = shift(@f); |
|
my $a = shift(@f); |
|
$score{language}{$language}{$metric} = |
|
{ |
|
'p' => $p, |
|
'r' => $r, |
|
'f' => $f, |
|
'a' => $a |
|
}; |
|
} |
|
} |
|
close(EVAL); |
|
} |
|
} |
|
my @treebanks; |
|
my $doing_dev; |
|
foreach my $language (@languages) |
|
{ |
|
my $language_reliable = exists($score{language}{$language}); |
|
foreach my $treebank (@{$treebanks{$language}}) |
|
{ |
|
push(@treebanks, $treebank); |
|
my $tcode = lc($treebank); |
|
$tcode =~ s/^.+-//; |
|
|
|
my $file = "$submission_folder/pertreebank/${language}_$tcode-ud"; |
|
if(-e "$file-dev.eval.log" && -e "$file-test.eval.log") |
|
{ |
|
die("Both dev and test eval.log exist for '$file'"); |
|
} |
|
elsif(-e "$file-dev.eval.log") |
|
{ |
|
$file .= '-dev.eval.log'; |
|
if(!defined($doing_dev)) |
|
{ |
|
$doing_dev = 1; |
|
} |
|
elsif($doing_dev==0) |
|
{ |
|
die("Both dev and test eval logs are present in the per-treebank folder."); |
|
} |
|
} |
|
elsif(-e "$file-test.eval.log") |
|
{ |
|
$file .= '-test.eval.log'; |
|
if(!defined($doing_dev)) |
|
{ |
|
$doing_dev = 0; |
|
} |
|
elsif($doing_dev==1) |
|
{ |
|
die("Both dev and test eval logs are present in the per-treebank folder."); |
|
} |
|
} |
|
|
|
if(-f $file && $language_reliable) |
|
{ |
|
open(EVAL, $file) or die("Cannot read '$file': $!"); |
|
while(<EVAL>) |
|
{ |
|
s/\r?\n$//; |
|
if(m/^\w+.*\|.*\d+/) |
|
{ |
|
my @f = split(/\s*\|\s*/, $_); |
|
my $metric = shift(@f); |
|
my $p = shift(@f); |
|
my $r = shift(@f); |
|
my $f = shift(@f); |
|
my $a = shift(@f); |
|
$score{treebank}{$treebank}{$metric} = |
|
{ |
|
'p' => $p, |
|
'r' => $r, |
|
'f' => $f, |
|
'a' => $a |
|
}; |
|
} |
|
} |
|
close(EVAL); |
|
} |
|
|
|
$score{treebank}{$treebank}{language} = $score{language}{$language}; |
|
|
|
$score{language}{$language}{QualitativeSUM}{ELAS}{f} += $score{treebank}{$treebank}{ELAS}{f}; |
|
$score{language}{$language}{QualitativeCNT}++; |
|
} |
|
} |
|
my $html = "<html>\n"; |
|
$html .= "<head>\n"; |
|
$html .= " <title>IWPT Results of $team/$submid</title>\n"; |
|
$html .= "</head>\n"; |
|
$html .= "<body>\n"; |
|
$html .= " <h1>IWPT 2020 Shared Task Results of <span style='color:blue'>$team</span>/$submid</h1>\n"; |
|
my @metrics = qw(Tokens Words Sentences UPOS XPOS UFeats AllTags Lemmas UAS LAS CLAS MLAS BLEX EULAS ELAS); |
|
$html .= " <h2>Coarse F<sub>1</sub> Scores</h2>\n"; |
|
$html .= " <p>Each score pertains to the combined test set of the language, without distinguishing individual treebanks and the enhancement types they annotate. The last line shows the macro-average over languages.</p>\n"; |
|
$html .= " <table>\n"; |
|
$html .= " <tr><td><b>Language</b></td>"; |
|
foreach my $metric (@metrics) |
|
{ |
|
$html .= "<td><b>$metric</b></td>"; |
|
} |
|
$html .= "</tr>\n"; |
|
foreach my $language (@languages) |
|
{ |
|
my $lh = $score{language}{$language}; |
|
$html .= " <tr><td>$languages{$language}</td>"; |
|
foreach my $metric (@metrics) |
|
{ |
|
$html .= "<td>$lh->{$metric}{f}</td>"; |
|
$score{language}{SUM}{$metric}{f} += $lh->{$metric}{f}; |
|
} |
|
$html .= "</tr>\n"; |
|
} |
|
my $n = scalar(@languages); |
|
$html .= " <tr><td><b>Average</b></td>"; |
|
foreach my $metric (@metrics) |
|
{ |
|
$score{language}{AVG}{$metric}{f} = sprintf("%.2f", $score{language}{SUM}{$metric}{f}/$n); |
|
$html .= "<td><b>$score{language}{AVG}{$metric}{f}</b></td>"; |
|
} |
|
$html .= "</tr>\n"; |
|
$html .= " </table>\n"; |
|
$html .= " <h2>Qualitative F<sub>1</sub> Scores</h2>\n"; |
|
$html .= " <p>The system output for each language was split into parts corresponding to individual source treebanks. ". |
|
"The scores then ignore errors in enhancement types for which the treebank lacks gold-standard annotation. ". |
|
"The column LAvgELAS shows the qualitative ELAS averaged over treebanks of the same language; ". |
|
"the final average in bold is averaged over languages rather than treebanks. ". |
|
"For comparison, the last column then shows the coarse ELAS F<sub>1</sub> for the given language.</p>\n"; |
|
$html .= " <table>\n"; |
|
$html .= " <tr><td><b>Treebank</b></td>"; |
|
foreach my $metric (@metrics) |
|
{ |
|
$html .= "<td><b>$metric</b></td>"; |
|
} |
|
|
|
$html .= "<td><b>Enhancements</b></td>"; |
|
|
|
$html .= "<td><b>LAvgELAS</b></td>"; |
|
|
|
$html .= "<td><b>cf.</b></td>"; |
|
$html .= "</tr>\n"; |
|
foreach my $treebank (@treebanks) |
|
{ |
|
my $lh = $score{treebank}{$treebank}; |
|
$html .= " <tr><td>$treebank</td>"; |
|
foreach my $metric (@metrics) |
|
{ |
|
$html .= "<td>$lh->{$metric}{f}</td>"; |
|
$score{treebank}{SUM}{$metric}{f} += $lh->{$metric}{f}; |
|
} |
|
|
|
my $omitted = $enhancements{$treebank} ne '' ? "($enhancements{$treebank})" : ''; |
|
$html .= "<td>$omitted</td>"; |
|
|
|
my $sum = $lh->{language}{QualitativeSUM}{ELAS}{f}; |
|
my $cnt = $lh->{language}{QualitativeCNT}; |
|
my $avg = $lh->{language}{QualitativeAVG}{ELAS}{f} = $cnt==0 ? 0 : sprintf("%.2f", $sum/$cnt); |
|
$html .= "<td>$avg</td>"; |
|
|
|
$html .= "<td>$lh->{language}{ELAS}{f}</td>"; |
|
$html .= "</tr>\n"; |
|
} |
|
$n = scalar(@treebanks); |
|
$html .= " <tr><td><b>Average</b></td>"; |
|
foreach my $metric (@metrics) |
|
{ |
|
$score{treebank}{AVG}{$metric}{f} = $n==0 ? 0 : sprintf("%.2f", $score{treebank}{SUM}{$metric}{f}/$n); |
|
$html .= "<td><b>$score{treebank}{AVG}{$metric}{f}</b></td>"; |
|
} |
|
|
|
$html .= "<td></td>"; |
|
|
|
|
|
my $sum = 0; |
|
$n = scalar(@languages); |
|
foreach my $language (@languages) |
|
{ |
|
$sum += $score{language}{$language}{QualitativeAVG}{ELAS}{f}; |
|
} |
|
$score{language}{QualitativeAVG}{ELAS}{f} = $n==0 ? 0 : sprintf("%.2f", $sum/$n); |
|
$html .= "<td><b>$score{language}{QualitativeAVG}{ELAS}{f}</b></td>"; |
|
|
|
$html .= "<td></td>"; |
|
$html .= "</tr>\n"; |
|
$html .= " </table>\n"; |
|
$html .= "</body>\n"; |
|
$html .= "</html>\n"; |
|
print($html); |
|
|