Commit Graph

53 Commits (3fea4b1e6fa2d3bfd6f620fcd3e188feb4903780)

Author SHA1 Message Date
Åke Forslund 245a4cb698 Refactor adapt intent data loading routines
- The data loading no longer require the bus
- Add an intent service interface class for better testing
- Update test cases
2019-08-30 13:00:26 +02:00
Åke Forslund f5cdeb76ce Move open_intent_envelope to intent_service 2019-08-30 13:00:26 +02:00
Åke Forslund 466f187eb7 Remove extra LOG statement 2019-03-28 23:29:07 +01:00
Åke d2e6d310ad Run normalized also when raw matches None (#2073)
If no match was found for the non-normalized utterance it would jump to
the exception handler for StopIteration skipping the normalized step
altogether

This changes the next/StopIteration system for list comprehensions
2019-03-28 15:43:28 -05:00
Åke Forslund 381999d5a8 Minor issues
- padatious sentence defaults
- A bit more explanation about the adapt message utterance
2019-03-28 14:50:50 +01:00
Steve Penrod 342c730a97 Normalize utterances before intent handling
Previously Padatious intent matches were performed on non-normalized text, meaning that things like "what's the weather" wouldn't match a Padatious intent but
"what is the weather" would.

The "utterance" in Adapt intent data will still be non-normalized even if the intent match occurred on a normalized utterance. Retaining the existing behavior.

The "intent_failure" data.  In there, "utterance" is always the raw version, "norm_utt" is the normalized one.

Also added better debugging info for intent matching to the log.

Also addresses a rare issue with the old code where the Adapt context could
have been updated even if the Adapt intent wasn't actually invoked due to
a higher Padatious intent match.
2019-03-28 14:48:26 +01:00
Åke dfa714c56d
Merge pull request #2059 from MycroftAI/feature/padatious-priority
Adjust and document Padatious loose fallback priority
2019-03-21 23:38:25 +01:00
Steve Penrod 41773a039a Adjust and document Padatious loose fallback priority
The loose (conf > 0.5) Padatious match was previously occurring as Fallback
priority 99. The AIML fallback at priority 90 would consume lots of
utterances, interferring with many skills.  Now Padatious runs at priority
89.

Additionally, added documentation of the intent and fallback system, including
guidelines for priorities.
2019-03-21 17:16:07 -05:00
Steve Penrod 44f60ec6f3 Change default lang to None, not English
Much of the code used "en-us" as the default value when not specified.
This limited the internationalization potential.  Changing the default
to None and adds the ability to define the default lang code from other
locations in code.  E.g.

```python

from mycroft.util.lang import set_default_lang

set_default_lang("en-us")
print("English date: "+nice_date(dt))

set_default_lang("de-de")
print("German date: "+nice_date(dt))
```

This allows easier localization of Skills by having the framework set the default without any changes necessary by the Skill writers.

Other minor changes:
* Changed the default return value of get_gender*() to None instead of False
2019-03-14 10:57:31 +01:00
Åke Forslund be72733abb Fix context checks
- intent_service
- MycroftSkill
2019-02-26 15:46:12 +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
JarbasAI 29310363d7 fix converse (#1884)
- Fix Exception on non-existing instances crashes the handle_converse_request()
- Report error to intent service
- Cleanup of converse related code.
2018-11-20 14:31:49 +01:00
Åke 83e1ed1d3c
Merge pull request #1815 from JarbasAl/feature/cross_context
feature: allow adapt context across skills
2018-10-08 22:57:04 +02:00
Åke Forslund b761f02dfb Make ContextManager handle cross intent context
This makes a cross context call be treated as one level when calculating the probability. this makes previous contexes not be completely invalidated when a cross context call is sent.
2018-10-08 14:17:52 +02:00
Åke 1ad41ef5ec Workaround for adapt issue with context + one_of (#1789)
Adapt doesn't populate the entry from the one_of correctly from context. To work around the issue intent structure is scanned for empty keys and tries to populate them from entities in __tags__
2018-09-24 15:17:13 -05:00
Åke 64476eb143 Replace emitter/ws with bus (#1757)
Makes the code a bit more understandable
2018-08-21 20:50:50 -05:00
Steve Penrod 609a09bbf3
Allow Padatious to override Adapt (#1713)
Allow a Padatious intent to override Adapt when it is VERY
certain that the utterance is directed at it.  (95% confidence
or greater.)  Right now that only occurs if the intent match
for the given phrase is perfect.

This solves this kind of issue:
* Adapt:  Matching on "Set" and "Alarm"
* Padatious: Handling "is an alarm set"

* Fix logic error for when no Padatious intent
2018-08-03 14:43:17 -05:00
Matthew D. Scholefield dbdd67f965 Add AdaptIntent alias
It is used so that the init argument isn't required and so that it is imported from within the mycroft module
2018-06-01 20:01:25 -05:00
Matthew D. Scholefield 79bf94e48e Speed up intent tests by responding to converse requests 2018-05-14 14:27:37 -05:00
Matthew D. Scholefield fc8424c9ee Make skill ids use skill folder
This is necessary because in Python 3, hash(x) changes every single start of the application. Using the skill folder makes it consistent. In addition, the skill folder makes it easier to debug parts of the application in comparison to using something like an md5sum
2018-05-10 18:52:17 -05:00
Åke Forslund a2993e4ba6 Remove backwards compatibility with python 2.7 2018-04-27 08:51:47 -05:00
InconsolableCellist 7447dbd5ea Simple log output change to prevent confusion (#1497)
Modified the debugging message output after an utterance is complete, to
make it clear that metric data is only sent if opt_in is enabled.

This addresses #1494, which I filed in error, thinking that opt_in was
never checked (due to reading the log output and not knowing it was
checked elsewhere)

==== Fixed Issues ====

==== Localization Notes ====
Slight change to existing, unlocalized text
2018-03-22 13:18:11 -05:00
penrods 2af217bed0 Wrote and cleaned up more docstrings
Made docstrings more consistent with the preferred 'Google Style Docstring'
standard:
http://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html
2018-02-14 17:25:57 -06:00
penrods fa589fead4 Quiet PEP8 2018-02-13 03:05:43 -06:00
penrods c68ad44b1c Internal documentation, typos, remove misleading message
* Made MycroftSkill.remove_event() return a bool, preventing unnecessary/misleading message from being posted by MycroftSkill.cancel_scheduled_event()
* More doc and several minor renames around intent processing
* Several minor typo and doc corrections
2018-02-13 02:54:12 -06:00
Åke Forslund f88acdb60f Fix converse handling
Fallbacks were triggered even if utterance had been handled by converse.
This checks if converse handled the utterance as well.
2018-01-08 18:01:03 -06:00
Åke Forslund 936bd54180 Add a function to build the standard timing report 2018-01-08 18:01:03 -06:00
Åke Forslund baa15b98aa Send timing metrics for various subsystems
====  Tech Notes ====
STT, intent handling, intent fallbacks, skill handlers are now timed and
tied together with a ident (consistent through the chain so the flow from
STT until completion of the skill handler can be follewed.

TTS execution time is also measured, right now this is not tied into the
ident due to the nature of the speech.

The report is always called "timing" and always contain the following
fields:

- id: Identifier grouping the metrics into interactions
- system: Which part (STT, intent service, skill handler, etc)
- start_time: timestamp for when the action started
- time: how long it took to execute the action

The different system adds their own specific information, for example
the intent_service adds the intent_type, i.e. which handler was matched.

==== Protocol Notes ====
mycroft.skills.loaded is sent togheter with skill id and skill name
whenever a skill is loaded. This is used in the intent_service to
convert from id to skill name when reporting
2018-01-08 18:01:03 -06:00
Åke 742558046d Python 2/3 compatibility (#1259)
Add Python 2/3 compatibility

====  Tech Notes ====
This allows the main bus, skills and cli to be run in both python 2.7 and
3.5+.

Mainly trivial changes
- syntax for exceptions
- logic for importing correct Queue module
- .iteritems -> future.utils.iteritems when accessing dicts key value
pairs

* Allow audio service to be run in python 3
* Make speech client work with python 3
* Importing of Queue version dependent
* Exception syntax corrected
* Creating sound buffer is version dependant
- Adapt context use range from builtins
- Use compatible next() instead of .next() when walking the skill
directory

* Make CLI Python 3 Compatible
- Use compatible BytesIO instead of StringsIO
- Open files as text instead of binary
- Make sure integer divisions are used

* Make messagebus send compatible
* Fix failing travis

Re-add future 0.16.0

* Make string checks compatible
* basestring doesn't exist in python 3 so it's imported from the "past"
* Fix latest compatibility issues in speech client
- handle urllib
- handle encoding before calling md5

* Make Api.build_json() python 2/3 compatible
2017-12-18 17:24:21 -06:00
Matthew D. Scholefield 35d057ff9b Add get_response method as a synchronous alternative to converse 2017-12-07 16:11:35 -06:00
gaurav 3a40014122 Issue-1227 Fix arg =[] and ={}
Issue-1227 fixed line length

Issue-1227 fixed pep 8 E124

Issue-1227 fixed formatting
2017-11-22 23:17:16 -06:00
penrods bf61cae4de Add optional skill announcement message
A Skill can now implement the get_intro_message() method, which can return a
string to be spoken the very first time a skill is run.  This is intended to
be an announcement, such as further steps necessary to setup the skill.

Also stopped generation of the Error message when the expected StopIteration
occurs on a intent failure.  This confused new developers and poluted the logs.

Finally, corrected some documentation typos.
2017-11-09 04:34:00 -06:00
Åke Forslund 92f25f2922 Remove Location as a default context word
====  Tech Notes ====
Location was added as a default context keyword when the context manager
was added as an example of how the context feature could be used.
However in the current greedy implementation in can cause some confusion
with lingering context providing incorrect Location.

The feature can still be turned on in configuration if someone wants to
experiment with it.
2017-10-28 03:21:02 -05:00
Åke Forslund 3e878bd59f Replace ConfigurationManger with Configuration 2017-10-26 19:02:32 -04:00
penrods 8f2e5d9498 Change to Apache 2.0 license from GPLv3.0
This commit officially switches the mycroft-core repository from
GPLv3.0 licensing to Apache 2.0.  All dependencies on GPL'ed code
have been removed and we have contacted all previous contributors
with still-existing code in the repository to agree to this change.

Going forward, all contributors will sign a Contributor License
Agreement (CLA) by visiting https://mycroft.ai/cla, then they will
be included in the Mycroft Project's overall Contributor list,
found at: https://github.com/MycroftAI/contributors.  This cleanly
protects the project, the contributor and all who use the technology
to build upon.

Futher discussion can be found at this blog post:
https://mycroft.ai/blog/right-license/

This commit also removes all __author__="" from the code.  These
lines are painful to maintain and the etiquette surrounding their
maintainence is unclear.  Do you remove a name from the list if the
last line of code the wrote gets replaced?  Etc.  Now all
contributors are publicly acknowledged in the aforementioned repo,
and actual authorship is maintained by Github in a much more
effective and elegant way!

Finally, a few references to "Mycroft AI" were changed to the correct
legal entity name "Mycroft AI Inc."

==== Fixed Issues ====
#403 Update License.md and file headers to Apache 2.0
#400 Update LICENSE.md

====  Documentation Notes ====
Deprecated the ScheduledSkill and ScheduledCRUDSkill classes.
These capabilities have been superceded by the more flexible MycroftSkill
class methods schedule_event(), schedule_repeating_event(), update_event(),
and cancel_event().
2017-10-04 01:28:44 -05:00
Matthew D. Scholefield 5e392f34aa Optimize imports
Remove unused imports and group local vs external alphabetically
2017-09-18 16:07:50 -05:00
Matthew D. Scholefield cfdc405da5 Add new LOG class 2017-09-18 13:56:06 -05:00
Åke Forslund 31701fc05d Add more safety around the context manager
====  Tech Notes ====
- Sanity check Message in handle_add_context(), 'word' needs to be a
string before calling into the context manager.
- Sanity check Message in handle_remove_context(), make sure a context
keyword was received before trying to remove.
- Docstrings
- Suppress exceptions while injecting context
2017-09-13 12:44:35 -05:00
Åke Forslund d746a87e34 Added docstring for update_context
Including note about not working on one_of keywords.
2017-08-31 21:34:30 +02:00
Åke Forslund 7022239456 Fix failure when using one_of in intents
==== Fixed Issues ====
#1022

====  Tech Notes ====
When a one_of intent is hit the intent returned by adapt doesn't look like normal require/optional intent parameters. This PR adds a check for entities before trying to accessing them when trying to update context.

This is a temporary workaround while it's determined if the adapt behaviour is correct or should be modified to conform to the normal format. (See issue 66 in the adapt repo), but in any case it's a good sanity check
2017-08-29 09:05:29 +02:00
Jarbas f04f5107e7 small fix (#1005) Rebase issues with converse method
====  Tech Notes  ====
- Use skill id instead of name
- use time() function correctly
2017-08-21 09:18:01 +02:00
Jarbas d661b8d2e7 Add conversational support to skill system
The most recently used skills now have an opportunity to preview all
utterances before they hit the intent system.

==== Tech Notes ====
Skills get a preview in the order of activation -- most recent first --
and if they can consume the utterance or ignore it. If consumed,
processing stops. If ignored, the next most recent skill gets a shot
at it. Finally, if no skill consumes it the intent system takes over,
running as it always has.

Skills remain "active" for 5 minutes after last use.

A skill achieves this by implementing the converse() method, e.g.

def def converse(self, utterances, lang="en-us"):
    if .... :
        return True  # handled, consume utterance
    else:
        return False  # not for this skill, pass it along
2017-08-17 12:09:17 -05:00
Åke Forslund f19ac28a5c Add some safety to the add/remove context methods
====  Tech Notes ====
Invalid context or word arguments will now raise ValueError
2017-08-15 21:27:19 -05:00
Åke Forslund b1082d4b27 Only use latest meaning of each keyword 2017-08-15 21:27:19 -05:00
Åke Forslund 242770aa94 Update context config options
- options grouped under "context"
- added option to activate "greedy" context gathering
2017-08-15 21:27:19 -05:00
Åke Forslund c9b19cb97e Fix remove_context
Also remove debug prints
2017-08-15 21:27:19 -05:00
Åke Forslund 471a8d8360 Add configuration settings for using adapt's context 2017-08-15 21:27:19 -05:00
Åke Forslund b9a054e669 Manual context injection
A skill can inject context to enable and disable intent handlers
automatically depending on previous conversation.
2017-08-15 21:27:19 -05:00
Matthew D. Scholefield a86f0478a4 Add intent fallback system
Also removes multi utterence intent fail. Only makes sense to emit an intent_failure regardless of the amount of intents
2017-08-03 13:49:02 -05:00
Matthew D. Scholefield 90aff68034 Reverting "Add intent fallback system (#899)"
This is because this will break wolfra alpha skill unless they update
skills, but if they update before getting the new version, it will also
break wolfram

This reverts commit 6ca4161335.
2017-07-14 17:53:42 -05:00