MycroftAI / lingua-franca

Mycroft's multilingual text parsing and formatting library
Apache License 2.0
75 stars 79 forks source link

English as a fallback language does not work after upgrade #174

Closed r0d0dendr0n closed 3 years ago

r0d0dendr0n commented 3 years ago

Describe the bug After upgrading lingua_franca the WeatherSkill says Error: parse module of language 'en' is not currently loaded. when asking about tommorows weather. To fix this I have to manualy set load_langs_on_demand = True in config.py.

To Reproduce Steps to reproduce the behavior:

  1. Set the language to something other than English.
  2. Ask Mycroft for todays weather

Expected behavior I expected Mycroft to simply give me an answer.

Log files

Traceback (most recent call last): File "/opt/mycroft/skills/mycroft-weather.mycroftai/init.py", line 433, in handle_currentweather today, = self.__extract_datetime("today", lang='en-us') File "/opt/mycroft/skills/mycroft-weather.mycroftai/init.py", line 1826, in __extract_datetime extracted_dt = extract_datetime(text, anchorDate, lang, default_time) File "/home/pi/mycroft-core/mycroft/util/parse.py", line 190, in extract_datetime lang, default_time) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/lingua_franca/internal.py", line 595, in call_localized_function return _call_localized_function(func, *args, **kwargs) File "/home/pi/mycroft-core/.venv/lib/python3.7/site-packages/lingua_franca/internal.py", line 536, in _call_localized_function "' is not currently loaded.") ModuleNotFoundError: parse module of language 'en' is not currently loaded.`

Environment (please complete the following information):

Additional context I think all informations are provided.

krisgesling commented 3 years ago

Hey thanks for flagging this, we're about to update LF in core so this is very helpful :)

ChanceNCounter commented 3 years ago

Mycroft-core needs some changes to prepare for LF0.3+ (reflected in the PR linked above this comment.) The problem, as @r0d0dendr0n discovered, is that some skills currently contain hardcoded references to English, or else they are hardcoded to fall back on English when they haven't been localized to the primary language.

(That's not the only problem, but it's the one you're seeing here.)

The current PR to upgrade Mycroft addresses this by loading both your configured language and English, so that any skills which explicitly call English will work without changes. In the long run, I'm hoping that I (or somebody else) will be able to tweak Mycroft to handle 2+ languages - especially as fallback options - more gracefully.

I suspect you'll encounter a number of other problems using the current version of LF with the current version of Mycroft.


One of the goals with LF 0.3 was to become less overtly English-centric. There's not much we can do about the fact that development usually starts in English, because 2 of 4 collaborators speak English as a native language, but downstream, for us, is conversation robots! They don't have a native language.

The setting you found was actually added for use cases that don't know what language they'll want until it's time to call the function, and it's got a (minor, at this point) performance hit, which probably isn't desirable when you know you're going to want the language over and over.

r0d0dendr0n commented 3 years ago

I understand the goals, but is it possible to deploy a temporary fix, so that it does not break every non-English instance of Mycroft? Maybe force load English as a secondary language? Set a default fallback in configuration?

Please do know that software is supposed to serve the user, not the other way. I mean I can manage on my own, because I k ow how to flip a boolean, but most people don't.

krisgesling commented 3 years ago

I haven't tried it yet but Chance has drafted a PR to update LF in core to 0.3. It would be great if you had time to review and test this: https://github.com/MycroftAI/mycroft-core/pull/2772

r0d0dendr0n commented 3 years ago

Will do this evening (CET)!

ChanceNCounter commented 3 years ago

I should probably re-explain: you aren't supposed to update Mycroft's copy of Lingua Franca directly. Rather, wait for programs to upgrade their own dependencies.

r0d0dendr0n commented 3 years ago

I agree with that.