Add fuzzy and text-classification light model #1

Merged
Tjiho merged 18 commits from fuzzy into master 2025-02-01 01:35:11 +01:00
Showing only changes of commit ef1e108106 - Show all commits

View file

@ -4,6 +4,13 @@ from rapidfuzz import process, fuzz, utils
ROOMS = ["cuisine", "salon", "chambre", "bureau"] ROOMS = ["cuisine", "salon", "chambre", "bureau"]
MUSIQUE_GENRE_SHORT = ["synthpop", "jazz classique", "jazz manouche", "classique", "rock", "jazz", "blues", "film", "francaise", "pop", "reggae", "folk",
"électro", "punk", "corse", "arabe", "persane", "piano", "rap", "slam"]
MUSIQUE_GENRE_LONG = ["synthpop", "jazz classique", "jazz manouche", "classique", "rock", "jazz", "blues", "musique de film", "chanson francaise", "pop", "reggae", "folk",
"électro", "punk", "chanson corse", "chanson arabe", "chanson persane", "piano", "rap", "slam", "chanson classique"]
def compute_sentences_lamp_on(): def compute_sentences_lamp_on():
return ["allume la lumière de la" + room for room in ROOMS] return ["allume la lumière de la" + room for room in ROOMS]
@ -12,10 +19,19 @@ def compute_sentences_lamp_off():
return ["éteins la lumière de la" + room for room in ROOMS] return ["éteins la lumière de la" + room for room in ROOMS]
def compute_sentences_musique_genre_long():
return ["met du" + genre for genre in MUSIQUE_GENRE_LONG]
def compute_sentences_musique_genre_short():
return ["met de la musique" + genre for genre in MUSIQUE_GENRE_SHORT]
SENTENCES_HOUR = ["quel heure est-il ?"] SENTENCES_HOUR = ["quel heure est-il ?"]
SENTENCES_LAMP_ON = compute_sentences_lamp_on() SENTENCES_LAMP_ON = compute_sentences_lamp_on()
SENTENCES_LAMP_OFF = compute_sentences_lamp_off() SENTENCES_LAMP_OFF = compute_sentences_lamp_off()
# SENTENCES_MUSIQUE = computes_sentences SENTENCES_MUSIQUE_GENRE_LONG = compute_sentences_musique_genre_long()
SENTENCES_MUSIQUE_GENRE_SHORT = compute_sentences_musique_genre_short()
def fuzz_predict(text): def fuzz_predict(text):
@ -33,6 +49,12 @@ def fuzz_predict(text):
if choosen_sentence in SENTENCES_LAMP_OFF: if choosen_sentence in SENTENCES_LAMP_OFF:
return {'intentName': 'LightOff', 'intentArg': [find_matching(ROOMS, text)]} return {'intentName': 'LightOff', 'intentArg': [find_matching(ROOMS, text)]}
if choosen_sentence in SENTENCES_MUSIQUE_GENRE_LONG:
return {'intentName': 'LightOff', 'intentArg': [find_matching(MUSIQUE_GENRE_SHORT, text)]}
if choosen_sentence in SENTENCES_MUSIQUE_GENRE_SHORT:
return {'intentName': 'LightOff', 'intentArg': [find_matching(MUSIQUE_GENRE_SHORT, text)]}
return {'intentName': 'Unknown'} return {'intentName': 'Unknown'}