class SenseProfile: def __init__(self, word, name, score, answer_history): self.word = word self.name = name self.score = score self.proficiency = AccuracyModel(answer_history=answer_history) # Load object from json representation @staticmethod def load_json(w, sp): word = w name = sp['name'] score = sp['score'] answer_history = eval(sp['answer_history']) return SenseProfile(word, name, score, answer_history) # Update the score given the next correct/incorrect answer def update(self, correct): self.score = self.proficiency.update(correct) # Representation def dict_repr(self): result = { 'name': self.name, 'score': self.score, 'answer_history': self.proficiency.__repr__() } return result def __repr__(self): return "{}||{}".format(self.name, self.score)
class SenseProfile: def __init__(self, parent, sense): self.parent = parent self.sense = sense self.name = sense.name self.score = 0.0 self.proficiency = AccuracyModel() def update(self, correct): self.score = self.proficiency.update(correct) self.parent.update() def __repr__(self): return "{}||{}".format(self.sense.name, self.score)