Commit Graph

329 Commits (2582d78237f6959b835321cd92ea6616b410e56e)

Author SHA1 Message Date
Åke Forslund 7e88ae7e88 Correct the datdir/res path
Comment says the folder to be checked should be datadir/res, this makes
the code mean the same thing.
2020-04-17 23:42:04 +02:00
Åke Forslund b991453bcf Update docstrings of mycroft/util/__init__.py 2020-04-17 23:42:04 +02:00
Åke Forslund c8be703e49 Additional zero was prepended.
The formatting of small numbers was fixed in lingua franca
2020-03-26 18:43:19 +01:00
Åke Forslund 968370cbf1 Remove exec permission from format files
mycroft/util/format.py and test/unittests/util/test_format.py
2020-02-13 07:59:16 +01:00
Åke Forslund 9245f551f4 Remove backwards compat. imports from lang tools
This removes the whole mycroft.util.lang submodule replacing it with a
minimum needed set of functions

extract_datetime: when a date was missing en-us would return the current date
to not mess up existing skills. This is no longer the case, if an
utterance doesn't contain a date the function will return None as
indicated by the docstring
2020-02-12 09:27:50 +01:00
Åke Forslund 9c8c8e0144 Send time reference for "now" to Lingua-franca
This will provide timezone info as well as now reference to the
extracted sentences.
2020-01-29 15:33:28 +01:00
Åke Forslund 37caf7837d Remove logic from format.py and parse.py
The functions are still there providing the docstrings but calling the
lingua_franca functions.

Note, there is a INTENTIONAL addition of an inconsistence. Making the
extract_datetime return todays date instead of None as is documented.
This needs to be removed as soon as the mycroft default skills have been
added.
2020-01-18 08:58:23 +01:00
Åke Forslund 1b5b4f3d84 Add wrapper for extract_datetime 2020-01-18 08:58:23 +01:00
Åke Forslund 2cc90f3f9f Remove functions from format.py and parse.py 2020-01-18 08:58:23 +01:00
Åke Forslund 32666e9d68 Remove content from lang specific files
The files are kept for backwards compatibility but these just contains imports
of lingua-franca versions of variables
2020-01-18 08:58:23 +01:00
Åke Forslund 1b88db4fa1 Replace format and parse calls with lingua-franca 2020-01-18 08:58:23 +01:00
ChanceNCounter 4e8db9c860 clean up nice_duration handler
* Replace integer values with enum values for clarity
* Simplify exception thrown on incompatible input
* Pythonify (and de-Chanceify) zero-output logic
2019-12-17 05:10:34 -08:00
ChanceNCounter 5eb6b51eb2 Fix extractnumber_en failure on "%" (#2110)
Closes MycroftAI/mycroft-core#2110
2019-12-05 14:19:37 -08:00
Åke e7d9e8be1b
Merge pull request #2402 from maxbachmann/cleanup
Improve speed of pronounce_number_en
2019-11-29 17:07:59 +01:00
maxbachmann 4174689906 improve runtime 2019-11-29 16:56:36 +01:00
Åke e6385720b3
Merge pull request #2396 from maxbachmann/python2cleanup
cleanup python2 unicode
2019-11-27 08:46:20 +01:00
Åke e78a9730e1
Merge pull request #2386 from maxbachmann/dev
Add more time idioms (half past, etc.)
2019-11-27 08:41:02 +01:00
maxbachmann 87220ee85c add some more time idioms 2019-11-27 01:53:23 +01:00
maxbachmann 7a48297132 cleanup python2 unicode 2019-11-26 23:09:32 +01:00
Christian Clauss a1ff3fb355 Upgrade from pycodestyle to flake8 2019-11-19 23:07:52 +01:00
Mike Woudenberg cc5631c45f Adds rudimentary Dutch parsing support 2019-11-14 08:47:36 +01:00
Steve Penrod 0b8f7f54a4 Remove unnecessary code
The check for "this" performed in the case of "this quarter of an hour"
was copy/pasted in a large checkin.  The change it made to
daySpecified made no difference since the or in the later code
looked for an unspecified absolute hour.  I can come up with no
senseable phrase that matches the conditions and couldn't even
create a nonsensical phrase that made a difference.

Since all of the existing unit tests pass without this code,
I'm going to just remove it.
2019-11-04 09:39:09 +01:00
Åke 324fe988aa
Merge pull request #2356 from ChanceNCounter/spanish-language-parsers
fix bug in isFractional_es and improve coverage
2019-10-14 16:04:57 +02:00
Åke 8126bcafce
Merge pull request #2346 from ChanceNCounter/tests/util-parse-en
fix bug, redundancy in parse_en; improve coverage
2019-10-07 13:22:23 +02:00
ChanceNCounter 1c41e523ce fix bug in isFractional_es and improve coverage
- Fix: isFractional_es() parsed fractions incorrectly
- Update: earlier commit msg suggested another fix:
  - Month parsing not fixed
  - Several failing tests (skipped) document problem
  - TODO and an issue also created
- Substantially improve parse_es.py test coverage
- TODO or comment several found bugs
  - Many lines remain uncovered, incl possible bugs
2019-10-05 14:46:09 -07:00
Åke 8ffad68251
Merge pull request #2347 from ChanceNCounter/extractnumber-es-fix-and-add-extractnumbers
Fix extractnumber_es, add extract_numbers_es
2019-10-04 08:46:03 +02:00
Åke 90ceaa3c88
Merge pull request #2342 from ChanceNCounter/fix/convert-mixed-fraction-param-default
add default value to nice_number param
2019-10-04 08:43:15 +02:00
ChanceNCounter 1107f5d6cc Fix extractnumber_es, add extract_numbers_es
- Fix bug causing extractnumber_es to return a sum instead of a list
- Add Spanish parser to extract_numbers and extract_number

==== Fixed Issues ====
Closes #2310

====  Tech Notes ====
Further obscures #2056: short_scale and ordinals parameters added to the
Spanish parsers, but they don't do anything. Present for compat only.
There is a TODO for this.

==== Localization Notes ====
It's all Spanish stuff!

This will require a native Spanish speaker to analyze the relationship
between extractnumber and isFractional, and determine why certain
fractions do not parse correctly. There is a TODO for this.
2019-10-03 17:11:39 -07:00
ChanceNCounter 16d6bf4b22 fix bug, redundancy in parse_en; improve coverage
- Remove unreachable conditions from parse_en:1122-1133
  - input string passed through clean_string() on line 763
  - articles stripped from input before line 1122
  - removed conditions relied on presence of "the" in input
- Improved test coverage on parse_en.py by approx 65 statements
  - Directly test certain helper functions which are difficult to
invoke indirectly
  - Add tests for certain missed conditions
  - Approx. 20 uncovered statements remain
2019-10-03 14:41:21 -07:00
ChanceNCounter 8c50fe9700 add optional 'clock' param for displayed output
Add one more optional parameter: bool clock, always produces
digital clock-like output. "0h 3m" becomes "0:03:00".

Has no effect on resolutions YEARS or DAYS, and MINUTES won't print hrs.
2019-10-02 07:55:22 +02:00
ChanceNCounter 4253929d2c - make nice_duration handle years, datetimes, and ms
- Companion enum:
mycroft.util.format.TimeResolution
offers YEARS, DAYS, HOURS, MINUTES, SECONDS, or MILLISECONDS

- Will only return ms if MILLISECONDS is chosen. Default: SECONDS

- Update tests
2019-10-02 07:55:22 +02:00
ChanceNCounter 388d9afaa7 add default value to nice_number param
Add default value to nice_number & convert_mixed_fraction `denominator`

Add tests for convert_mixed_fraction
2019-10-01 06:55:44 -07:00
ChanceNCounter a44167a3a4 Fixes index error in parse_en.extract_datetime()
==== Fixed Issues ====
#2333

====  Tech Notes ====
extract_datetime("day after tomorrow") attempted to check the previous
word. This resulted in an index error. Fixed by introducing a nested
condition. Seems to have solved it.

A similar bug is present in other parts of this file, such as line 843.

I have also discovered a number of other oddities, but they may be
outside the scope of this issue. At least Mycroft can now extract from
"day after tomorrow."

==== Localization Notes ====
I haven't checked parsers for any other languages.
2019-09-28 14:31:59 -07:00
Åke Forslund 39d0053493 Catch inspect error in logger
Inspect would in certain cases fail to find the line number. This
catches the exception and provides a basic name for the logger.
2019-09-24 20:58:34 +02:00
Åke Forslund 29dbbe1bee Update to use the old dns connection test aswell
This handles capture portals as well.

The standard connection logic is now

Check outside ip is reachable and after that check that www.google.com
is resolvable and connectable.

TODO: create endpoint on backend with known response to perform check
upon.
2019-09-17 09:27:43 +02:00
Chris Veilleux da3ce2caf5 Change connection check logic to resolve www.google.com
Change logic that checked for an internet connection after an issue occurred during initial boot where the old connection check gave a false positive.

Reordered imports to be PEP8 compliant. Minor refactoring to remove issues identified in PyCharm
2019-09-17 09:27:43 +02:00
Åke Forslund 3d37315bc0 Utilize pulseaudio's corking/ducking feature
Pulseaudio allows corking / ducking for streams with prioritized roles
This sets the role for the mycroft speech to "phone" and all other to
"music" if the config tts->pulse_duck is set to true.
2019-08-31 14:27:06 +02:00
Chris Veilleux c5058a5117 Merge remote-tracking branch 'remotes/origin/dev' into feature/log-merger 2019-08-29 13:57:08 -05:00
Kris Gesling 754da78065
Merge pull request #2242 from cclauss/patch-2
Use ==/!= to compare str, bytes, and int literals
2019-08-08 06:26:57 +09:30
Chris Veilleux b44381d265 changed format of of log messages to include a date, put the log level in the second position and add the pid 2019-08-02 11:16:37 -05:00
Christian Clauss 517a0edaa2
Use ==/!= to compare str, bytes, and int literals
Identity is not the same thing as equality in Python

$ python
```
>>> 1 == 1.0
True
>>> 1 is 1.0
False
```
2019-07-31 00:13:44 +02:00
c0r73x e88e7c007d More fixes to swedish numbers 2019-07-27 20:27:51 +02:00
c0r73x 4f92361bcc Added test_format_sv.py 2019-07-25 22:45:30 +02:00
c0r73x 9e37064408 Fixed format_sv 2019-07-25 21:49:50 +02:00
Chris Veilleux 4e9130114e remove validate_param since it's now unused 2019-07-19 08:16:54 +02:00
Kris Gesling efa69e0526 'next {day}' to be 3-9 days in future (#2184)
* 'next {day}' to be 2-9 days in future

* restore module level docstring

* remove lang specific definition of 'next'

* restore module level docstring
2019-07-13 11:53:38 +02:00
Åke da00b38f82 Explain the config system used here. (#2201)
- Add module docstring
- Add comment in the init class method about setting up the log level
- Add mycroft.util.log to the readthedocs documentation
- Add comment in the config about the log_level
2019-07-11 17:39:50 -05:00
Åke Forslund c2c2377780 Add additional exceptions for may 2019-07-08 15:36:14 +02:00
Kris Gesling 946b7bf3de fix requests with non-month 'may' 2019-07-08 15:36:14 +02:00
Åke Forslund 25026e9f4c Add docs for the mycroft.util.format module
- Adds a module docstring to both format and parse module
- Update toc with a short description for these members
- Fix slight formatting issues
2019-06-28 15:30:13 +02:00