Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: drop lingua-franca #85

Merged
merged 5 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from time import sleep
from typing import List

from lingua_franca.parse import extract_number
from lingua_franca.format import (
from ovos_number_parser import extract_number
from ovos_date_parser import (
nice_time,
nice_weekday,
get_date_strings
Expand Down Expand Up @@ -847,7 +847,7 @@ def _display_multi_day_scalable(self, forecast: List[Weather]):
weatherCondition=day.condition.animated_code,
highTemperature=day.temperature_high,
lowTemperature=day.temperature_low,
date=nice_weekday(day.date_time, self.lang)[:3],
date=nice_weekday(day.date_time, lang=self.lang)[:3],
)
)
self.gui["forecast"] = dict(all=display_data)
Expand Down Expand Up @@ -1049,7 +1049,7 @@ def _format_time(self, dt: datetime) -> str:
the value to display on the screen
"""
return nice_time(dt,
self.lang,
lang=self.lang,
speech=False,
use_24hour = self.use_24h,
use_ampm = not self.use_24h)
Expand Down
5 changes: 4 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
requests>=2.31.0
pytz
ovos-utils>=0.0.28
ovos-workshop>=0.0.16,<3.0.0
ovos-workshop>=2.2.0a1,<3.0.0
ovos-number-parser>=0.0.1,<1.0.0
ovos-date-parser>=0.0.1,<1.0.0
ovos-utterance-normalizer>=0.0.1,<1.0.0
17 changes: 8 additions & 9 deletions weather_helpers/dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@

The skill class will use the "name" and "data" attributes to pass to the TTS process.
"""
# TODO - get rid of relative imports as soon as skills can be properly packaged with arbitrary module structures
from typing import List
from os.path import dirname
# TODO - get rid of relative imports as soon as skills can be properly packaged with arbitrary module structures
from typing import List, Optional

from lingua_franca.format import join_list, nice_time
from ovos_date_parser import nice_time
from ovos_utils.time import now_local
from ovos_workshop.resource_files import SkillResources

from ovos_workshop.skills.ovos import join_word_list
from .intent import WeatherIntent
from .util import get_speakable_day_of_week, get_time_period
from .weather import (
Expand All @@ -50,7 +50,6 @@
WeatherReport
)


# TODO: MISSING DIALOGS
# - current.clear.alternative.local
# - current.clouds.alternative.local
Expand All @@ -77,7 +76,7 @@ def lang(self):

def translate(self, dialog, data=None):
data = data or dict()
return self.resources.render_dialog(dialog, data=data)
return self.resources.render_dialog(dialog, data=data)

def _add_location(self):
"""Add location information to the dialog."""
Expand Down Expand Up @@ -212,7 +211,7 @@ def __init__(self, intent_data: WeatherIntent, weather: Weather):
super().__init__(intent_data)
self.weather = weather
self.name = HOURLY

def build_weather_dialog(self):
"""Build the components necessary to speak the forecast for a hour."""
self.name += "-weather"
Expand All @@ -223,7 +222,7 @@ def build_weather_dialog(self):
)
self._add_location()

def build_temperature_dialog(self, _ = None):
def build_temperature_dialog(self, _=None):
"""Build the components necessary to speak the hourly temperature."""
self.name += "-temperature"
self.data = dict(
Expand Down Expand Up @@ -428,7 +427,7 @@ def build_condition_dialog(self, condition: str):
if daily.condition.category == condition:
day = get_speakable_day_of_week(daily.date_time, lang=self.lang)
days_with_condition.append(day)
self.data.update(days=join_list(days_with_condition, "and"))
self.data.update(days=join_word_list(days_with_condition, connector="and", sep=",", lang=self.lang))


def get_dialog_for_timeframe(intent_data: WeatherIntent,
Expand Down
8 changes: 3 additions & 5 deletions weather_helpers/intent.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
from datetime import timedelta

from ovos_utils.time import now_local
from lingua_franca.parse import normalize

from ovos_utterance_normalizer import UtteranceNormalizerPlugin
from .util import (
get_utterance_datetime,
get_geolocation,
Expand All @@ -40,9 +39,8 @@ def __init__(self, message, weather_config: WeatherConfig):
:param language: The configured language of the device
"""
self.message = message
self.utterance = normalize(message.data["utterance"],
weather_config.lang,
remove_articles=False)
normalizer = UtteranceNormalizerPlugin.get_normalizer(lang=weather_config.lang)
self.utterance = normalizer.normalize(message.data["utterance"])
self.location = message.data.get("location")
self.config = weather_config
self.scale = None
Expand Down
6 changes: 3 additions & 3 deletions weather_helpers/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from itertools import islice

import pytz
from lingua_franca.format import nice_date
from lingua_franca.parse import extract_datetime

from ovos_date_parser import nice_date, extract_datetime
from ovos_backend_client.api import GeolocationApi
from ovos_utils.time import now_local, to_local

Expand Down Expand Up @@ -65,7 +65,7 @@ def get_utterance_datetime(
else:
intent_timezone = get_tz_info(timezone)
anchor_date = datetime.now(intent_timezone)
extract = extract_datetime(utterance, anchor_date, language)
extract = extract_datetime(utterance, anchorDate=anchor_date, lang=language)
if extract is not None:
utterance_datetime, _ = extract
return utterance_datetime
Expand Down
Loading