def define_frequencies (file_contents): # Вот список знаков препинания и неинтересных слов, которые можно использовать для обработки текстовых знаков препинания = '' '! () - [] {} ;:' "\, <> ./? @ # $% ^ & * _ ~ '' 'un Interesting_words = ["the", "a", "to", "if", "is", "it", "of", "and", "or" , "an", "as", "i", "me", "my", \ "we", "our", "ours", "you", "your", "yours", "he", "она", "он", "его", "ее", "ее", "ее", "они", "они", \ "их", "что", "который", "кто", " кого "," этот "," тот "," я "," есть "," был "," были "," быть "," был "," будучи ", \" иметь "," имеет "," имел "," делать "," делает "," сделал "," но "," в "," по "," с "," от "," здесь "," когда "," где "," как ", \ "все", "любой", "оба", "каждый", "немногие", "еще", "некоторые", "такие", "нет", "ни", "слишком", "очень", " может "," будет "," просто "]
frequencies={}
def iterate():
words=file_contents.split()
for word in words:
if word not in uninteresting_words and word not in punctuations:
if word not in frequencies and word in file_contents:
frequencies[word]+=1
else:
frequencies[word]=1
#wordcloud
cloud = wordcloud.WordCloud()
cloud.generate_from_frequencies(frequencies)
return cloud.to_array()
myimage = calculate_frequencies(file_contents)
plt.imshow(myimage, interpolation = 'nearest')
plt.axis('off')
plt.show()