I'm trying to create a word cloud based on a string and then importing it into a report document. I am using python-docx, matplotlib, and word cloud. This is a brief summary of my
from wordcloud import WordCloud
import matplotlib.pyplot as plt
from docx import Document
from docx.shared import Inches
document = Document()
document.add_heading("Auto Generated Report")
text = "kd sa gf sdf gd python auomation get set python dfs aslkdf asdfij fdifh fdosfj dsfoj "
cloud = WordCloud().generate(text)
plt.title('Summarization of responses on possible improvements of CS course.')
plt.savefig('N.png')
document.add_picture('N.png', width=Inches(5))
document.save("Report")
However, instead of displaying a word cloud, the report just shows a blank graph.
The three steps are: Extract the review (text document) Create and generate a wordcloud image. Display the cloud using matplotlib.
To export your word cloud, right click or command + click the word cloud and select Export.
Word Cloud is a data visualization technique used for representing text data in which the size of each word indicates its frequency or importance. Significant textual data points can be highlighted using a word cloud. Word clouds are widely used for analyzing data from social network websites.
Supplemental to @Andy's answer, cloud.to_file('N.png')
is how you save the word cloud image into your local disk so that you can import later. You can find a good reference here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With