keywords = open('keywords.txt',encoding='utf-8').read() | |
keywords = set([key.strip() for key in keywords.split()]) | |
def hscore(text): | |
cnt = 0 | |
for i in range(len(text)): | |
if text[i:i+1] in keywords or text[i:i+2] in keywords: | |
cnt+=1 | |
return cnt/len(text) |