Commit 17ef7c7e authored by Toby Boyd's avatar Toby Boyd
Browse files

Merge branch 'master' of github.com:tensorflow/models

parents 8008e72f a380b4b3
......@@ -34,6 +34,7 @@ the scored human judgement.
"""
from __future__ import print_function
import scipy.stats
import sys
from getopt import GetoptError, getopt
......@@ -42,8 +43,8 @@ from vecs import Vecs
try:
opts, args = getopt(sys.argv[1:], '', ['embeddings=', 'vocab='])
except GetoptError, e:
print >> sys.stderr, e
except GetoptError as e:
print(e, file=sys.stderr)
sys.exit(2)
opt_embeddings = None
......@@ -56,19 +57,20 @@ for o, a in opts:
opt_vocab = a
if not opt_vocab:
print >> sys.stderr, 'please specify a vocabulary file with "--vocab"'
print('please specify a vocabulary file with "--vocab"', file=sys.stderr)
sys.exit(2)
if not opt_embeddings:
print >> sys.stderr, 'please specify the embeddings with "--embeddings"'
print('please specify the embeddings with "--embeddings"', file=sys.stderr)
sys.exit(2)
try:
vecs = Vecs(opt_vocab, opt_embeddings)
except IOError, e:
print >> sys.stderr, e
except IOError as e:
print(e, file=sys.stderr)
sys.exit(1)
def evaluate(lines):
acts, preds = [], []
......@@ -85,6 +87,7 @@ def evaluate(lines):
rho, _ = scipy.stats.spearmanr(acts, preds)
return rho
for filename in args:
with open(filename, 'r') as lines:
print '%0.3f %s' % (evaluate(lines), filename)
print('%0.3f %s' % (evaluate(lines), filename))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment