Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
| 97 |
-
|
|
|
|
|
|
|
| 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 =
|
| 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
|
| 145 |
-
|
| 146 |
-
wordcloud =
|
| 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)
|