word.py 478 B

1234567891011121314151617181920212223
  1. # Data structure for holding data
  2. class Word():
  3. def __init__(self, char, freq = 0, deg = 0):
  4. self.freq = freq
  5. self.deg = deg
  6. self.char = char
  7. def returnScore(self):
  8. return self.deg/self.freq
  9. def updateOccur(self, phraseLength):
  10. self.freq += 1
  11. self.deg += phraseLength
  12. def getChar(self):
  13. return self.char
  14. def updateFreq(self):
  15. self.freq += 1
  16. def getFreq(self):
  17. return self.freq