Commit Graph

344 Commits (10b8e93b7419126864d9bab2effbe813962865ee)

Author SHA1 Message Date
Chris Rogers 1bb74f5c79 Use isinstance instead of type.
This is in support of issues-1959.
2019-02-03 12:58:31 -05:00
Chris Rogers cdf7dc3756 Use datetime.timedelta for extract_duration_en.
This is in support of issues-1959.
2019-02-03 12:16:36 -05:00
Chris Rogers d50cb00de8 Fix pep8 issues.
This is in support of issues-1959.
2019-02-02 14:21:37 -05:00
Chris Rogers 9e193c74e0 Make constant and functions private.
Making things weak private, to limit surface area of support. As things
become increasingly stable/tested/useful, it may make sense to open them
up, but for now, keeping them private will limit risk.

This is in support of issue-1959.
2019-02-02 14:07:48 -05:00
Chris Rogers 351381bca2 Fix pep8 issues.
This is in support of issues-1959.
2019-02-02 14:03:19 -05:00
Chris Rogers 7049e65cbe Minor shuffling + update docs.
After many changes, things had gotten a little disorganized, and the
docs were a little out of date. This brings them up to date.

This is in support of issues-1959.
2019-02-02 13:45:22 -05:00
Chris Rogers 534ca2aff9 All regressions in number parsing fixed.
This is in support of issues-1959.
2019-02-02 13:12:25 -05:00
Chris Rogers 6da1ec5c6e Fix regression in number parsing.
Fix regression that caused "X and one half" to parse as just X.

This is in support of issues-1959.
2019-02-01 23:24:45 -05:00
Chris Rogers f4eee8726a Refactor many methods in parse_en.
This improves the utility of the _ReplaceableNumber class, and updates
most of the number parsing functions to take tokens rather than text.
This simplifies the interactions between many of the functions, as there
is no need to convert back and forth between text and tokens.

This also adds some tests. Note that there are a few regressions that
will be fixed in a subsequent commit.
2019-02-01 23:04:54 -05:00
Chris Rogers 95aca10294 Fix _extract_decimal
Actually use the short_scale and ordinals values.
2019-02-01 18:57:28 -05:00
Chris Rogers 2ce632389f Fix and simplfy extract_numbers_en
This was calling convert_words_to_numbers and parsing out the resuling
numbers, which was a simple way of getting the numebrs in order, but it
choked on anything that didn't match the regex being used to parse
numbers, in particular numbers of the form '6e18'. The better solution
is to directly use extract_numbers_with_text (which now sorts by
start_index) and get the values from there directly.

This is in support of issues-1959.
2019-02-01 18:51:03 -05:00
Chris Rogers 6645ab6bfe Add short_scale and ordinal args to helpers.
This is in support of issues-1959.
2019-02-01 18:28:40 -05:00
Chris Rogers 5c74789c2d Lower text before parsing.
This is in support of issues-1959.
2019-02-01 18:21:13 -05:00
Chris Rogers 23edb9eb00 Fix decimal/fraction parsing with leading numbers.
"Five hours seven and a half minutes" was parsing as 5.5. This is
resolved. Multiple fractions/decimals still cause problems, e.g.

convert_words_to_numbers("seven and a half and nine and a half")
Out[5]: '7 and a 0.5 and 9 and a 0.5'

This is in support of issues-1959.
2019-02-01 17:39:01 -05:00
Steve Penrod df4f6ca6dd Fix typo and add --list option
The -l / --list option will now display the name and index of all available input devices.
2019-01-31 08:19:21 +01:00
Chris Rogers a3e94bcbc6 Add numbers, e.g. '20', '30' to sums
This is in support of issues-1959.
2019-01-30 22:53:22 -05:00
Chris Rogers 4732feab41 Fix indicies and substitution logic.
Placeholders are inserted into the text to maintain accurate
indicie relative to the original string.

This is in support of issues-1959.
2019-01-30 22:06:02 -05:00
Chris Rogers 49274493d9 Update convert_words_to_numbers logic.
The logic has been updated for start/end indexs.

This is in support of issues-1959.
2019-01-30 21:18:48 -05:00
Chris Rogers 03a445991c Fix multiplies and extract_numbers_with_text
A small bug caused things like "two hundred twenty" to return only the
"hundred tenty" for the text. This has been fixed.

extract_numbers_with_text was updated to deal with the new return types
of the functions it depends on. Specifically, it accounts for the start
and end index values.

This is in support of issues-1959.
2019-01-30 18:24:18 -05:00
Chris Rogers 71836b61ec Fix decimal and fraction parsing.
This updates the _extract_fraction and _extract_decimal functions to
handle the new token format.
2019-01-30 18:03:25 -05:00
Chris Rogers 48214ca66a Introduce tokens for number parsing.
Replace use of tuples with a dedicated class. This improves clarity by
giving named accessors.

This is in support of issues-1959.
2019-01-30 16:48:59 -05:00
Chris Rogers 9db9b6107b Change approach to number/text replacment.
Previously it was assumed that the orgiginal text would be enough to
determine where in a string a number should go, however, in some
scenarios, that does not work, and results in the wrong values being
parsed.

A different, and smarter approach is being taken now, in which the
original string is initially split into a list of tuples of
(index, word) where index is the index of the word within the string.
All subsequent processing is done on these tuples, meaning we always
know exactly where the words were in the orginal string. This should
make text replacement perfect, as we can always sub out the exact,
correct words, based on their indicies.

extract_number_with_text_en now returns the number parsed, the text that
represents the number, the start index, and the end index.

Things are not yet working perfectly. Here is roughly the current state
of the world:

from mycroft.util.lang.parse_en import *
extract_number_with_text_en("this is some two hundred thousand twenty
two hours")
Out[3]: (200022, 'hundred thousand twenty two', 4, 7)
extract_number_with_text_en("this is some twenty two hours")
Out[4]: (22, 'twenty two', 3, 4)
extract_number_with_text_en("this is some twenty hours")
Out[5]: (20, 'twenty', 3, 3)
extract_number_with_text_en("this is some two and a half hours")
Out[6]: (2, 'two', 3, 3)
extract_number_with_text_en("this is some two point five hours")
Out[7]: (2, 'two', 3, 3)

The list of tuples is a bit of a hassle to deal with. In a future
commite the will be replaced with dictionaries, or even better, Token
objects, that contain the word and it's index. This would make the
code easier to reason about (removing lots things like words[0][1]
which has no meaning without deep understanding of the code).

This is in support of issues-1959.
2019-01-29 22:33:23 -05:00
Chris Rogers 8a5bf49651 Handle lists of summation numbers.
Phrases like "twenty thirty forty" would return
(40, "twenty thrity forty"). This changes that so
(40 "forty") is returned.
2019-01-29 21:25:06 -05:00
Chris Rogers 690df0b1d3 Update entract_numbers_en to use the new functions.
This is in support of issues-1959.
2019-01-29 20:57:16 -05:00
Chris Rogers f4723b1026 Cleanup parse_en.
Rename some functions, and fix docs/pep8 issues.
2019-01-29 20:50:13 -05:00
Chris Rogers 9aa02587b3 Fix an issue with extractnumber_en_with_text
Articles (a, an, the) that appeared immediately before the number were
included in the returned text. This fixes those issues.

The solution isn't super clean - it craetes a new function to wrap the
old one (unavoidable, since the articles can be needed for fractions),
and splits the returned string, the strips leading artivles.

Since strings are immutable, this is probably not super efficient. Might
be better to eventually use lists as much as possible, and only create a
string at the end (though the lists will come with their own problems,
so that could turn out to be a wash). In any case, this works for now.
2019-01-29 20:25:38 -05:00
Chris Rogers 0b8e88a325 Fix docs for _initialize_number_data.
This is in support of issues-1959.
2019-01-29 20:03:41 -05:00
Chris Rogers 9ff7fd5452 Fix issues with extractnumber_en_with_text
Issues fixed:
Lists, e.g. "some words one two three" would return (3, "one two three")
Negaitve words were not included in output, e.g. "negative five" would
return (-5, "five").

This is in support of issues-1959.
2019-01-29 19:53:30 -05:00
Chris Rogers b5ffbcc549 Fix edgecase in extractnumber_en_with_text
Any articles (a, an, the) appearing before the number would be included
in the text, e.g. "set a timer for eight minutes" returned:
(8, 'a eight')

This fix clears the number words list if no number words have been
found. Note that articles can't simple be filtered, as they are
often a part of the numebr (e.g. three and a half).

This is in support of issues-1959.
2019-01-28 17:28:27 -05:00
Chris Rogers 12e5fd603a Implement methods useful for extract_duration
Methods implemented include:

extract_number_with_text
extract_numbers_with_text
convert_words_to_numbers
extract_duration

This is in support of issues-1959. This continues the work of
returning the relevant text that corresponds to a number
parsed from a string.
2019-01-28 17:04:12 -05:00
Chris Rogers 5252e710b5 Prevent the conversion of ints to floats>
This is in support of issues-1959. This continues the work of
returning the relevant text that corresponds to a number
parsed from a string.
2019-01-26 18:06:11 -05:00
Chris Rogers 05046c7390 Add ordinal and fraction support.
This is in support of issues-1959. This continues the work of returning
the relevant text that corresponds to a number parsed from a string.
2019-01-26 17:39:56 -05:00
Chris Rogers 49c344c1d7 Return correct text for decimals and fractions
This is in support of issues-1959. This continues the work of returning
the relevant text that corresponds to a number parsed from a string.
2019-01-26 14:36:01 -05:00
Chris Rogers 5a3d809e68 Begin returning text with parsed numbers
This is in support of issues-1959. This begins the work of returning the
relevant text that corresponds to a number parsed from a string. Here's
a sample showing the basic functionality/state of the world (showing
some of the remaining cases to handle)

>>> from mycroft.util.lang.parse_en import *
>>> extractnumber_en_with_text("three hours twenty minutes")
(3, 'three')
>>> extractnumber_en_with_text("twenty minutes")
(20, 'twenty')
>>> extractnumber_en_with_text("twenty five minutes")
(25, 'twenty five')
>>> extractnumber_en_with_text("two hundred twenty five minutes")
(225, 'two hundred twenty five')
>>> extractnumber_en_with_text("three and a half minutes")
(3.5, 'three and a half minutes')
>>> extractnumber_en_with_text("three point five minutes")
(3.5, 'three point five minutes')

====  Tech Notes ====
Checks if the word being parsed is relevant to number parsing. If it is
not, and we have already found number words, we return what we have. If
it is, we add it to a list of words representing the current number
being parsed.

====  Documentation Notes ====
The old implementation of extractnumber_en seems to generally return the
last number in the text. This change will cause the first number to be
returned.
2019-01-26 14:26:00 -05:00
Chris Rogers 6d9447128b Cleanup unnecessary comments/improve docs.
This is part of a refactor of extractnumber_en, with the ultimate
goal of making it easier to maintain and extend (should also
improve perf).  This is in support of issues-1959.
2019-01-25 21:06:29 -05:00
Chris Rogers 8d588743d0 Extract fraction and decimal methods.
This is part of a refactor of extractnumber_en, with the ultimate
goal of making it easier to maintain and extend (should also
improve perf).  This is in support of issues-1959.

All tests (minus extract_duration, which has not yet been implemented)
are passing at this stage.
2019-01-25 21:02:34 -05:00
Chris Rogers 1a176da6b6 Deal with scale numbers and plurarls appropriately.
This is part of a refactor of extractnumber_en, with the ultimate
goal of making it easier to maintain and extend (should also
improve perf).  This is in support of issues-1959.

All tests (minus extract_duration, which has not yet been implemented)
are passing at this stage.
2019-01-25 20:44:59 -05:00
Åke Forslund 8693b71c0e Add some additional info to audiotest
Audiotest now prints the device and samplerate used as well as the commandline used to playback the audio for easier debugging if things doesn't work as intended.
2019-01-25 14:12:10 +01:00
Chris Rogers a6aaaa365a Extract ordinals from extractnumber_en
This is part of a refactor of extractnumber_en, with the ultimate goal
of making it easier to maintain and extend (should also improve perf).
This is in support of issues-1959.
2019-01-23 22:04:02 -05:00
Chris Rogers 8f03f18219 Refactor extractnumber_en - extract constants
Begins a refactor of extractnumber_en, with the ultimate goal of making
it easier to maintain and extend (should also improve perf). This is
in support of issues-1959.
2019-01-23 21:36:56 -05:00
Chris Rogers 3a9f11c67e Add extract_duration skeleton 2019-01-23 18:25:22 -05:00
Chris Rogers 644d75cfc9 Issues-1962 - Revert changes to normalize_en 2019-01-21 18:37:04 -05:00
G3RB3N 876b5393f7 Dev add nl nl (#1906)
* Added nl-nl voc, dialogs and formatter
2019-01-16 13:48:41 +01:00
Åke 4e10339f55
Merge pull request #1912 from aleale99/dev
Updated:
- nice_date()
- pronounce_number()
2019-01-12 13:07:19 +01:00
Åke Forslund 38701a9790 Remove inheritance from object
Inheriting from object isn't necessary in python3.
2019-01-11 09:24:21 +01:00
Åke Forslund ff04af99c9 Move the device finding code into an util function 2019-01-08 08:05:07 +01:00
Ale 8f0e6787f3
Update parse_it.py
correct import
2019-01-05 09:58:21 +01:00
Ale 4270fd4528
Update parse_it.py
imported too early, the functions that use them are not yet ready
2019-01-04 18:39:54 +01:00
Åke c92f92de4f Bugfix/mimic2 negative numbers (#1927)
* Fix mimic2 negative numbers

Make the regex extracting numbers also match negative numbers when preparsing phrases sent to the mimic2 service

* Update pronounce_number to use "minus" for negatives

After discussion in the chat it was suggested to use "minus" for negatives as default.

When scientific notation is used the term "negative " is still used.
2019-01-02 16:36:04 -06:00
Ale a6eff4c750
cleanup 2018-12-31 16:56:54 +01:00
Ale 3d3bccb3bb
Update parse_it.py isFractional_it with
with short_scale =False
2018-12-31 16:45:06 +01:00
Ale f8515fdf79
Update format_it
italian use short_scale=False
2018-12-31 16:34:17 +01:00
Åke 33c735a935 Handle floats when checking year pronounciation (#1916)
* Handle floats when checking year pronounciation

* Corrected typo in docstring
2018-12-27 11:39:44 -06:00
Ale 4b9c410dd4
Update format.py
update pronounce_number_it() to long/short scale and scientific format
2018-12-22 11:13:45 +01:00
Ale 5933d3b6d2
Update format_it.py
update pronounce_number_it() to long/short scale and scientific format
correct some unusuals numbers in  LONG_SCALE_IT
2018-12-22 11:10:34 +01:00
Ale 59a8770eaf
pep8 update format_it.py
just a space
2018-12-19 14:54:04 +01:00
Ale eff7c7e10c
minor update format_it.py
insert  LONG_SCALE_IT  and SHORT_SCALE_IT
2018-12-19 14:37:25 +01:00
Åke Forslund 178319aa68 Handle invalid json when loading log level
Just ignore invalid log files
2018-12-05 22:32:23 +01:00
danielwine 7ec96b0d07 Add format_hu and update format.py along with tests 2018-12-04 15:09:20 +01:00
Kris Gesling 32a3860bce Issue-1877 - fix ordinal followed by one
"Third one" will now return the expected 3 instead of 1.
2018-11-26 09:25:44 +01:00
JarbasAI 60d2905678 feature/extract multiple numbers from text (#1867)
Add extract_numbers() function

The function extracts all numbers from the input string and returns them as a list.
2018-11-19 12:39:59 +01:00
jarbasal fa2b3007a9 improve datetime parsing with long times and a couple
add support for decades, centuries, millemniums
add support for "within the hour", "in a second/minute",
add support for "a couple time_unit" and "a couple of time_unit"
2018-11-17 09:03:41 +01:00
Åke Forslund a67a60a8eb Remove bare except 2018-11-16 12:14:09 +01:00
Åke Forslund 986e70ec9b Add docstrings for play_* methods 2018-11-16 12:03:42 +01:00
jarbasal d9a905c8b1 extract date time improvements 2018-11-07 04:14:21 +00:00
Åke d1298744f1
Merge pull request #1831 from silvia-odwyer/language-error-checking
Language error checking
2018-10-09 17:30:41 +02:00
Åke Forslund 3682391960 Fix final pep8 issues 2018-10-09 16:36:15 +02:00
Silvia O'Dwyer 45eadaab49 Warnings for unsupported languages are now logged. 2018-10-09 16:15:57 +02:00
Åke 4f84ff6a62
Merge pull request #1841 from nielstron/feature/issue-1718
Pronounce large numbers, Bugfix/ issue #1718
2018-10-09 15:57:03 +02:00
Niels Mündler 1b16b4dbaf Include problematic input from #1718 as test
Fix trillion being saved with wrong number (10e10 instead of 10e12)

==== Fixed Issues ====
1718

====  Tech Notes ====
NONE - explain new algorithms in detail, tool changes, etc.

====  Documentation Notes ====
NONE - description of a new feature or notes on behavior changes

==== Localization Notes ====
NONE - point to new strings, language specific functions, etc.

==== Environment Notes ====
NONE - new package requirements, new files being written to disk, etc.

==== Protocol Notes ====
NONE - message types added or changed, new signals, APIs, etc.
2018-10-09 13:18:13 +02:00
Åke Forslund 260f54a386 Move config location definitions to separate file 2018-10-09 11:38:10 +02:00
jarbasal f262bd6f77 Read log level from both user and system config
Resolves issue #1728
2018-10-09 11:37:56 +02:00
Niels Mündler 7c9ae548da Fix pronouncing of fairly large numbers and simplify terms
==== Fixed Issues ====

====  Tech Notes ====
NONE - explain new algorithms in detail, tool changes, etc.

====  Documentation Notes ====
NONE - description of a new feature or notes on behavior changes

==== Localization Notes ====
NONE - point to new strings, language specific functions, etc.

==== Environment Notes ====
NONE - new package requirements, new files being written to disk, etc.

==== Protocol Notes ====
NONE - message types added or changed, new signals, APIs, etc.
2018-10-09 01:12:03 +02:00
Niels Mündler a01f11f30a Fix large numbers in short and long scale, include tests 2018-10-09 00:08:14 +02:00
Niels Mündler 0f8c6d118d Simplify script, remove redundancies 2018-10-08 23:43:51 +02:00
Åke 9f4a3c264d Make the combo lock handle multiple users (#1828)
* Make the combo lock handle multiple users

On the Mark-1 the locking would fail since the first time the lock is
accessed the process is run under root (script checking the enclosure
version). This caused the locking to fail since the normal mycroft
processes got an access error (lock-file owned by root)

This change creates lock-files and sets the permissions to 0o777
if the file doesn't exist so it's accessible for all users

Also added an Apache license header
2018-10-01 14:42:21 -05:00
Steve Penrod edb126ca44 Fixed typo and updated comments on schedule_event 2018-10-01 12:29:28 +02:00
Steve Penrod 1694fb716b Fix date format for today/tomorrow/yesterday
The test for today/tomorrow/yesterday was only looking at the day,
not the month and year.  So on July 14, 2018 it would claim that
the date June 14 2018 and July 14 2020 are all "today".

Now the full date is used in the comparison
2018-10-01 12:28:50 +02:00
Åke 506d7ed843 Add locking when accessing the IdentityManager (#1801)
Adds the mycroft.util.combo_lock ComboLock class for interprocess/Thread
lock.

Loading updated to be more reliable:
- Flush and sync file
- wait 1.2 seconds before load

Split the logic from the locking so the lock can be avoided when calling
update from save or load from get.
2018-09-28 01:26:33 -05:00
Steve Penrod 04745c9c40
Fix now_utc() to return aware datetime
The mycroft.util.time.now_utc() was returning a naive datetime object, potentially causing
issues in skills running on instances that aren't using UTC system-wide.  This didn't impact
Picroft or Mark 1, but Github installs would experience issues with skills such as the Alarm.
2018-09-26 12:04:32 -05:00
Steve Penrod 3c94435f0e Extract_datetime cleanup
Cleaned up a few things noticed during review of Spanish extract_datetime_es() implementation.
2018-09-24 15:59:28 -05:00
Angel Docampo f2c033f1f7 added functions for the spanish parser (#1571)
Added functions for the spanish parser

* Added spanish function calls in parser.py for extractnumber_es
and extract_datetime_es
* Added spanish functions in util/paser_es.py for extractnumber_es
extract_datetime_es and added some missing numbers

Merged in changes from #1804
2018-09-24 05:06:29 -05:00
Åke 25ccc3bed7 Feature/extract datetime update (#1804)
* Fix ambiguous time handling
  In certain cases the ambiguous time handling skipped a day forward. This updates the logic to handle a bit better.
* Adds a test for the ambiguous time
* Remove references to timeStr
   timeStr was never set and the logic that used it would never activate.
* Remove rename of currentDate
* Add extract_datetime parameter default_time
   If a time is not found in the input string the time will be set from the
   datetime/time object passed in as the default_time argument. If None the
   time will be Midnight as previously.
2018-09-24 03:08:39 -05:00
Åke 9bad550c26 Make audiotest wait until playback is complete (#1785)
To reduce unneccessary Output the log level is reduced and the ALSA lib
output is muted unless the --verbose is used.
2018-09-09 01:56:57 -05:00
Åke Forslund 1e27cff708 Fix exception in exception handler
The exception handler in pronounce_number_en would in turn raise an
exception. This fixes that case.
2018-08-30 00:06:19 +02:00
Steve Penrod a3f1179897 Unify vocab/regex/dialog under new 'locale' directory
* Add MycroftSkill.find_resource() that locates a localization resource file
  from either under the old vocab/regex/dialog folder, or under any folder in
  the new 'locale' folder.  The locale folder unifies the three different
  folders and allows arbitrary subfolders underneath it.
* MycroftSkill.speak_dialog() will now speak the entry name if no dialog file
  is found.  Periods are replaced with spaces, so
  ```self.speak_dialog("this.is.a.test.")``` would return "this is a test" if
  no file named this.is.a.test.dialog is found.
* Remove MycroftSkills.vocab_dir value
* Minor edits to several docstrings
2018-08-27 13:28:46 +02:00
Åke Forslund b7e1cb835c Fix broken test
- update test_parse*
- correct the reference in mycroft.util
2018-08-21 11:57:12 +02:00
Steve Penrod 51b60398a3 Remove deprecated extractnumber
Removing the deprecated mycroft.util.parse.extractnumber(), use extract_number() instead.
2018-08-21 04:06:34 -05:00
Michael Nguyen 7b69fb8d46 better pronounciation for 4 digit numbers 2018-08-15 00:31:34 -05:00
Julien Kassar 24a80d60c3 Fix camel case splitting
Signed-off-by: Julien Kassar <github@kassisol.com>
2018-08-12 14:00:28 -04:00
Michael Nguyen 7b54149bcd
Merge pull request #1653 from JarbasAl/feature/pronounce_scientific
Feature/pronounce scientific
2018-07-31 13:04:14 -05:00
Josh Cox 2abb8fa74b Add Ogg123 support (#1678)
This is reimplementation of #1649 which became divergent.

## Description
Adds a Ogg123Service and a play_ogg exactly like Mpg123Service and play_mp3

## How to test
I have a skill for a podcast which does not have an mp3 feed:
https://github.com/joshuacox/skill-GNUworldOrder

## Contributor license agreement signed?
signed by @joshuacox
2018-07-26 22:25:39 -05:00
Steve Penrod 0e61700e13 Allow reference dates with tzinfo (#1695)
* Allow reference dates with tzinfo

The extract_datetime_en() function could cause an exception if the currentData parameter contained tzinfo.
2018-07-19 10:48:39 +02:00
f-e-l-i-x 9e2dc9628e German formatting for Wolfram alpha skill responses in format_de.py (#1669)
Response formatting for German language ordinals depending on cases/prepositions for dates
"am 1. März" -> "am ersten März" (on the first of March)
"der 1. März" -> "der erste März" (the first of March)
"1. März" -> "erster März" (first of March)

Response formatting for mathematical results
"10 ^ 2" -> "10 hoch 2" (ten to the power of two)

Can be tested via the corresponding test_format_de or by using wolfram alpha skill:
"Was ist die Fläche von Canada"
"Wann ist George Washington geboren"
2018-07-19 02:44:33 -05:00
Åke 031daac17b
Merge pull request #1693 from forslund/feature/better-time-parse-and-fix-date-formatting
better time parse and fix date formatting #1681 + #1689
2018-07-18 21:31:51 +02:00
Åke Forslund a14a8b6d7e Remove setup.py's reliance on the mycroft modules
- Adds missing fields, such as description, author and e-mail
- Removes the old setup_base.py from the mycroft.util module
2018-07-18 17:24:26 +02:00
penrods 9bce9557cc Improve pronunciation for nice_time_en()
Switched from "AM" to "a.m.", and "PM" to "p.m".  These are pronounced better
in Mimic, and are also the more normally accepted ways of writing the
abbreviations for ante meridiem and post meridiem (at least according to the
AP and Chicago Style guides).
2018-07-18 13:46:27 +02:00
Steve Penrod 718703c94b Silence Codacy complaints
More import cleanup
2018-07-18 13:46:27 +02:00
Steve Penrod 1029881a78 Minor code cleanup
* Add support for "o'clock" variations
* Clean up imports
* Simplified some overly-complex code
* Normalize line endings
2018-07-18 13:46:27 +02:00
Steve Penrod 3624680698 Enhance extract_datetime(), add time utilities
Many cases that were missed in the unittests for extract_datetime()
from the original source.  Restored those tests and made code
adjustments to support them all.

Also adding the mycroft.util.time module.  This supports:
* mycroft.util.time.default_timezone()
  Returns the user-configured timezone based on location
* mycroft.util.time.now_utc()
  Returns the time in UTC
* mycroft.util.time.now_local()
  Returns the time in the user's timezone
* mycroft.util.time.to_utc()
  Converts to UTC
* mycroft.util.time.to_local()
  Converts to user's timezone

NOTE: Several skills should be updated to use these now.

==== Fixed Issues ====
Several issues for skills regarding parsing of "today"

====  Documentation Notes ====
Note the new module:  mycroft.util.time

==== Localization Notes ====
Localized versions of extract_datetime() likely need to be
updated, as most were based on the original English implementation
2018-07-18 13:46:27 +02:00
JarbasAI 6cf2ed814c feature/allow to pronounce ordinals and very small fractions (#1663)
* allow to pronounce ordinals

* cleanup

* long scale / short scale very small fractions
2018-07-10 02:54:04 -05:00
Åke 1093383443 Fix extraction of 0 in extract_number() (#1673)
0 was not detected as a valid number when checking if the function should proceed to check for fractions.
2018-07-10 02:26:25 -05:00
Åke 622748d7d3 Bugfix/parse corrections (#1670)
* Restore extractdatetime to return False

- Restore extractdatetime to return False if no time was found
- Add tests to make sure this is true
- Add a extract_datetime function to keep coherency with the rest of the functions. (the old extractdatetime still exists for compatibility)
- Update documentation to match

* Minor corrections to docstrings.
2018-07-02 02:44:28 -05:00
JarbasAI fa4173a2d3 fix extract date (#1651)
* Fix errors when spaces are missing "3pm" "5seconds"
* Fix relative times "in 15 minutes" is now from current time not from midnight

Resolves #1650
2018-06-26 11:45:39 +02:00
Carsten Agerskov 5994644085 Feature/nice date (#1635)
* Added nice_date, nice_date_time, nice_year
2018-06-25 17:43:24 +02:00
jarbasal 57a86a7fe6 pep8 2018-06-22 01:03:32 +01:00
jarbasal 1710803bb0 pronounce scientific notation 2018-06-22 01:03:32 +01:00
jarbasal 2f05b0b820 fix extra zero 2018-06-22 01:01:59 +01:00
jarbasal 8637236490 codacy 2018-06-21 19:15:11 +01:00
jarbasal f95c7cf805 py3.4 compatibility 2018-06-21 17:19:54 +01:00
jarbasal ae8e241ffc long scale 2018-06-19 02:37:13 +01:00
jarbasal 5c424fecc1 long scale 2018-06-19 02:18:27 +01:00
jarbasal f83b4f97bb pronounce big numbers 2018-06-19 02:18:27 +01:00
jarbasal b329de593b up 2018-06-19 02:18:25 +01:00
jarbasal 07a5e463d9 long scale and short scale 2018-06-19 02:18:25 +01:00
jarbasal 2fc2fcab08 typo 2018-06-19 02:16:35 +01:00
jarbasal e79dce7afd improve extract_number_en 2018-06-19 02:14:30 +01:00
Åke Forslund 39c4e0aaf1 Add wiki link for long/short scale 2018-06-18 15:46:20 +02:00
jarbasal 7e1fb80cb4 improve extract_number_en
- Support higher numbers, almost unreasonably high!
- Support long scale and short scale
2018-06-18 15:45:14 +02:00
Michael Nguyen d81d321ed0
Merge pull request #1627 from forslund/bugfix/socket-timeout
Fix changed default socket timeout
2018-06-12 16:01:47 -05:00
f-e-l-i-x b239d3dc2f German language support (#1634)
* Add parse and format functions for german
* Add german dialog files
2018-06-12 08:55:21 +02:00
Åke Forslund 6d9ecef63e Fix changed default socket timeout
The default socket timeout was changed when checking the connectivity through connecting to a remote server (8.8.8.8). This has now been updated to only change the timeout for the socket used for the connection.
2018-06-05 17:20:14 +02:00
Matthew D. Scholefield 509162de50 Support tilda in data_dir 2018-05-23 15:03:01 -05:00
Matthew D. Scholefield b0b88bbd62 Remove all references to /opt/mycroft 2018-05-23 08:22:14 +02:00
Åke Forslund 8d81b4473b Fix french "centième" handling 2018-05-02 10:01:04 +02:00
Åke Forslund a2993e4ba6 Remove backwards compatibility with python 2.7 2018-04-27 08:51:47 -05:00
Åke Forslund b200d51d39 Fix test cases under python 3
Lots of minor fixes including, sorting dicts, making ints of strings,
     MagicMock file spec and some other things

A couple of issues in the mycroft-core code base were identified and
fixed. Most notably the incorrect version check for python three when
adding basestring.

Update .travis.yml
2018-04-27 08:50:46 -05:00
Åke Forslund d03eb4ed70 Add Microsoft NCSI as a backup to detect connection
Since on some networks port 53 is blocked the old method failed on
occation. This adds a backup method using standard requests.

Read https://blogs.technet.microsoft.com/networking/2012/12/20/the-network-connection-status-icon/ for more info on the NCSI check.
2018-04-19 11:02:05 -05:00
Matthew D. Scholefield 10bd9a1cf3 Change initial kill to SIGINT
This sends a ctrl+c signal to each process which will allow code to exit properly by handling KeyboardInterrupt
Other notable changes:
 - create_daemon method used to clean up create daemon threads
 - create_echo_function used to reduce code duplication with messagebus
 echo functions
 - wait_for_exit_signal used to wait for ctrl+c (SIGINT)
 - reset_sigint_handler used to ensure SIGINT will raise KeyboardInterrupt
2018-04-11 21:29:10 -05:00
Cakeh 713f48dd66 Fix missing import 2018-02-15 15:46:12 +01:00
Cakeh e7202868e5 Update sv format functions 2018-02-15 13:02:45 +01:00
Kévin C 692877fa07
Fix PEP8 issue 2018-02-15 12:53:51 +01:00
Kévin C f0869dcf31
Merge branch 'dev' into dev 2018-02-15 12:51:45 +01:00
Cakeh 7f733bdf75 Update nice_number_fr, en, pt, it docstring 2018-02-15 12:16:58 +01:00
Augusto Monteiro 2b1e5b2714
Merge pull request #1400 from forslund/feature/swedish-lang-utils
Add format and parsing methods for swedish
2018-02-13 09:38:15 -03:00
Cakeh 85a13309e9 fix codacy issues 2018-02-12 12:21:07 +01:00
Cakeh c1918da9cb Add fr support for ordinal numbers and time qualifiers 2018-02-12 12:02:54 +01:00
Cakeh c45d228d91 Issue-1411 - Leave all nice_number formatting to language 2018-02-12 12:02:04 +01:00
Cakeh 9b5f4dd09c Fixed variable name change 2018-02-08 22:38:50 +01:00
Cakeh fcbf2eae9e Correct issues found by Codacy 2018-02-08 22:20:56 +01:00
Cakeh 3a11f39d7d Issue-1375 - Fix and complete french translation 2018-02-08 21:46:24 +01:00
Åke 708d3ecce1
Merge pull request #1412 from MycroftAI/feature/fix_nice_time
Fix bug in nice_time() for times before noon
2018-02-08 14:08:42 +01:00
Ale 27f974c3fe inserted new italian functions adapted from en
Add new tests for nice_time() and pronounce_number()
2018-02-08 10:58:36 +01:00
penrods 420b21e40e Fix bug in nice_time() for times before noon
Bonehead copy/paste and testing gap left a bug that reported things
like "negative 11 o'clock"
2018-02-08 01:29:05 -06:00
Åke Forslund a11b093e4d Add format and parsing methods for swedish 2018-02-01 15:32:08 +01:00
Åke b2af245554 Add match_one fuzzymatching function (#1372)
match_one finds the closest match for a query in a list or dictionary of
possibilities.
2018-02-01 01:52:14 -06:00
Åke Forslund 044c4c3c0f Fix broken test and codacy warning
- Restore nice_number_it
- Fix codacy warning about overriding str
- Fix octal representation of times in convert_time test
2018-01-31 14:09:06 +01:00
penrods 2811a74adc Remove now-private method 2018-01-31 05:31:16 -06:00
penrods 6dbf1e72d7 Add formater for numbers and time
Add support for:
* mycroft.util.format.nice_time()
* mycroft.util.format.prounce_number()
* implemented unittests for above

Also renamed the helper method convert_number() to
_convert_to_mixed_fraction()
2018-01-31 05:30:01 -06:00
Ale c56b293d3d Update italian parsing methods
Add extract_datetime_it
Add tests for italian methods
2018-01-29 09:47:10 +01:00