hoangs commited on
Commit
c932161
·
verified ·
1 Parent(s): 962234f

Upload model.py

Browse files
Files changed (1) hide show
  1. model.py +35 -0
model.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Literal
2
+
3
+ Intent = Literal["clean_room", "go_dock", "play_music", "answer_question", "small_talk", "other"]
4
+
5
+ def route_intent(text: str) -> Intent:
6
+ """Very simple rule-based intent router for short commands.
7
+
8
+ Works best with lowercase, accent-stripped Vietnamese or English.
9
+ """
10
+ t = text.lower()
11
+
12
+ if any(k in t for k in ["hút bụi", "vacuum", "clean room", "quét nhà"]):
13
+ return "clean_room"
14
+ if any(k in t for k in ["về sạc", "go charge", "go dock", "về dock"]):
15
+ return "go_dock"
16
+ if any(k in t for k in ["bật nhạc", "play music", "phát nhạc"]):
17
+ return "play_music"
18
+ if any(k in t for k in ["thời tiết", "mấy giờ", "how is the weather", "question"]):
19
+ return "answer_question"
20
+ if any(k in t for k in ["kể chuyện cười", "joke", "chúc ngủ ngon", "good night", "hello", "xin chào"]):
21
+ return "small_talk"
22
+ return "other"
23
+
24
+
25
+ if __name__ == "__main__":
26
+ tests = [
27
+ "Robot ơi hút bụi phòng khách đi",
28
+ "Đi về sạc đi",
29
+ "Bật nhạc nhẹ giúp tôi với",
30
+ "Hôm nay thời tiết thế nào",
31
+ "Kể chuyện cười đi",
32
+ "Ờ... thôi để sau",
33
+ ]
34
+ for txt in tests:
35
+ print(txt, "->", route_intent(txt))