File size: 282 Bytes
779443d
 
 
386dc73
 
 
 
 
 
1
2
3
4
5
6
7
8
9
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)