Update intents.py
Browse files- intents.py +17 -0
intents.py
CHANGED
|
@@ -47,3 +47,20 @@ def detect_intent(text: str) -> str:
|
|
| 47 |
if any(re.search(p, t, flags=re.I) for p in patterns):
|
| 48 |
return intent
|
| 49 |
return "general"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
if any(re.search(p, t, flags=re.I) for p in patterns):
|
| 48 |
return intent
|
| 49 |
return "general"
|
| 50 |
+
def is_table_query(text: str) -> bool:
|
| 51 |
+
"""
|
| 52 |
+
Xác định xem câu hỏi có liên quan đến bảng (table) hay không.
|
| 53 |
+
:param text: Chuỗi văn bản cần kiểm tra
|
| 54 |
+
:return: True nếu liên quan đến bảng, False nếu không
|
| 55 |
+
"""
|
| 56 |
+
if not text:
|
| 57 |
+
return False
|
| 58 |
+
|
| 59 |
+
# Danh sách từ khóa liên quan đến bảng
|
| 60 |
+
table_keywords = [
|
| 61 |
+
"bảng", "table", "sheet", "danh sách", "excel",
|
| 62 |
+
"dữ liệu", "thống kê", "grid", "dataframe"
|
| 63 |
+
]
|
| 64 |
+
|
| 65 |
+
text_lower = text.lower()
|
| 66 |
+
return any(keyword in text_lower for keyword in table_keywords)
|