Spaces:
Paused
Paused
Commit
•
f36b4bf
1
Parent(s):
d5b4eea
Upload app.py
Browse files
app.py
CHANGED
@@ -157,26 +157,29 @@ def chatbot_mechanism(message, history, additional_input_1):
|
|
157 |
extra_information_for_special_cases = ""
|
158 |
extra_information_for_special_cases_flag = False
|
159 |
unclear_cases = [
|
160 |
-
# Case 0: -> YEAR
|
161 |
-
[
|
|
|
|
|
|
|
162 |
# Case 1: -> MONTH, YEAR
|
163 |
["tháng này", "tháng hiện tại", "tháng nay", "tháng bây giờ", "tháng đang diễn ra", "tháng hiện nay", "tháng hiện giờ"],
|
164 |
-
# Case 2: ->
|
165 |
-
["
|
166 |
|
167 |
-
# Case 3: -> YEAR
|
168 |
-
["
|
169 |
# Case 4: -> MONTH, YEAR
|
170 |
["tháng trước", "tháng qua", "tháng vừa rồi", "tháng đã qua"],
|
171 |
-
# Case 5: ->
|
172 |
-
["
|
173 |
|
174 |
-
# Case 6: -> YEAR
|
175 |
-
["
|
176 |
# Case 7: -> MONTH, YEAR
|
177 |
["tháng sau", "tháng tới", "tháng tiếp theo", "tháng kế tiếp", "tháng sắp tới"],
|
178 |
-
# Case 8: ->
|
179 |
-
["
|
180 |
]
|
181 |
for i in range(len(unclear_cases)):
|
182 |
for u in range(len(unclear_cases[i])):
|
@@ -190,28 +193,28 @@ def chatbot_mechanism(message, history, additional_input_1):
|
|
190 |
if i in [0, 1, 2]:
|
191 |
target_time = current_time # No change
|
192 |
elif i == 3:
|
193 |
-
target_time = current_time - timedelta(days =
|
194 |
elif i == 4:
|
195 |
target_time = current_time - timedelta(days = 30)
|
196 |
elif i == 5:
|
197 |
-
target_time = current_time - timedelta(days =
|
198 |
elif i == 6:
|
199 |
-
target_time = current_time + timedelta(days =
|
200 |
elif i == 7:
|
201 |
target_time = current_time + timedelta(days = 30)
|
202 |
elif i == 8:
|
203 |
-
target_time = current_time + timedelta(days =
|
204 |
# Extract time to day, month, year
|
205 |
day = str(target_time.strftime('%d').lstrip(''))
|
206 |
month = str(target_time.strftime('%m').lstrip(''))
|
207 |
year = str(target_time.strftime('%Y').lstrip(''))
|
208 |
# Handle specific cases
|
209 |
if i in [0, 3, 6]:
|
210 |
-
extra_information_for_special_cases = f"
|
211 |
elif i in [1, 4, 7]:
|
212 |
extra_information_for_special_cases = f"Tháng {month} năm {year}"
|
213 |
elif i in [2, 5, 8]:
|
214 |
-
extra_information_for_special_cases = f"
|
215 |
if extra_information_for_special_cases_flag == True:
|
216 |
question = extra_information_for_special_cases + " " + question
|
217 |
|
|
|
157 |
extra_information_for_special_cases = ""
|
158 |
extra_information_for_special_cases_flag = False
|
159 |
unclear_cases = [
|
160 |
+
# Case 0: -> DAY, MONTH, YEAR
|
161 |
+
[
|
162 |
+
"ngày này" , "ngày hiện tại", "ngày hôm nay", "hôm nay", "hôm này", "ngày nay", "ngày hiện nay",
|
163 |
+
"bây giờ", "hiện giờ", "hiện nay", "hiện tại", "thời điểm này", "thời gian này", "lúc này", "khi này",
|
164 |
+
],
|
165 |
# Case 1: -> MONTH, YEAR
|
166 |
["tháng này", "tháng hiện tại", "tháng nay", "tháng bây giờ", "tháng đang diễn ra", "tháng hiện nay", "tháng hiện giờ"],
|
167 |
+
# Case 2: -> YEAR
|
168 |
+
["năm này", "năm hiện tại", "năm nay", "năm hiện nay"],
|
169 |
|
170 |
+
# Case 3: -> DAY, MONTH, YEAR
|
171 |
+
["hôm qua", "hôm trước", "ngày qua", "ngày trước"],
|
172 |
# Case 4: -> MONTH, YEAR
|
173 |
["tháng trước", "tháng qua", "tháng vừa rồi", "tháng đã qua"],
|
174 |
+
# Case 5: -> YEAR
|
175 |
+
["năm trước", "năm ngoái", "năm qua", "năm vừa rồi", "năm đã qua"],
|
176 |
|
177 |
+
# Case 6: -> DAY, MONTH, YEAR
|
178 |
+
["ngày mai", "ngày sau", "ngày tới", "ngày tiếp theo", "ngày hôm sau", "ngày kế tiếp", "ngày sắp tới"],
|
179 |
# Case 7: -> MONTH, YEAR
|
180 |
["tháng sau", "tháng tới", "tháng tiếp theo", "tháng kế tiếp", "tháng sắp tới"],
|
181 |
+
# Case 8: -> YEAR
|
182 |
+
["năm sau", "năm tới", "năm tiếp theo", "năm kế tiếp", "năm sắp tới"],
|
183 |
]
|
184 |
for i in range(len(unclear_cases)):
|
185 |
for u in range(len(unclear_cases[i])):
|
|
|
193 |
if i in [0, 1, 2]:
|
194 |
target_time = current_time # No change
|
195 |
elif i == 3:
|
196 |
+
target_time = current_time - timedelta(days = 1)
|
197 |
elif i == 4:
|
198 |
target_time = current_time - timedelta(days = 30)
|
199 |
elif i == 5:
|
200 |
+
target_time = current_time - timedelta(days = 365)
|
201 |
elif i == 6:
|
202 |
+
target_time = current_time + timedelta(days = 1)
|
203 |
elif i == 7:
|
204 |
target_time = current_time + timedelta(days = 30)
|
205 |
elif i == 8:
|
206 |
+
target_time = current_time + timedelta(days = 365)
|
207 |
# Extract time to day, month, year
|
208 |
day = str(target_time.strftime('%d').lstrip(''))
|
209 |
month = str(target_time.strftime('%m').lstrip(''))
|
210 |
year = str(target_time.strftime('%Y').lstrip(''))
|
211 |
# Handle specific cases
|
212 |
if i in [0, 3, 6]:
|
213 |
+
extra_information_for_special_cases = f"Ngày {day} tháng {month} năm {year}"
|
214 |
elif i in [1, 4, 7]:
|
215 |
extra_information_for_special_cases = f"Tháng {month} năm {year}"
|
216 |
elif i in [2, 5, 8]:
|
217 |
+
extra_information_for_special_cases = f"Năm {year}"
|
218 |
if extra_information_for_special_cases_flag == True:
|
219 |
question = extra_information_for_special_cases + " " + question
|
220 |
|