baobuiquang commited on
Commit
6dcf36b
1 Parent(s): c0fa8f1

Upload 2 files

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -12,6 +12,7 @@ import pandas as pd
12
  import numpy as np
13
  import torch
14
  import time
 
15
  from transformers import AutoTokenizer, AutoModel
16
  from datetime import datetime, timedelta
17
  from dateparser.search import search_dates
@@ -236,7 +237,8 @@ def chatbot_mechanism(message, history, additional_input_1):
236
  y_text = str(df.columns[y_index])
237
 
238
  # Not related but extract datetime in the question if any
239
- extracted_date = search_dates(question)[0][1].strftime('%d/%m/%Y')
 
240
 
241
  # Small adjustment for better print
242
  if y_text.count('/') == 4:
@@ -260,8 +262,8 @@ def chatbot_mechanism(message, history, additional_input_1):
260
 
261
 
262
  # Score display
263
- x_score_display = str(round((x_score - 0.8) / (1.0 - 0.8) * 100, 1))
264
- y_score_display = str(round((y_score - 0.8) / (1.0 - 0.8) * 100, 1))
265
 
266
  # Cell value
267
  cell_value = df.iloc[x_index, y_index]
@@ -270,26 +272,26 @@ def chatbot_mechanism(message, history, additional_input_1):
270
  final_output_message = f"\
271
  <div style='{eval_text_2}'>\
272
  <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
273
- Đặc trưng trích xuất được (vector trong dữ liệu):\
274
  </div>\
275
  • {x_text}<br>\
276
  • {y_text if extra_information_for_special_cases_flag == False else extra_information_for_special_cases}<br>\
277
  <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
278
  Đặc trưng trích xuất được (nội suy):\
279
  </div>\
280
- • {extracted_date}<br>\
281
  <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
282
  Đánh giá:\
283
  </div>\
284
  Độ tương quan: [x={x_score_display}%, y={y_score_display}%]<br>\
285
  </div>\
 
 
 
 
 
 
286
  "
287
- # <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
288
- # {eval_text_sub_title}\
289
- # </div>\
290
- # <div style='color: {eval_text_color}; font-weight: bold;'>\
291
- # {eval_text_1}\
292
- # </div>\
293
  # <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
294
  # Kết quả:\
295
  # </div>\
 
12
  import numpy as np
13
  import torch
14
  import time
15
+ import re
16
  from transformers import AutoTokenizer, AutoModel
17
  from datetime import datetime, timedelta
18
  from dateparser.search import search_dates
 
237
  y_text = str(df.columns[y_index])
238
 
239
  # Not related but extract datetime in the question if any
240
+ extracted_date = search_dates(message)[0][1].strftime('%d/%m/%Y')
241
+ print_extracted_date = bool(re.search(r'\d', message))
242
 
243
  # Small adjustment for better print
244
  if y_text.count('/') == 4:
 
262
 
263
 
264
  # Score display
265
+ x_score_display = str(round((x_score - 0.85) / (1.0 - 0.85) * 100, 1))
266
+ y_score_display = str(round((y_score - 0.85) / (1.0 - 0.85) * 100, 1))
267
 
268
  # Cell value
269
  cell_value = df.iloc[x_index, y_index]
 
272
  final_output_message = f"\
273
  <div style='{eval_text_2}'>\
274
  <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
275
+ Đặc trưng trích xuất được (embedding):\
276
  </div>\
277
  • {x_text}<br>\
278
  • {y_text if extra_information_for_special_cases_flag == False else extra_information_for_special_cases}<br>\
279
  <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
280
  Đặc trưng trích xuất được (nội suy):\
281
  </div>\
282
+ • {extracted_date if print_extracted_date == True else ''}<br>\
283
  <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
284
  Đánh giá:\
285
  </div>\
286
  Độ tương quan: [x={x_score_display}%, y={y_score_display}%]<br>\
287
  </div>\
288
+ <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
289
+ {eval_text_sub_title}\
290
+ </div>\
291
+ <div style='color: {eval_text_color}; font-weight: bold;'>\
292
+ {eval_text_1}\
293
+ </div>\
294
  "
 
 
 
 
 
 
295
  # <div style='color: gray; font-size: 80%; font-family: courier, monospace; margin-top: 6px;'>\
296
  # Kết quả:\
297
  # </div>\