Add fuzzy and text-classification light model #1
					 1 changed files with 23 additions and 1 deletions
				
			
		Add musique genre in fuzzy
				commit
				
					
					
						ef1e108106
					
				
			
		
							
								
								
									
										24
									
								
								src/fuzzy.py
									
										
									
									
									
								
							
							
						
						
									
										24
									
								
								src/fuzzy.py
									
										
									
									
									
								
							|  | @ -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'} | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue