Added support for "what day are we"

This commit is contained in:
Mathieu B 2021-07-26 22:07:51 +02:00
parent cae27505fc
commit db13666d57
5 changed files with 43 additions and 9 deletions

View File

@ -2,6 +2,7 @@ import os
import torch import torch
from unidecode import unidecode from unidecode import unidecode
import get_path_file import get_path_file
from ia.model import NeuralNet from ia.model import NeuralNet
from ia.nltk_utils import bag_of_words, tokenize from ia.nltk_utils import bag_of_words, tokenize
@ -56,4 +57,4 @@ def get_tag_for_sentence(input_sentence):
if prob.item() > 0.75 and len(sentence) > 2: if prob.item() > 0.75 and len(sentence) > 2:
return tag return tag
else: else:
return 'dont_understand' return 'dont_understand'

Binary file not shown.

View File

@ -1,12 +1,14 @@
import time import time
from datetime import datetime
import utils.intents_utils from utils import config_utils, intents_utils
from utils import config_utils
def what_time_is_it(): def what_time_is_it():
tag = 'what_time_is_it'
response = intents_utils.get_response(tag)
current_time = time.localtime() current_time = time.localtime()
response = utils.intents_utils.get_response("what_time_is_it")
if config_utils.get_in_config("12HOURS-FORMAT"): if config_utils.get_in_config("12HOURS-FORMAT"):
response = response.replace('{time}', time.strftime("%I:%M %p", current_time)) response = response.replace('{time}', time.strftime("%I:%M %p", current_time))
@ -17,4 +19,12 @@ def what_time_is_it():
def what_day_is_it(): def what_day_is_it():
return "" tag = 'what_day_is_it'
response = intents_utils.get_response(tag)
day_number = datetime.today().weekday()
lang_json = intents_utils.get_lang_for_intent('what_day_is_it')['others']['days_of_week']
response = response.replace('{day}', lang_json[str(day_number)])
return response

View File

@ -19,9 +19,20 @@
"Tell me the day of the week. ", "Tell me the day of the week. ",
"What day are we" "What day are we"
], ],
"response": [ "responses": [
"{day}", "{day}",
"Today is {day}" "Today is {day}"
] ]
},
"others": {
"days_of_week": {
"0": "Monday",
"1": "Tuesday",
"2": "Wednesday",
"3": "Thursday",
"4:": "Friday",
"5": "Saturday",
"6": "Sunday"
}
} }
} }

View File

@ -17,10 +17,22 @@
"Quel jour est-on", "Quel jour est-on",
"C'est quel jour aujourd'hui" "C'est quel jour aujourd'hui"
], ],
"response": [ "responses": [
"Nous somme le {day}", "Nous somme {day}",
"Aujourd'hui nous sommes {day}", "Aujourd'hui nous sommes {day}",
"On est {day}" "On est {day}",
"{day}"
] ]
},
"others": {
"days_of_week": {
"0": "Lundi",
"1": "Mardi",
"2": "Mercredi",
"3": "Jeudi",
"4:": "Vendredi",
"5": "Samedi",
"6": "Dimanche"
}
} }
} }