Created
October 10, 2023 00:16
-
-
Save Hehehe421/034cff865bd408f22561c4c4b5b321d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Loop through each source and generate word clouds | |
for source, headlines in trending_news.items(): | |
# Combine the headlines into a single string | |
headlines_text = ' '.join(headlines) | |
# Generate the word cloud | |
wordcloud = WordCloud(width=800, height=400, background_color='white').generate(headlines_text) | |
# Display the word cloud with the source name as the title | |
plt.figure(figsize=(12, 6)) | |
plt.imshow(wordcloud, interpolation='bilinear') | |
plt.title(f'Trending News on {source}') | |
plt.axis("off") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment