Advertisement
makispaiktis

Exetastiki2020 - Code - Quality.py

Jul 15th, 2020 (edited)
1,059
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. from math import log
  2.  
  3. word_weights = dict()
  4. def quality(word):
  5.     if len(word_weights)==0:
  6.         with open("count_1w.txt") as file:
  7.             for line in file:
  8.                 splt = line[:-1].split("\t")
  9.                 word_weights[splt[0]] = log(1./(len(word_weights)+1))/len(splt[0])
  10.         for num in range(10000):
  11.             word_weights[str(num)] = num
  12.     return word_weights.get(word, -len(word)*1000)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement