pvaluedotone commited on
Commit
fd0f5ba
·
verified ·
1 Parent(s): 5d5fca8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -34,6 +34,26 @@ def get_sentiment_label(polarity, pos_thresh, neg_thresh):
34
  else:
35
  return "Neutral"
36
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  # Main processing function
38
  def analyze_sentiment(file, text_column, pos_thresh, neg_thresh):
39
  try:
 
34
  else:
35
  return "Neutral"
36
 
37
+ # Generate word cloud
38
+ def generate_wordcloud(text_series, title):
39
+ text = " ".join(text_series.dropna())
40
+ if not text.strip():
41
+ fig = plt.figure(figsize=(6, 4))
42
+ plt.text(0.5, 0.5, f"No data for {title}", fontsize=14, ha='center', va='center')
43
+ plt.axis("off")
44
+ plt.title(title)
45
+ plt.tight_layout()
46
+ return fig
47
+
48
+ wc = WordCloud(width=600, height=400, background_color="white", colormap="tab10").generate(text)
49
+ fig = plt.figure(figsize=(6, 4))
50
+ plt.imshow(wc, interpolation="bilinear")
51
+ plt.axis("off")
52
+ plt.title(title)
53
+ plt.tight_layout()
54
+ return fig
55
+
56
+
57
  # Main processing function
58
  def analyze_sentiment(file, text_column, pos_thresh, neg_thresh):
59
  try: