Hi. So i’ve recently been undertaking a course in python with google certificates. I’ve managed great so far but the final project is extremely hard. The software doesn’t show you the progress of the dictionary created so far so it’s quite difficult to understand where i’m going wrong. The outcome is to create a word cloud with the counted words in a dictionary.
Below is the current code i have.
The part that says learner code starts here is the only code written by me and there is other installs and uploads done previously to this with some done behind the scenes. Any help would be appreciated.
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
split_text = file_contents.split()
result_dict = {}
for word in split_text:
for char in word:
if char in punctuations:
char.replace(punctuations, "")
if word in uninteresting_words:
pass
else:
if word not in result_dict:
result_dict += word
result_dict[word] = 1
else:
result_dict[word] += 1
#wordcloud
cloud = wordcloud.WordCloud()
cloud.generate_from_frequencies(result_dict)
return cloud.to_array()
myimage = calculate_frequencies(result_dict)
plt.imshow(myimage, interpolation = 'nearest')
plt.axis('off')
plt.show()