sent2547 commited on
Commit
4f330db
·
verified ·
1 Parent(s): fcf292f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -7,12 +7,15 @@ nlp = pipeline("sentiment-analysis", model=model_name)
7
  label_map = {
8
  "LABEL_0": 0,
9
  "LABEL_1": 1,
10
- "LABEL_2": 2
 
11
  }
 
12
  label_name_map = {
13
  "LABEL_0": "negative",
14
  "LABEL_1": "neutral",
15
- "LABEL_2": "positive"
 
16
  }
17
 
18
  def analyze_text(text):
@@ -21,7 +24,8 @@ def analyze_text(text):
21
  score = result['score']
22
  code = label_map.get(label, -1)
23
  label_name = label_name_map.get(label, label)
24
- return f"ผลวิเคราะห์: {label_name} (รหัส: {code}) ความมั่นใจ {score:.2f}"
 
25
 
26
  demo = gr.Interface(
27
  fn=analyze_text,
 
7
  label_map = {
8
  "LABEL_0": 0,
9
  "LABEL_1": 1,
10
+ "LABEL_2": 2,
11
+ "LABEL_3": 3 # เพิ่ม label_3 ตามจริง
12
  }
13
+
14
  label_name_map = {
15
  "LABEL_0": "negative",
16
  "LABEL_1": "neutral",
17
+ "LABEL_2": "positive",
18
+ "LABEL_3": "mixed" # หรือคำอื่นที่ตรงกับความหมาย
19
  }
20
 
21
  def analyze_text(text):
 
24
  score = result['score']
25
  code = label_map.get(label, -1)
26
  label_name = label_name_map.get(label, label)
27
+ return f"ผลวิเคราะห์: {label_name} (รหัส: {code}) ความมั่นใจ {score:.3f}"
28
+
29
 
30
  demo = gr.Interface(
31
  fn=analyze_text,