-
Notifications
You must be signed in to change notification settings - Fork 0
/
file.txt
40 lines (30 loc) · 1.45 KB
/
file.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
Farhan
Vaskor
Zeya
Quayyum
def calculate_frequencies(file_contents):
# Here is a list of punctuations and uninteresting words you can use to process your text
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
uninteresting_words = ["the", "a", "to", "if", "is", "it", "of", "and", "or", "an", "as", "i", "me", "my", \
"we", "our", "ours", "you", "your", "yours", "he", "she", "him", "his", "her", "hers", "its", "they", "them", \
"their", "what", "which", "who", "whom", "this", "that", "am", "are", "was", "were", "be", "been", "being", \
"have", "has", "had", "do", "does", "did", "but", "at", "by", "with", "from", "here", "when", "where", "how", \
"all", "any", "both", "each", "few", "more", "some", "such", "no", "nor", "too", "very", "can", "will", "just"]
# LEARNER CODE START HERE
words = file_contents.split(" ")
words_list = []
for word in words:
for uninteresting_word in uninteresting_words:
if word is not uninteresting_word:
words_list.append(word)
for word in words_list:
if not word.isalpha():
word = ''.join([letter for letter in word if word.isalpha()])
words_dict = {}
for word in words_list:
if word not in words_dict.keys():
words_dict[word] = words_list.count(word)
#wordcloud
cloud = wordcloud.WordCloud()
cloud.generate_from_frequencies()
return cloud.to_array()