Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
from transformers import pipeline
|
| 3 |
-
import gradio as gr
|
| 4 |
from collections import Counter
|
| 5 |
import re
|
| 6 |
|
|
@@ -27,7 +27,7 @@ if uploaded_file:
|
|
| 27 |
df = pd.read_excel(uploaded_file)
|
| 28 |
|
| 29 |
if 'text' not in df.columns:
|
| 30 |
-
st.error("β Error: Your file must contain a column named 'text'."
|
| 31 |
else:
|
| 32 |
# Create a column contains cleaned text
|
| 33 |
df["text_clean"] = df["text"].apply(clean_text)
|
|
@@ -46,7 +46,7 @@ if uploaded_file:
|
|
| 46 |
st.success("β
No complaints found in the uploaded file!")
|
| 47 |
else:
|
| 48 |
# Merge all complaint texts into one long string, and split into words
|
| 49 |
-
all_complaints = " ".join(complaints["text_clean"]
|
| 50 |
|
| 51 |
# Use the summarization model to extract core problem themes
|
| 52 |
summary = problem_extractor(all_complaints, max_length=60, min_length=20, do_sample=False)[0]["summary_text"]
|
|
@@ -55,7 +55,7 @@ if uploaded_file:
|
|
| 55 |
st.subheader("π§Ύ Complaint Summary")
|
| 56 |
st.markdown(f"π§Ύ Total Reviews: {len(df)}\n")
|
| 57 |
st.markdown(f"β Complaints Detected: {len(complaints)}\n\n")
|
| 58 |
-
st.markdown(f"π Key Customer Issue Summary (from complaints):{summary})
|
| 59 |
st.subheader("π Complaint Samples")
|
| 60 |
st.dataframe(complaints[["text"]].reset_index(drop=True))
|
| 61 |
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
from transformers import pipeline
|
|
|
|
| 4 |
from collections import Counter
|
| 5 |
import re
|
| 6 |
|
|
|
|
| 27 |
df = pd.read_excel(uploaded_file)
|
| 28 |
|
| 29 |
if 'text' not in df.columns:
|
| 30 |
+
st.error("β Error: Your file must contain a column named 'text'.")
|
| 31 |
else:
|
| 32 |
# Create a column contains cleaned text
|
| 33 |
df["text_clean"] = df["text"].apply(clean_text)
|
|
|
|
| 46 |
st.success("β
No complaints found in the uploaded file!")
|
| 47 |
else:
|
| 48 |
# Merge all complaint texts into one long string, and split into words
|
| 49 |
+
all_complaints = " ".join(complaints["text_clean"].tolist())
|
| 50 |
|
| 51 |
# Use the summarization model to extract core problem themes
|
| 52 |
summary = problem_extractor(all_complaints, max_length=60, min_length=20, do_sample=False)[0]["summary_text"]
|
|
|
|
| 55 |
st.subheader("π§Ύ Complaint Summary")
|
| 56 |
st.markdown(f"π§Ύ Total Reviews: {len(df)}\n")
|
| 57 |
st.markdown(f"β Complaints Detected: {len(complaints)}\n\n")
|
| 58 |
+
st.markdown(f"π Key Customer Issue Summary (from complaints): {summary}")
|
| 59 |
st.subheader("π Complaint Samples")
|
| 60 |
st.dataframe(complaints[["text"]].reset_index(drop=True))
|
| 61 |
|