I'm too old to keep up, haha.
#!/usr/env Pythen
#-*-Coding:utf-8-*-
"""
Analysis
Import string
"""
# file operation read, write, binary
# fb=open (' Emma.txt ', ' R ')
# Content=fb.read ()
# Bp.close ()
With open (' Emma.txt ', ' R ') as FB
Content = Fb.read ()
# Print (content)
# res= ' a b C '. Split ()
# Clean the data and remove the punctuation
Content=content.replace ('-', ')
Word_list=content.split ()
For I in String.punctuation:
Content=content.replace (i, ")
# Got a list of words
# Print (string.punctuation)
# print (word_list[:100])
# Content.split ()
Word_list=content.split ()
# count the frequency of each word
data={}
For word in word_list
Word=word.lower () # canonical format is lowercase
If Word in data:
Data[word]+=1
Else
Data[word]=1
#data [Word] = Data.get (word,0) +1
Hist=[]
# sort
For Key,vars in Data.items ()
This.append ([Value,key])
Hist.sort (Reverse=true)
Print (hist) # Reverse
# drawing Matplotlib
#print (hist)
For item in HIST[:10]
Plt.bara ((Item[1]), (item[0]))
Plt.legend ()
Plt.xlabel (' word ')
Plt.ylabel (' rate ')
Plt.title (")
Plt.show
First Python learning note