davidtran999 commited on
Commit
ac8260e
·
verified ·
1 Parent(s): 2f7b068

Upload backend/hue_portal/chatbot/tests/test_intent_keywords.py with huggingface_hub

Browse files
backend/hue_portal/chatbot/tests/test_intent_keywords.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import unittest
2
+
3
+ from hue_portal.chatbot.chatbot import Chatbot
4
+
5
+
6
+ class IntentKeywordTests(unittest.TestCase):
7
+ @classmethod
8
+ def setUpClass(cls):
9
+ cls.bot = Chatbot()
10
+
11
+ def test_office_keywords_have_priority(self):
12
+ intent, confidence = self.bot.classify_intent("Cho mình địa chỉ Công an phường An Cựu", context=None)
13
+ self.assertEqual(intent, "search_office")
14
+ self.assertGreaterEqual(confidence, 0.7)
15
+
16
+ def test_document_code_forces_search_legal(self):
17
+ intent, confidence = self.bot.classify_intent("Quyết định 69 quy định gì về kỷ luật?", context=None)
18
+ self.assertEqual(intent, "search_legal")
19
+ self.assertGreaterEqual(confidence, 0.8)
20
+
21
+ def test_fine_keywords_override_greeting(self):
22
+ intent, confidence = self.bot.classify_intent("Chào bạn mức phạt vượt đèn đỏ là bao nhiêu", context=None)
23
+ self.assertEqual(intent, "search_fine")
24
+ self.assertGreaterEqual(confidence, 0.8)
25
+
26
+
27
+ if __name__ == "__main__":
28
+ unittest.main()
29
+