Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -109,8 +109,12 @@ Rules (priority order, MUST follow strictly):
|
|
| 109 |
5. Otherwise:
|
| 110 |
- Respond "positive" if the review is praising.
|
| 111 |
- Respond "neutral" if it is neither.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 112 |
|
| 113 |
-
|
| 114 |
Do NOT explain. Do NOT add anything else.
|
| 115 |
|
| 116 |
Review: {review_text}
|
|
@@ -207,9 +211,12 @@ def validate_review(description, rating, image_paths=None):
|
|
| 207 |
(data['rating'].astype(str).str.contains('4|5'))
|
| 208 |
)
|
| 209 |
conditions_accepted_positive_any_rating = data['LLM'].str.contains('positive', case=False)
|
| 210 |
-
conditions_accepted_neutral_high = (data['LLM'].str.contains('neutral', case=False)) & (data['rating'].astype(str).str.contains('1|2|3|4|5'))
|
| 211 |
description_null = data['description'].astype(str).str.strip().str.lower() == "null"
|
| 212 |
conditions_accepted_null = description_null & data['rating'].astype(str).str.contains('3|4|5')
|
|
|
|
|
|
|
|
|
|
|
|
|
| 213 |
|
| 214 |
# --- REJECT CONDITIONS ---
|
| 215 |
conditions_rejected_1 = (data['rating'].astype(str).str.contains('1|2')) & (data['description'].astype(str).str.len() == 0)
|
|
@@ -218,16 +225,17 @@ def validate_review(description, rating, image_paths=None):
|
|
| 218 |
(data['LLM'].str.contains('positive|negative|neutral', case=False))
|
| 219 |
conditions_rejected_3 = (data['LLM'].str.contains('negative', case=False)) & \
|
| 220 |
(data['description'].astype(str).str.contains('|'.join(Negative_Strings), case=False))
|
| 221 |
-
conditions_rejected_4 = (data['LLM'].str.contains('neutral', case=False)) & (data['rating'].astype(str).str.contains('
|
| 222 |
conditions_rejected_5 = (data['LLM'].str.contains('negative', case=False)) & ~(data['description'].astype(str).str.contains('|'.join(Negative_Strings), case=False))
|
| 223 |
conditions_rejected_null = description_null & data['rating'].astype(str).str.contains('1|2')
|
|
|
|
| 224 |
|
| 225 |
# Final flags
|
| 226 |
conditions_accepted = conditions_accepted_1 | conditions_accepted_2 | conditions_accepted_3 | \
|
| 227 |
-
conditions_accepted_4 |
|
| 228 |
-
conditions_accepted_positive_any_rating | conditions_accepted_null
|
| 229 |
conditions_rejected = conditions_rejected_1 | conditions_rejected_2 | conditions_rejected_3 | \
|
| 230 |
-
conditions_rejected_4 | conditions_rejected_5 | conditions_rejected_null
|
| 231 |
conditions_ignored = ((~(conditions_rejected | conditions_accepted)) |
|
| 232 |
(data['description'].astype(str).str.contains('|'.join(ignore_keywords), case=False)))
|
| 233 |
|
|
|
|
| 109 |
5. Otherwise:
|
| 110 |
- Respond "positive" if the review is praising.
|
| 111 |
- Respond "neutral" if it is neither.
|
| 112 |
+
|
| 113 |
+
6. If the review mentions fraud, repacked, fake, reputation damage,
|
| 114 |
+
or loss of trust related to the company or seller,
|
| 115 |
+
ALWAYS respond "negative" even if product praise exists.
|
| 116 |
|
| 117 |
+
7. Respond with only one word.
|
| 118 |
Do NOT explain. Do NOT add anything else.
|
| 119 |
|
| 120 |
Review: {review_text}
|
|
|
|
| 211 |
(data['rating'].astype(str).str.contains('4|5'))
|
| 212 |
)
|
| 213 |
conditions_accepted_positive_any_rating = data['LLM'].str.contains('positive', case=False)
|
|
|
|
| 214 |
description_null = data['description'].astype(str).str.strip().str.lower() == "null"
|
| 215 |
conditions_accepted_null = description_null & data['rating'].astype(str).str.contains('3|4|5')
|
| 216 |
+
conditions_accepted_neutral_with_positive_keywords = (
|
| 217 |
+
data['LLM'].str.contains('neutral', case=False) &
|
| 218 |
+
data['description'].str.contains('|'.join(Positive_Strings), case=False)
|
| 219 |
+
)
|
| 220 |
|
| 221 |
# --- REJECT CONDITIONS ---
|
| 222 |
conditions_rejected_1 = (data['rating'].astype(str).str.contains('1|2')) & (data['description'].astype(str).str.len() == 0)
|
|
|
|
| 225 |
(data['LLM'].str.contains('positive|negative|neutral', case=False))
|
| 226 |
conditions_rejected_3 = (data['LLM'].str.contains('negative', case=False)) & \
|
| 227 |
(data['description'].astype(str).str.contains('|'.join(Negative_Strings), case=False))
|
| 228 |
+
conditions_rejected_4 = ( (data['LLM'].str.contains('neutral', case=False)) & (data['rating'].astype(str).str.contains('1|2')) & ~(data['description'].str.contains('|'.join(Positive_Strings), case=False)) )
|
| 229 |
conditions_rejected_5 = (data['LLM'].str.contains('negative', case=False)) & ~(data['description'].astype(str).str.contains('|'.join(Negative_Strings), case=False))
|
| 230 |
conditions_rejected_null = description_null & data['rating'].astype(str).str.contains('1|2')
|
| 231 |
+
conditions_rejected_neutral_negative_words = (data['LLM'].str.contains('neutral')) & (data['description'].str.contains('|'.join(Negative_Strings), case=False))
|
| 232 |
|
| 233 |
# Final flags
|
| 234 |
conditions_accepted = conditions_accepted_1 | conditions_accepted_2 | conditions_accepted_3 | \
|
| 235 |
+
conditions_accepted_4 | \
|
| 236 |
+
conditions_accepted_positive_any_rating | conditions_accepted_null |conditions_accepted_neutral_with_positive_keywords
|
| 237 |
conditions_rejected = conditions_rejected_1 | conditions_rejected_2 | conditions_rejected_3 | \
|
| 238 |
+
conditions_rejected_4 | conditions_rejected_5 | conditions_rejected_null |conditions_rejected_neutral_negative_words
|
| 239 |
conditions_ignored = ((~(conditions_rejected | conditions_accepted)) |
|
| 240 |
(data['description'].astype(str).str.contains('|'.join(ignore_keywords), case=False)))
|
| 241 |
|