[ Foro de Python ]
Este es el código:
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
nueva_list = []
nuevo_dictionary = {}
for word in original_words:
if word not in nuevo_dictionary:
nuevo_dictionary[word] = 1
elif word in nuevo_dictionary:
nuevo_dictionary[word] += 1
for words in uninteresting_words:
if words in nuevo_dictionary:
del nuevo_dictionary[words]
#wordcloud
cloud = wordcloud.WordCloud()
cloud.generate_from_frequencies(nuevo_dictionary)
return cloud.to_array()
myimage = calculate_frequencies(file_contents)
plt.imshow(myimage, interpolation = 'nearest')
plt.axis('off')
plt.show()
Si alguien me puede ayudar, se lo agradecería.
(No se puede continuar esta discusión porque tiene más de dos meses de antigüedad. Si tienes dudas parecidas, abre un nuevo hilo.)