Asad110786110 commited on
Commit
e604217
Β·
verified Β·
1 Parent(s): 243b17c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -6
app.py CHANGED
@@ -13,14 +13,15 @@ client = OpenAI(
13
 
14
  # ---------------- SENTIMENT FUNCTION ---------------- #
15
  def get_sentiment(review_text: str) -> str:
16
- prompt = f"""
17
  Classify sentiment of this review in English or Roman Urdu.
18
  Return EXACTLY one word: positive, negative, or neutral.
19
 
20
  Rules (priority order, MUST follow strictly):
21
 
22
  1. If the review contains any abusive, offensive, vulgar, or insulting words
23
- in English or Roman Urdu, ALWAYS respond with "negative".
 
24
  This overrides ALL other rules β€” even if the rest of the review is positive.
25
 
26
  2. If the review mentions problems with Priceoye's website, service, delivery,
@@ -28,15 +29,21 @@ Rules (priority order, MUST follow strictly):
28
  ALWAYS respond with "negative".
29
  This overrides everything else except abusive language.
30
 
31
- 3. If both positive and negative opinions are present but not directly about
 
 
 
 
 
 
 
32
  Priceoye's website, service, or delivery β†’ respond "neutral".
33
 
34
- 4. Otherwise:
35
  - Respond "positive" if the review is praising.
36
- - Respond "negative" if the review is complaining.
37
  - Respond "neutral" if it is neither.
38
 
39
- 5. Respond with only one word.
40
  Do NOT explain. Do NOT add anything else.
41
 
42
  Review: {review_text}
 
13
 
14
  # ---------------- SENTIMENT FUNCTION ---------------- #
15
  def get_sentiment(review_text: str) -> str:
16
+ prompt =f"""
17
  Classify sentiment of this review in English or Roman Urdu.
18
  Return EXACTLY one word: positive, negative, or neutral.
19
 
20
  Rules (priority order, MUST follow strictly):
21
 
22
  1. If the review contains any abusive, offensive, vulgar, or insulting words
23
+ in English or Roman Urdu (e.g., bad words, slang, or personal attacks),
24
+ ALWAYS respond with "negative".
25
  This overrides ALL other rules β€” even if the rest of the review is positive.
26
 
27
  2. If the review mentions problems with Priceoye's website, service, delivery,
 
29
  ALWAYS respond with "negative".
30
  This overrides everything else except abusive language.
31
 
32
+ 3. If the review only criticizes or complains about a product
33
+ (e.g., "yeh phone bekaar hai", "battery weak hai")
34
+ but does NOT contain abusive or insulting words,
35
+ DO NOT treat it as negative β€” respond based on the overall tone:
36
+ - If it seems disappointed but polite β†’ "neutral"
37
+ - If it praises other things β†’ "positive"
38
+
39
+ 4. If both positive and negative opinions are present but not directly about
40
  Priceoye's website, service, or delivery β†’ respond "neutral".
41
 
42
+ 5. Otherwise:
43
  - Respond "positive" if the review is praising.
 
44
  - Respond "neutral" if it is neither.
45
 
46
+ 6. Respond with only one word.
47
  Do NOT explain. Do NOT add anything else.
48
 
49
  Review: {review_text}