Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -75,8 +75,22 @@ def cluster_data(df, num_clusters):
|
|
| 75 |
def generate_wordcloud(df):
|
| 76 |
text = " ".join(df['texts'].tolist())
|
| 77 |
stopwords = set(STOPWORDS)
|
| 78 |
-
wordcloud = WordCloud(
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
plt.imshow(wordcloud, interpolation='bilinear')
|
| 81 |
plt.axis('off')
|
| 82 |
buf = BytesIO()
|
|
|
|
| 75 |
def generate_wordcloud(df):
|
| 76 |
text = " ".join(df['texts'].tolist())
|
| 77 |
stopwords = set(STOPWORDS)
|
| 78 |
+
wordcloud = WordCloud(
|
| 79 |
+
width=800,
|
| 80 |
+
height=400,
|
| 81 |
+
background_color='white',
|
| 82 |
+
max_words=300,
|
| 83 |
+
collocations=False,
|
| 84 |
+
min_font_size=5,
|
| 85 |
+
max_font_size=100,
|
| 86 |
+
stopwords=stopwords,
|
| 87 |
+
prefer_horizontal=1.0
|
| 88 |
+
).generate(text)
|
| 89 |
+
|
| 90 |
+
# Fill the empty spaces better
|
| 91 |
+
wordcloud.recolor(color_func=lambda *args, **kwargs: "black")
|
| 92 |
+
|
| 93 |
+
plt.figure(figsize=(10, 5))
|
| 94 |
plt.imshow(wordcloud, interpolation='bilinear')
|
| 95 |
plt.axis('off')
|
| 96 |
buf = BytesIO()
|