Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -45,20 +45,14 @@ def analyze_reviews(uploaded_file):
|
|
| 45 |
return
|
| 46 |
|
| 47 |
# Use the summarization model to extract core problem themes
|
| 48 |
-
summaries = []
|
| 49 |
topic_summary_pairs = []
|
| 50 |
complaint_texts = complaints["text_clean"].tolist()
|
|
|
|
| 51 |
for complaint in complaint_texts:
|
| 52 |
try:
|
| 53 |
-
|
| 54 |
-
if len(tokenizer(complaint)["input_ids"]) < 15:
|
| 55 |
-
summary_piece = complaint # skip summary
|
| 56 |
-
else:
|
| 57 |
-
summary_piece = problem_extractor(complaint, max_length=40, min_length=15, do_sample=False)[0]["summary_text"]
|
| 58 |
-
# Classify the summary into predefined topics
|
| 59 |
-
topic_result = zero_classifier(summary_piece, ["Driver Issue", "App Issue", "Payment Issue", "Customer Support", "Wait Time"])
|
| 60 |
top_topic = topic_result["labels"][0]
|
| 61 |
-
topic_summary_pairs.append((top_topic,
|
| 62 |
except Exception as e:
|
| 63 |
st.warning(f"❗ Error processing complaint: {e}")
|
| 64 |
continue
|
|
|
|
| 45 |
return
|
| 46 |
|
| 47 |
# Use the summarization model to extract core problem themes
|
|
|
|
| 48 |
topic_summary_pairs = []
|
| 49 |
complaint_texts = complaints["text_clean"].tolist()
|
| 50 |
+
candidate_labels = ["Driver Issue", "App Issue", "Payment Issue", "Customer Support", "Wait Time"]
|
| 51 |
for complaint in complaint_texts:
|
| 52 |
try:
|
| 53 |
+
topic_result = zero_classifier(complaint, candidate_labels)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
top_topic = topic_result["labels"][0]
|
| 55 |
+
topic_summary_pairs.append((top_topic, complaint)
|
| 56 |
except Exception as e:
|
| 57 |
st.warning(f"❗ Error processing complaint: {e}")
|
| 58 |
continue
|