problem :( The main thing is that the seventh void really doesn't )
In Chinese, structural auxiliary words mainly express the structural relationship between additional components and the head language , In written language, structural auxiliary words are usually written in three words :“ Of ”、“ The earth ”、“ have to ”. This can make the structural relationship in written language clearer . Please make statistics sefile104.txt
The types of structural auxiliary words in the document , And arrange each structural auxiliary word from less to more , Then output the number to the screen , Format requirements : Width is 5 Characters , Minus character - fill , Right alignment . Be careful sefile104.txt The code of the file is UTF-8(UTF-8 Use uppercase ), All strings in the program use double quotation marks
"" Express .
Please put the number (1)~(10) And the corresponding underline are deleted , Fill in the blanks to complete the statements in the program , You cannot modify existing code .
import jieba
list_names=[" Of "," The earth "," have to "]
list1=[]
count={} # To count
with open("sefile104.txt","r",(1)) as f: #1
txt=f.(2) #2
words=(3)(txt) #3 Use precise patterns for word segmentation
for word in words:
if word (4) list_names: #4 If the word is not a structural auxiliary , Then don't record the participle
(5) #5
list1.append(word)
count[word]= (6)+1 #6
kind=(7)_(list1)) #7 The types of structural auxiliary words in statistical documents
print("sefile104.txt The types of structural auxiliary words in the document are :%d"%kind)
items=(8)_(count.items()) #8 Return it as a list type
items.sort(key=lambda x:x[1],(9)__) #9 Sort by number in ascending order
for i in range(kind):
var,number=items[i]
print(' In file "{0}" Word occurrence times { (10) }'.format(var,number)) #10