Spaces:
Sleeping

SoniaD commited on
Commit
77f45ac
Β·
verified Β·
1 Parent(s): e4e14d1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
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"]).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,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