综合练习
詞頻統計預處理
下載一首英文的歌詞或文章
將所有,.?!’:等分隔符全部替換為空格
將所有大寫轉換為小寫
生成單詞列表
生成詞頻統計
排序
排除語法型詞匯,代詞、冠詞、連詞
輸出詞頻最大TOP10
text="No matter how many characters are available for your password you should be sure to use every one of them. The more characters available for your password and the more you use makes it that much harder to figure out the combination. Always make use of all characters available for a strong and secure password.Personal information such as names, birthdays, nicknames, pet's names, social security numbers, and the like should never, ever, ever be used because these are way too obvious and too easy to crack. The more you avoid using things like this as your passwords, the more secure your login areas will be."
sym=[',','.','!','?','’',':','$','%']
word= ['a','in','of','the','to','at','it','on','and','so','his','that',
'not','was','my','were','we','he','an','as','is','for','mr','us']
new_text=text
for i in range(len(sym)):
new_text=new_text.replace(sym[i],'')
new_text=new_text.lower()
text_list=new_text.split()
d=dict(zip())
for i in text_list:
d[i]=new_text.count(i)
for i in word:
if(d.get(i)!=None):
d.pop(i)
new_d=sorted(d.items(),key=lambda x:x[1],reverse=True)
for i in range(10):
print(new_d[i])
總結
- 上一篇: SAP Spartacus Org un
- 下一篇: SAP Spartacus里如何查找所有