hoangs commited on
Commit
ddd5c13
·
verified ·
1 Parent(s): 99560ba

Upload model.py

Browse files
Files changed (1) hide show
  1. model.py +39 -0
model.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Literal
2
+
3
+ Priority = Literal["low", "normal", "high", "urgent"]
4
+
5
+ URGENT_WORDS = ["ngay lập tức", "ngay bây giờ", "lập tức", "khẩn cấp"]
6
+ HIGH_WORDS = ["càng sớm càng tốt", "sớm nhất", "ưu tiên", "rất quan trọng"]
7
+ LOW_WORDS = ["khi rảnh", "lúc rảnh", "khi nào tiện", "không gấp"]
8
+
9
+ def estimate_priority(command: str) -> Priority:
10
+ """Estimate the priority of a Vietnamese task/command."""
11
+ t = command.lower()
12
+
13
+ for w in URGENT_WORDS:
14
+ if w in t:
15
+ return "urgent"
16
+
17
+ for w in HIGH_WORDS:
18
+ if w in t:
19
+ return "high"
20
+
21
+ for w in LOW_WORDS:
22
+ if w in t:
23
+ return "low"
24
+
25
+ # heuristic: if has words like 'ngay', 'bây giờ'
26
+ if "ngay" in t or "bây giờ" in t:
27
+ return "high"
28
+
29
+ return "normal"
30
+
31
+ if __name__ == "__main__":
32
+ tests = [
33
+ "Hút bụi phòng khách khi rảnh",
34
+ "Nhắc tôi thanh toán tiền điện càng sớm càng tốt",
35
+ "Dọn nhà bếp ngay lập tức",
36
+ "Kiểm tra cửa sổ tối nay",
37
+ ]
38
+ for t in tests:
39
+ print(t, "->", estimate_priority(t))