Ashendilantha commited on
Commit
6cef51d
·
verified ·
1 Parent(s): e78f98f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -8
app.py CHANGED
@@ -92,9 +92,11 @@ def chatbot_response(history, user_input, text_input=None, file_input=None):
92
 
93
  return history, answer
94
 
95
- # Function to generate word cloud
96
- def generate_word_cloud(text):
97
- wordcloud = WordCloud(width=800, height=400, background_color="white").generate(text)
 
 
98
  return wordcloud
99
 
100
  # Function to generate bar graph for decoded predictions
@@ -122,7 +124,7 @@ if st.button("🔍 Classify"):
122
  st.write(f"Confidence Level: {confidence}")
123
 
124
  # Generate word cloud for the cleaned text input
125
- wordcloud = generate_word_cloud(text_input)
126
  st.image(wordcloud.to_array(), caption="Word Cloud for Text Input", use_container_width=True)
127
  else:
128
  st.warning("Please enter some text to classify.")
@@ -141,10 +143,9 @@ if file_input:
141
  mime="text/csv"
142
  )
143
 
144
- # Generate word cloud for the cleaned CSV data
145
- bulk_text = " ".join(df["Decoded Prediction"].dropna().astype(str).tolist())
146
- wordcloud = generate_word_cloud(bulk_text)
147
- st.image(wordcloud.to_array(), caption="Word Cloud for CSV Data", use_container_width=True)
148
 
149
  # Generate bar graph for decoded predictions frequency
150
  generate_bar_graph(df)
 
92
 
93
  return history, answer
94
 
95
+ # Function to generate word cloud from the 'content' column (from output CSV)
96
+ def generate_word_cloud_from_output(df):
97
+ # Assuming 'content' column is the first column after processing
98
+ content_text = " ".join(df["content"].dropna().astype(str).tolist())
99
+ wordcloud = WordCloud(width=800, height=400, background_color="white").generate(content_text)
100
  return wordcloud
101
 
102
  # Function to generate bar graph for decoded predictions
 
124
  st.write(f"Confidence Level: {confidence}")
125
 
126
  # Generate word cloud for the cleaned text input
127
+ wordcloud = generate_word_cloud_from_output(pd.DataFrame({"content": [text_input]})) # Create a DataFrame for single input
128
  st.image(wordcloud.to_array(), caption="Word Cloud for Text Input", use_container_width=True)
129
  else:
130
  st.warning("Please enter some text to classify.")
 
143
  mime="text/csv"
144
  )
145
 
146
+ # Generate word cloud for the 'content' column of the processed CSV data
147
+ wordcloud = generate_word_cloud_from_output(df)
148
+ st.image(wordcloud.to_array(), caption="Word Cloud for CSV Content", use_container_width=True)
 
149
 
150
  # Generate bar graph for decoded predictions frequency
151
  generate_bar_graph(df)