From 12119f428167cd00124e376d50d6c3b214a7d341 Mon Sep 17 00:00:00 2001 From: Mathieu B Date: Tue, 3 Aug 2021 21:31:22 +0200 Subject: [PATCH] Lots of improvements for WeatherSkill --- .../entertainement/weather/__init__.old.py | 231 ------------------ .../skills/entertainement/weather/__init__.py | 12 + .../weather/providers/__init__.py | 0 .../weather/providers/meteo_swiss.py | 2 + .../weather/vocab/fr-fr/day.entity | 5 +- .../vocab/fr-fr/handle_is_it_cold.intent | 2 + .../vocab/fr-fr/handle_is_it_hot.intent | 2 + .../vocab/fr-fr/handle_temperature.intent | 10 + .../weather/vocab/fr-fr/handle_weather.intent | 12 +- 9 files changed, 38 insertions(+), 238 deletions(-) create mode 100644 jarvis/skills/entertainement/weather/providers/__init__.py create mode 100644 jarvis/skills/entertainement/weather/providers/meteo_swiss.py create mode 100644 jarvis/skills/entertainement/weather/vocab/fr-fr/handle_is_it_cold.intent create mode 100644 jarvis/skills/entertainement/weather/vocab/fr-fr/handle_is_it_hot.intent create mode 100644 jarvis/skills/entertainement/weather/vocab/fr-fr/handle_temperature.intent diff --git a/jarvis/skills/entertainement/weather/__init__.old.py b/jarvis/skills/entertainement/weather/__init__.old.py index a69b97a..5ba343f 100644 --- a/jarvis/skills/entertainement/weather/__init__.old.py +++ b/jarvis/skills/entertainement/weather/__init__.old.py @@ -15,237 +15,6 @@ class WeatherSkill(Skill, metaclass=SkillRegistering): def __init__(self, data=dict): super().__init__("WeatherSkill", data) - - @intent_handler( - IntentBuilder("handle_number_days_forecast") - .optionally("query") - .one_of("weather", "forecast") - .require("number-days") - .optionally("location") - ) - # pas ouf - def handle_number_days_forecast(self, data): - """Handle multiple day forecast without specified location. - - Examples: - "What is the 3 day forecast?" - "What is the weather forecast?" - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_one_day_forecast") - .optionally("query") - .one_of("weather", "forecast") - .require("relative-day") - .optionally("location") - ) - def handle_one_day_forecast(self, data): - """Handle forecast for a single day. - - Examples: - "What is the weather forecast tomorrow?" - "What is the weather forecast on Tuesday in Baltimore?" - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_weather_later") - .require("query") - .require("weather") - .require("later") - .optionally("location") - ) - def handle_weather_later(self, data): - """Handle future weather requests such as: what's the weather later? - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_weather_at_time") - .optionally("query") - .one_of("weather", "forecast") - .require("relative-time") - .optionally("relative-day") - .optionally("location") - ) - def handle_weather_at_time(self, data): - """Handle future weather requests such as: what's the weather tonight? - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_weekend_forecast") - .require("query") - .one_of("weather", "forecast") - .require("weekend") - .optionally("location") - ) - def handle_weekend_forecast(self, data): - """Handle requests for the weekend forecast. - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_week_weather") - .optionally("query") - .one_of("weather", "forecast") - .require("week") - .optionally("location") - ) - def handle_week_weather(self, data): - """Handle weather for week (i.e. seven days). - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_current_temperature") - .optionally("query") - .require("temperature") - .optionally("location") - .optionally("unit") - .optionally("today") - .optionally("now") - ) - def handle_current_temperature(self, data): - """Handle requests for current temperature. - - Examples: - "What is the temperature in Celsius?" - "What is the temperature in Baltimore now?" - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_daily_temperature") - .optionally("query") - .require("temperature") - .require("relative-day") - .optionally("location") - .optionally("unit") - ) - def handle_daily_temperature(self, data): - """Handle simple requests for current temperature. - - Examples: "What is the temperature?" - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_hourly_temperature") - .optionally("query") - .require("temperature") - .require("relative-time") - .optionally("relative-day") - .optionally("location") - ) - def handle_hourly_temperature(self, data): - """Handle requests for current temperature at a relative time. - - Examples: - "What is the temperature tonight?" - "What is the temperature tomorrow morning?" - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_high_temperature") - .optionally("query") - .require("high") - .optionally("temperature") - .optionally("location") - .optionally("unit") - .optionally("relative-day") - .optionally("now") - .optionally("today") - ) - def handle_high_temperature(self, data): - """Handle a request for the high temperature. - - Examples: - "What is the high temperature tomorrow?" - "What is the high temperature in London on Tuesday?" - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_low_temperature") - .optionally("query") - .require("low") - .optionally("temperature") - .optionally("location") - .optionally("unit") - .optionally("relative-day") - .optionally("now") - .optionally("today") - ) - def handle_low_temperature(self, data): - """Handle a request for the high temperature. - - Examples: - "What is the high temperature tomorrow?" - "What is the high temperature in London on Tuesday?" - - Args: - data Bus event information from the intent parser - """ - - pass - - @intent_handler( - IntentBuilder("handle_is_it_hot") - .require("confirm-query-current") - .one_of("hot", "cold") - .optionally("location") - .optionally("today") - ) - def handle_is_it_hot(self, data): - """Handler for temperature requests such as: is it going to be hot today? - - Args: - data Bus event information from the intent parser - """ - pass - - @intent_handler( - IntentBuilder("handle_how_hot_or_cold") - .optionally("query") - .one_of("hot", "cold") - .require("confirm-query") - .optionally("location") - .optionally("relative-day") - .optionally("today") - ) def handle_how_hot_or_cold(self, data): """Handler for temperature requests such as: how cold will it be today? diff --git a/jarvis/skills/entertainement/weather/__init__.py b/jarvis/skills/entertainement/weather/__init__.py index 3bbd797..f413933 100644 --- a/jarvis/skills/entertainement/weather/__init__.py +++ b/jarvis/skills/entertainement/weather/__init__.py @@ -10,6 +10,18 @@ class WeatherSkill(Skill, metaclass=SkillRegistering): def handle_weather(self, data): pass + @intent_file_handler("handle_temperature.intent", "HandleTemperatureIntent") + def handle_temperature(self, data): + pass + + @intent_file_handler("handle_is_it_hot.intent", "HandleIsItHotIntent") + def handle_temperature(self, data): + pass + + @intent_file_handler("handle_is_it_cold.intent", "HandleIsItColdIntent") + def handle_temperature(self, data): + pass + def create_skill(data): return WeatherSkill(data) diff --git a/jarvis/skills/entertainement/weather/providers/__init__.py b/jarvis/skills/entertainement/weather/providers/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jarvis/skills/entertainement/weather/providers/meteo_swiss.py b/jarvis/skills/entertainement/weather/providers/meteo_swiss.py new file mode 100644 index 0000000..d4a9185 --- /dev/null +++ b/jarvis/skills/entertainement/weather/providers/meteo_swiss.py @@ -0,0 +1,2 @@ +def get_temperature(): + return 20 \ No newline at end of file diff --git a/jarvis/skills/entertainement/weather/vocab/fr-fr/day.entity b/jarvis/skills/entertainement/weather/vocab/fr-fr/day.entity index 307020b..37e908e 100644 --- a/jarvis/skills/entertainement/weather/vocab/fr-fr/day.entity +++ b/jarvis/skills/entertainement/weather/vocab/fr-fr/day.entity @@ -12,4 +12,7 @@ après-demain après demain après midi aprèm -après-midi \ No newline at end of file +après-midi +soir +matin +ces prochains jours \ No newline at end of file diff --git a/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_is_it_cold.intent b/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_is_it_cold.intent new file mode 100644 index 0000000..03bc156 --- /dev/null +++ b/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_is_it_cold.intent @@ -0,0 +1,2 @@ +est-ce qu'il va faire froid {day} +va t'il faire froid {day} \ No newline at end of file diff --git a/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_is_it_hot.intent b/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_is_it_hot.intent new file mode 100644 index 0000000..c25deae --- /dev/null +++ b/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_is_it_hot.intent @@ -0,0 +1,2 @@ +est-ce qu'il va faire chaud {day} +va t'il faire chaud {day} \ No newline at end of file diff --git a/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_temperature.intent b/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_temperature.intent new file mode 100644 index 0000000..76d23d7 --- /dev/null +++ b/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_temperature.intent @@ -0,0 +1,10 @@ +ce sera quoi la température ((ce|cet|) {day}|) ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +c'est quoi la température ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +il fait quel température (dehors|) ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +ca (ressemble à|donne) quoi la température (dehors|) ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +donne moi la température ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +donne moi la température (pour|de) (ce|cet|) {day} ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +dis moi la température ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +dis moi la température (pour|de) (ce|cet|) {day} ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +il (fait|va faire) (quel température|combien) (dehors|) (soir|midi|après-midi|matin|) ((ce|cet|) {day}|) ((à|a|pour) {location}|) +il (fait|fera|va faire) (quelle|combien|) température (dehors|) ((ce|cet|) {day}|(pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) ((à|a|pour) {location}|) \ No newline at end of file diff --git a/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_weather.intent b/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_weather.intent index f254d34..67c84d4 100644 --- a/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_weather.intent +++ b/jarvis/skills/entertainement/weather/vocab/fr-fr/handle_weather.intent @@ -1,13 +1,13 @@ -ce sera quoi la météo ({day}|) ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +ce sera quoi la météo ((ce|cet|) {day}|) ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) c'est quoi la météo ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) il fait quel temps (dehors|) ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) ca (ressemble à|donne) quoi (la météo|dehors|le temps) ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) donne moi la météo ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) -donne moi la météo (pour|de) {day} ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +donne moi la météo (pour|de) (ce|cet|) {day} ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) dis moi la météo ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) -dis moi la météo (pour|de) {day} ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) -il (fait|va faire) quel temps (dehors|) ({day}|) ((à|a|pour) {location}|) -il (fait|fera|va faire) (quel|quoi|) (temps|météo|) (dehors|) ({day}|(pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) ((à|a|pour) {location}|) +dis moi la météo (pour|de) (ce|cet|) {day} ((pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) +il (fait|va faire) quel temps (dehors|) (soir|midi|après-midi|matin|) ((ce|cet|) {day}|) ((à|a|pour) {location}|) +il (fait|fera|va faire) (quel|quoi|) (temps|météo|) (dehors|) ((ce|cet|) {day}|(pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) ((à|a|pour) {location}|) donne moi les prévisions de la journée ((à|pour) {location}|) -(donne moi|ce sera quoi) les prévisions (météo|) pour {day} ((à|a|pour) {location}|) +(donne moi|ce sera quoi) les prévisions (météo|) pour (ce|cet|) {day} ((à|a|pour) {location}|) (donne moi|ce sera quoi) les prévisions (météo|) ({day}|(pour|les|de ces|ces) {forecast_days} (prochain|prochains|) jours|) ((à|a|pour) {location}|) \ No newline at end of file