simple-h / score.py
a686d380's picture
Update score.py
779443d verified
raw
history blame
282 Bytes
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)