Add fuzzy and text-classification light model #1
2 changed files with 13 additions and 4 deletions
|
@ -64,6 +64,8 @@ class Ratatouille():
|
||||||
command = payload['intentName']
|
command = payload['intentName']
|
||||||
if command == 'GetTime':
|
if command == 'GetTime':
|
||||||
return self.send_hour()
|
return self.send_hour()
|
||||||
|
elif command == 'GetDate':
|
||||||
|
return self.send_date()
|
||||||
elif command == "LightOn":
|
elif command == "LightOn":
|
||||||
return self.light_on_single(payload['intentArg'][0])
|
return self.light_on_single(payload['intentArg'][0])
|
||||||
elif command == "LightOff":
|
elif command == "LightOff":
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
from src.tools.str import int_to_str
|
from src.tools.str import int_to_str
|
||||||
|
|
||||||
MONTHS = ['janvier','février','mars','avril','mai','juin','juillet','aout','septembre','octobre','novembre','decembre']
|
MONTHS = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin',
|
||||||
WEEKDAY = ['lundi','mardi','mercredi','jeudi','vendredi','samedi','dimanche']
|
'juillet', 'aout', 'septembre', 'octobre', 'novembre', 'decembre']
|
||||||
|
WEEKDAY = ['lundi', 'mardi', 'mercredi',
|
||||||
|
'jeudi', 'vendredi', 'samedi', 'dimanche']
|
||||||
|
|
||||||
|
|
||||||
def get_time(date):
|
def get_time(date):
|
||||||
hour = date.hour
|
hour = date.hour
|
||||||
|
@ -13,18 +16,20 @@ def get_time(date):
|
||||||
elif minute == 45:
|
elif minute == 45:
|
||||||
return 'il est '+format_hour(hour+1)+' moins le quart'
|
return 'il est '+format_hour(hour+1)+' moins le quart'
|
||||||
elif minute == 15:
|
elif minute == 15:
|
||||||
return 'il est '+format_hour(hour+1)+' et quart'
|
return 'il est '+format_hour(hour)+' et quart'
|
||||||
else:
|
else:
|
||||||
return 'il est '+format_hour(hour)+' '+str(minute)
|
return 'il est '+format_hour(hour)+' '+str(minute)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def get_date(date):
|
def get_date(date):
|
||||||
week_day = date.weekday()
|
week_day = date.weekday()
|
||||||
day = date.day
|
day = date.day
|
||||||
month = date.month
|
month = date.month
|
||||||
year = date.year
|
year = date.year
|
||||||
return 'Nous somme le '+format_weekday(week_day)+' '+str(day)+' '+format_month(month)+' '+str(year)
|
return 'Nous somme le '+format_weekday(week_day)+' '+str(day)+' '+format_month(month)+' '+str(year)
|
||||||
#self.yoda.say('Nous somme le '+str(week_day)+' '+str(day)+' '+str(month)+' '+str(year))
|
# self.yoda.say('Nous somme le '+str(week_day)+' '+str(day)+' '+str(month)+' '+str(year))
|
||||||
|
|
||||||
|
|
||||||
def format_hour(hour):
|
def format_hour(hour):
|
||||||
if hour == 12:
|
if hour == 12:
|
||||||
|
@ -34,8 +39,10 @@ def format_hour(hour):
|
||||||
|
|
||||||
return int_to_str(hour, 'f') + ' heure'
|
return int_to_str(hour, 'f') + ' heure'
|
||||||
|
|
||||||
|
|
||||||
def format_month(month):
|
def format_month(month):
|
||||||
return MONTHS[month - 1]
|
return MONTHS[month - 1]
|
||||||
|
|
||||||
|
|
||||||
def format_weekday(week_day):
|
def format_weekday(week_day):
|
||||||
return WEEKDAY[week_day]
|
return WEEKDAY[week_day]
|
||||||
|
|
Loading…
Add table
Reference in a new issue