Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import log
- word_weights = dict()
- def quality(word):
- if len(word_weights)==0:
- with open("count_1w.txt") as file:
- for line in file:
- splt = line[:-1].split("\t")
- word_weights[splt[0]] = log(1./(len(word_weights)+1))/len(splt[0])
- for num in range(10000):
- word_weights[str(num)] = num
- return word_weights.get(word, -len(word)*1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement