How to create a word cloud from a corpus in Python?

from wordcloud import WordCloud, STOPWORDS import matplotlib.pyplot as plt stopwords = set(STOPWORDS) def show_wordcloud(data, title = None): wordcloud = WordCloud( background_color=”white”, stopwords=stopwords, max_words=200, max_font_size=40, scale=3, random_state=1 # chosen at random by flipping a coin; it was heads ).generate(str(data)) fig = plt.figure(1, figsize=(12, 12)) plt.axis(‘off’) if title: fig.suptitle(title, fontsize=20) fig.subplots_adjust(top=2.3) plt.imshow(wordcloud) plt.show() show_wordcloud(Samsung_Reviews_Negative[‘Reviews’]) show_wordcloud(Samsung_Reviews_positive[‘Reviews’])

Increase resolution with word-cloud and remove empty border

You can’t increase the resolution of the image in plt.show() since that is determined by your screen, but you can increase the size. This allows it to scale, zoom, etc. without blurring. To do this pass dimensions to WordCloud, e.g. wordcloud = WordCloud(width=800, height=400).generate(text) However, this just determines the size of the image created by … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)