Created
March 1, 2016 23:37
-
-
Save kindleton/be141f9eacd3cb38c3b2 to your computer and use it in GitHub Desktop.
Calculate accuracy for CRF++ output file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
f1 = open(sys.argv[1]) | |
count = 0 | |
true = 0 | |
false = 0 | |
sentences = 0 | |
for line in f1: | |
if line == '\n' or line.split()==[]: | |
sentences+=1 | |
continue | |
count = count + 1 | |
x = line.strip().split() | |
if(x[-1]==x[-2]): | |
true=true+1 | |
else: | |
false = false+1 | |
print '#true', '#false', '#total_words', '#sentences' | |
print true, false, count, sentences | |
print 'accuracy = ', (100.0*true/count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment