Add support for verbose flag to Language

This commit is contained in:
Matthew Honnibal 2017-10-03 09:14:57 -05:00
parent 02586a5243
commit 96da86b3e5

View File

@ -388,7 +388,7 @@ class Language(object):
self._optimizer.device = device self._optimizer.device = device
return self._optimizer return self._optimizer
def evaluate(self, docs_golds): def evaluate(self, docs_golds, verbose=False):
scorer = Scorer() scorer = Scorer()
docs, golds = zip(*docs_golds) docs, golds = zip(*docs_golds)
docs = list(docs) docs = list(docs)
@ -401,7 +401,9 @@ class Language(object):
docs = list(pipe.pipe(docs)) docs = list(pipe.pipe(docs))
assert len(docs) == len(golds) assert len(docs) == len(golds)
for doc, gold in zip(docs, golds): for doc, gold in zip(docs, golds):
scorer.score(doc, gold) if verbose:
print(doc)
scorer.score(doc, gold, verbose=verbose)
return scorer return scorer
@contextmanager @contextmanager