Skip to content

Instantly share code, notes, and snippets.

@BernardOng
Last active August 22, 2016 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BernardOng/26cd0d0e3d8509c47bb26c78c8dabfa9 to your computer and use it in GitHub Desktop.
Save BernardOng/26cd0d0e3d8509c47bb26c78c8dabfa9 to your computer and use it in GitHub Desktop.
def add(self, title, rating):
newsent = self.cleanTokens(title)
for x in range(len(newsent)):
if newsent[x] not in self.corpus:
self.corpus[newsent[x]] = [0,0,0,0,0]
if rating > 0.00 and rating <= 1.44: self.corpus[newsent[x]][0] += 1
if rating > 1.44 and rating <= 2.44: self.corpus[newsent[x]][1] += 1
if rating > 2.44 and rating <= 3.44: self.corpus[newsent[x]][2] += 1
if rating > 3.44 and rating <= 4.44: self.corpus[newsent[x]][3] += 1
if rating > 4.44 and rating <= 5.00: self.corpus[newsent[x]][4] += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment