spaCy/examples/sentiment/util.py

15 lines
279 B
Python
Raw Normal View History

2016-11-20 05:29:36 +03:00
class Scorer(object):
def __init__(self):
self.true = 0
self.total = 0
def __iadd__(self, is_correct):
self.true += is_correct
self.total += 1
return self
def __str__(self):
return '%.3f' % (self.true / self.total)