spaCy/examples/sentiment/util.py
2016-11-20 03:29:36 +01:00

15 lines
279 B
Python

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)