#!/usr/bin/perl -w ## ## evaluate -- evaluate a part of speech tagger ## $sentences = 0; $s_right = 0; $words = 0; $w_right = 0; open GOLD, "$ARGV[0]"; open TEST, "$ARGV[1]"; while (my $gline = ) { my $tline = ; chomp $gline; chomp $tline; my @gwords = split /\s+/, $gline; my @twords = split /\s+/, $tline; my $serror = 0; while (@gwords) { $words++; $x = shift @gwords; $y = shift @twords; if ($x eq $y) { $w_right++; } else { $serror = 1; } } $sentences++; $s_right++ unless $serror; } print STDERR "$w_right out of $words tags correct\n"; printf STDERR "%.2f%% word accuracy\n", $w_right/$words * 100.0; printf STDERR "%.2f%% sentence accuracy\n", $s_right/$sentences * 100.0 ;