Coder Social home page Coder Social logo

adapt's People

Contributors

aatchison avatar amcgee7 avatar christopherrogers1991 avatar clusterfudge avatar forslund avatar ivuk avatar kathyreid avatar krisgesling avatar mfussenegger avatar mrshu avatar mrstegeman avatar nallath avatar nathanwarden avatar plnech avatar seanfitzgeraldsc avatar sudo-kid avatar waffle-iron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adapt's Issues

Capitalization and spacing in file paths

I'm attempting to write a tool to move files around using Adapt. I've used the regex intent example as a template and I'm encountering these problems:

Capitalization in input text is not preserved when getting the parsed values from the intent result object. (important for file/folder names)

File paths in the input are also shifted to lowercase and have spaces inserted around the slashes (/) in the file path.

Context manager question.

DISCLAIMER
First of all, i am very bad in programming, so sorry, if my question is stupid. Just close and forget.

I have an issue with context manager: i have an intent of a timer, with minute/second entities. So, when engine matches this intent and frames from previous match are still in context manager, he gets, for example, seconds from current phrase, and minutes from previous. So, is there an easy way to "blacklist" some entities?

TypeError: unorderable types: dict() < dict()

I got this error today :ย 

File "robot.py", line 73, in phase2
result = process(text)
File "robot.py", line 83, in process
for intent in engine.determine_intent(text):
File "/home/pi/Adapt/adapt/src/adapt-parser/adapt/engine.py", line 56, in determine_intent
for result in parser.parse(utterance, N=num_results):
File "/home/pi/Adapt/adapt/src/adapt-parser/adapt/parser.py", line 20, in parse
tagged = self._tagger.tag(utterance.lower())
File "/home/pi/Adapt/adapt/src/adapt-parser/adapt/entity_tagger.py", line 87, in tag
entities = self._sort_and_merge_tags(entities)
File "/home/pi/Adapt/adapt/src/adapt-parser/adapt/entity_tagger.py", line 32, in _sort_and_merge_tags
decorated.sort()

.voc files not using the `'` character

Keywords with a ' in them don't seem to work, they just say searching for...
The text detected from the voice has a '. Perhaps the voc file is stripping these out?

For example. if the keyword is "that's a spy" and I say that phrase, mycroft will say "searching for that's a spy" instead of activating the skill.

I don't know of coarse but one possibility is that whatever is reading in the voc file is changing it from "that's a spy" to "thats a spy"
Or perhaps this is the desired behavior and I need to somehow escape the character?

tokenize voice input?

Hello,

Does the tokenizer work with voice input too? If yes, I would appreciate it if you can guide me to which file/function deals with that.
I'm running Win10 and want to run the code from my Conda Python env

Thanks,

"Hint" Entity requirement

Currently, intent parsers support optional arguments, required arguments, and "at least one of these" requirements. Something that would help clean up the contents of a resolved intent would be the concept of a "hint" in the parser.

A hint would be an optional entity, but would not show up in the parsed intent. It would still be reflected in the intent confidence, so that the parse result would still rank appropriately. Any consumers of Adapt who depend on parse result confidence being the sum of all entity confidences (which is the case today, and not exposed via the engine or IntentParser.validate APIs) could be broken. The seems like an edge case, and folks breaking the abstraction layer should expect nastiness down the road ๐Ÿ˜„

This will require changes to IntentBuilder and IntentParser, as well as corresponding unit tests.

Example:

Imagine an intent for reminders.
IntentBuilder("CreateReminderIntent")
    .requires("DateTime", "ReminderTime") # datetime entity, arrival TBD
    .requires("ReminderContent") # regex entity
    .hint("ReminderKeyword")

Where ReminderKeyword is words/phrases like "reminder", "remind me to", etc.

Suggestion: Register entity takes in lists or a single string of entity_value

In the IntentDeterminationEngine.register_entity(...) registering intent in for loops in the user's code does not look pythonic and interacting that way with the API does not look refined to the end user.

In the following pull request, the iteration of entity_values is internalized the iteration in a simple manner.
It is a minor change, the iteration can also be parallelized, but it can be applied to similar methods to avoid external for loops from becoming the formal way of interacting with the API.

Requirements in setup.py

Thank you for sharing such a nice tool!

Small issue, when installing the code with python setup.py install, not all the requirements come along: setup.py does not refer to the requirements.txt. It would be nicer if it was the case, for packaging.

Releases not being tagged

Looking at the git logs there's been 0.3.1 and 0.3.2 releases but they've not been tagged in git, or at least the tags haven't been pushed to github.

Context + one_of() issue

When a keyword declared with one_of is provided via context the phrase isn't populated and is instead None:

{
    "intent_type": "WeatherIntent",
    "WeatherKeyword": "weather",
    "LocationContext": null,
    "target": null,
    "confidence": 1.0
}

above LocationContext is null/None

When specified as required it works as expected:

{
    "intent_type": "WeatherIntent",
    "WeatherKeyword": "weather",
    "LocationContext": "lizard",
    "target": null,
    "confidence": 0.375
}

here LocationContext is set to the value from context.

For a minimal example see https://gist.github.com/forslund/d98c98816dc90600aed7ad62bfd0f223

Adapt is not parsing unknown entities like number

Take this example.

Home Automation Intent Parser.

Automation Phrases used will be like below:

"Mycroft Set First floor Office Temperature at Twenty"
"Mycroft Switch On Ground floor Kitchen Table Light"
"Mycroft Switch Off Second floor Bathroom Heater"

Automation Intent Parser:

action_keyword = ["Set", "On", "Off"] ---> Require
floor_keyword = ["Ground", "First", "Second"] ---> Require
room_keyword =["Kitchen","Office","Bathroom"] ---> Require
device_keyword =["Heater", "Cooler" "Ceiling", "Table"] ---> Require

Q:- How Intent Parser will handle "Temperature at Twenty" ?
Other two phrases (2 and 3 ) looks ok, as entities are known.
Q:- How Automation Skill will get this number Twenty in json before setting office temperature?

Twenty is not a known entity, Do we need to registered another keyword with intent parser ?
temperature_keyword = ["one", "two"........................."fifty five"] ---> Require / Optional

If we make temperature_keyword optional and Automation Intent Parser detect no Temperature Value in phrase, then it will definitely pass null to Skill in json for temperature value.
Suppose Automation Skill put a check on Temperature value (which is null) and ask again for Temperature,
user replied "set it at Twenty",
In this case do we need another Temperature Intent Parser to parse Temperature Value?
..........................................................................................
Take another example :

A Voice Calculator

"Calculate Five Thousand Divide by Twenty Five"

Calculator Intent Parser
calci_keyword=["Calculate", "Calci"] ------> Require
operation_keyword=["Multiply","Divide","Plus","Minus"] ---> Require

What about "Five Thousand" and " Twenty Five" ?
How Intent Parser will deal with Numbers ?
..........................................................................................

Stock Exchange Intent Parser

"BUY Thousand Share of APPLE Limit two hundred point five"
"SELL Twenty Lot of ORACLE Market"

What about "Thousand" and " two hundred point five" ?
How Intent Parser will deal with Numbers ?

How to implement IntentBuilder() in for loop?

Hi,
I want to implement logic for IntentBuilder() in for loop.
I tried following logic but it didn't work. Also my category & subcategory are stored in array.

list=[['category', ['energy', 'equipment']], ['subcategory', [ 'consumption']],['datetime', ['one month data', 'two month data']], ['greet', ['hi', 'hello', 'hey']]]

e.g.:
weather_intent = IntentBuilder("WeatherIntent")
for i in range(0,len(list)):
weather_intent.optionally(list[i][0])
engine.register_intent_parser(weather_intent) .build()

Please help.

one_of Not Working as Expected

All,

I am trying out a really simple intent parser on Python 3.4. I have defined a simple intent like so:

from adapt.engine import IntentDeterminationEngine
from adapt.intent import IntentBuilder
import json

engine = IntentDeterminationEngine()

engine.register_entity("fastfood", "FoodType")
engine.register_entity("show", "Command")
engine.register_entity("what", "Question")

options = IntentBuilder("OptionsForLunch")\
    .require("Command")\
    .optionally("FoodType")\
    .build()

engine.register_intent_parser(options)

for intent in engine.determine_intent("show fastfood"):
    print(json.dumps(intent, indent=4))

This works just fine:

{
    "Command": "show",
    "intent_type": "OptionsForLunch",
    "confidence": 0.9230769230769231,
    "FoodType": "fastfood",
    "target": null
}

However, I would like to specify that either a Command or a Question are needed for this intent. So I defined the following:

from adapt.engine import IntentDeterminationEngine
from adapt.intent import IntentBuilder
import json

engine = IntentDeterminationEngine()

engine.register_entity("fastfood", "FoodType")
engine.register_entity("show", "Command")
engine.register_entity("what", "Question")

options = IntentBuilder("OptionsForLunch")\
    .one_of("Question", "Command")\
    .optionally("FoodType")\
    .build()

engine.register_intent_parser(options)

for intent in engine.determine_intent("show fastfood"):
    print(json.dumps(intent, indent=4))

This does not print out any matching intents. Am I using the one_of function incorrectly? As far as I can tell, I am using it the same way this test uses it.

Any help would be greatly appreciated, thanks!

Build a Database with Known Entities

It could be cool to have scripts that can build a Database with known entities from Wikidata.

E.g. one could use a SPARQL query like this (can be executed over here: https://query.wikidata.org)

SELECT ?subj ?label (GROUP_CONCAT(DISTINCT(?altLabel); separator=", ") as ?altlabels)
WHERE
{
    ?subj wdt:P31 wd:Q215380 . # subject -> is instance of -> BAND
    SERVICE wikibase:label {
        bd:serviceParam wikibase:language "en" .
        ?subj rdfs:label ?label . # gather label
        ?subj skos:altLabel ?altLabel # and alt labels (seperated by comma)
    }
}
GROUP BY ?subj ?label
LIMIT 100

to select all bands in Wikidata.
Then those entities could be stored in a Trie (as done currently) and the trie nodes could hold the query entity (e.g. Q215380) as well as the subject identifier (for example, Dire Straits are wd:Q50040)

For the intent matching they could be used as additional information for the probabilities (e.g. optional(Adapt.MusicEntity))

Possible bug in context merging in context.py

I'm new to mycroft, and I started to study the codebase (great stuff!). I noticed in Adapt this bug:

adapt/adapt/context.py

Lines 73 to 88 in 7eeadeb

def merge_context(self, tag, metadata):
"""
merge into contextManagerFrame new entity and metadata.
Appends tag as new entity and adds keys in metadata to keys in
self.metadata.
Args:
tag(str): entity to be added to self.entities
metadata(object): metadata containes keys to be added to self.metadata
"""
self.entities.append(tag)
for k in metadata.keys():
if k not in self.metadata:
self.metadata[k] = k

The keys of metadata are used instead of the values in merging. I believe it should be something like

    def merge_context(self, tag, metadata):
        """
        merge into contextManagerFrame new entity and metadata.

        Appends tag as new entity and adds keys in metadata to keys in
        self.metadata.

        Args:
            tag(str): entity to be added to self.entities
            metadata(object): metadata containes keys to be added to self.metadata
        """
        self.entities.append(tag)
        for k, v in metadata.items():
            if k not in self.metadata:
                self.metadata[k] = v

I'm still not very familiar with the codebase, so sorry if I got this wrong.

Approximate string matching support

Is there a built-in mechanism to support fuzzy string matching (within a certain range). For instance, when having a keyword "from", to be able to detect that "form" could be a match, if no exact match is found?

Suggestion: Return multiple values for an entity type

In some cases, it may be useful to retrieve multiple values from an utterance for a given entity type. Using the single_intent_parser.py weather example, a user might enter: "Will the weather rain or snow in Seattle?"

It would be nice to know each WeatherType in the question, perhaps something like this:

{
    "intent_type": "WeatherIntent",
    "confidence": 0.3125,
    "target": null,
    "Location": "Seattle",
    "WeatherType": [
        "rain",
        "snow"
    ]
}

Optional vs Required with Regex

It seems that with working with Regex optional is the way to successfully register where required fails to register intents.

Entity Recognition Issue

Hello, first of all I appreciate tremendously to the Mycroft AI team for dedicating their passion towards opensource AI. I am learning and benefiting so much from this personally.

I am not sure why this is happening but would like to ask if this is a bug internally in Adapt code for Python.

In identical environmental situations (Other code/config same), with a command

"remind me at 5 pm to do something" (after calling wake word)

if I have

reminder_keyword = [
'remind',
'remind me'
]

as reminder keyword entities, I get no intent that satisfies the query above. But then I tried,
"can you remind me at 5 pm to do something" (after calling wake word)
Then it magically returns the correct reminder intent.

So feeling suspicious, I changed my reminder_keyword list to

reminder_keyword = [
'remind',
'remind me',
' remind ',
' remind me '
]

having same words with one that has no space, and another with spaces next to the phrase.
Then as I suspected, it correctly picked up the intent from the same query that it failed before
("remind me at 5 pm to do something"). (nothing changed other than this)

Conclusion :
Why is Adapt returning the correct intent when I added the phrases with spaces on each end?
I think this is a bug related to how Adapt handles spaces internally. For a better developing environment, I believe we shouldn't be required to add additional identical phrases with spaces at the end to make it work as intended.

Thank you.

Tokenizer Internationalization - Spanish

We should test to see if the EnglishTokenizer impl is sufficient for Spanish, and if not, add an additional tokenizer. EnglishTokenizer is based on porter stemmer.

Tokenizer Internationalization - German

We should test to see if the EnglishTokenizer impl is sufficient for German, and if not, add an additional tokenizer. EnglishTokenizer is based on porter stemmer.

Entity matching more than it should

I am experiencing a problem with using regex. I have the following phrase defined in regex/en-us/City.rx

(for|at|in|on) (?P<city_name>.+)

but only when "on Tokyo" is spoken does it return "Tokyo". For the others it returns "for Tokyo", "at Tokyo" or "in Tokyo".

I have seen the problem on rpi3 running on both picroft and Mark 1 images.

I have a cut down version of my code at https://github.com/aussieW/regexProblem which demonstrates the problem.

Overlap of entity literals across different domains

Great project and OSS effort!

More of a feature relevance question on per se the adapt and how it relates to building skills.

If I get this right, in a system with multiple domains (skills in MyCroft terminology), especially dynamically combined at runtime (community skills), there is the likelihood of entity clashing between domains (especially bad if this is verb or keyword entities), potentially leading to wrong denotations.

Looking forward to community views on that and what are designated ways to counter such effects.

Context management

Hi Microft Team!

Awesome library/tool! Until now I have been playing with api.ai, wit.ai, and this kind of online intent parsers, but my plan is to use an offline open source solution to speed the processing time, improve my privacy and don't require an internet connection: "Adapt" looks really great!

I have seen that you have a branch to develop "context" capabilities within Adapt, but there's only a single commit by @clusterfudge and development seems to be halted. Is anybody working on it right now? What kind of data structure did you plan to use? It would be awesome if @clusterfudge could write what his plan was ;)

Many thanks for all your work guys, keep up with the good job!

Aitor

Number support

For an intent parser I created, where you could ask the timetable for a specific bus line, I had to write down the possible numbers for bus lines. But then, typing real numbers from the command line, e.g. when is the next bus sixty-one leaving from home? starts to be annoying.

Would it be possible to build in a support for numbers, somehow? I know of the library inflect that translates integers to text, which would help quite a bit on this. There is also pynum2word.

I think that being able to specify a new sort of entity (i.e. a numerical entity) would be nice. Something where you specify a range, say 1 to 100, and it will then understand both 1 and sixty-one, preferably returning the integer version in the json structure.

Python 3 compatibility

Is Python 3 compatibility planned at this time (or any, for that matter)? If so, do you want to keep the project both Python 2 and Python 3 compatible?

It's really easy to get the examples running on Python 3 currently, it just requires dropping the wsgiref in requirements.txt and swapping the xrange calls.

object is not subscriptable

It looks like there's a small error on 98 of intent.py: https://github.com/MycroftAI/adapt/blame/master/adapt/intent.py#L98

I'm not exactly sure why my current intent is ending up hitting this path (that apparently isn't hit by anything else), but the square brackets on the call to get should be parentheses. Otherwise this happens:

17:00:58.195 - mycroft.skills.intent_service:_adapt_intent_match:453 - ERROR - 'builtin_function_or_method' object is not subscriptable
Traceback (most recent call last):
  File "/home/chris/Code/mycroft-core/mycroft/skills/intent_service.py", line 440, in _adapt_intent_match
    context_manager=self.context_manager)]
  File "/home/chris/Code/mycroft-core/mycroft/skills/intent_service.py", line 437, in <listcomp>
    intents = [i for i in self.engine.determine_intent(
  File "/home/chris/Code/mycroft-core/.venv/lib/python3.6/site-packages/adapt/engine.py", line 123, in determine_intent
    best_intent, tags = self.__best_intent(result, remaining_context)
  File "/home/chris/Code/mycroft-core/.venv/lib/python3.6/site-packages/adapt/engine.py", line 73, in __best_intent
    i, tags = intent.validate_with_tags(parse_result.get('tags') + context_as_entities, parse_result.get('confidence'))
  File "/home/chris/Code/mycroft-core/.venv/lib/python3.6/site-packages/adapt/intent.py", line 167, in validate_with_tags
    best_resolution = resolve_one_of(tags, self.at_least_one)
  File "/home/chris/Code/mycroft-core/.venv/lib/python3.6/site-packages/adapt/intent.py", line 98, in resolve_one_of
    last_end_index = resolution.get[entity_type][-1].get('end_token')
TypeError: 'builtin_function_or_method' object is not subscriptable

PR incoming.

Tokenizer Internationalization - French

We should test to see if the EnglishTokenizer impl is sufficient for French, and if not, add an additional tokenizer. EnglishTokenizer is based on porter stemmer.

Issues with previously registered vocab terms and regex

@HeinzSchmidt was talking earlier about having troubles with properly triggering his shopping skill, so I started testing it. He registered regex that looks like (?P<ShopVerb>.*) (?P<ShopItem>.*) to (?P<ShopLocation>.*), and was trying to use it to match to add onions to my shopping list, with add as the ShopVerb, onions as the ShopItem, and my shopping list as the ShopLocation. However, he was getting back my shopping as the location rather than my shopping list. According to an online regex tester, this is incorrect.

I did some testing, and found out that the problem persists with other syntax - add onions to my shopping mouse, for example, returns my shopping as the location, chopping off mouse at the end. Other similar words such as terminal were also getting cut off, and I realized that mouse and keyboard were registered as vocab by the desktop launcher skill. When I added desktop launcher to the blacklisted skills, the problem with those two words stopped. I did a quick check, and list has been registered as vocab to scheduled skills. I added those to the blacklist, and I started getting my shopping list back again.

This means that there is some issue with Adapt parsing regex when there is another vocab term in the expression. From my testing, it also seems to be localized to be only at the end of sentences, although that may not be true.

Allow "empty" regexes.

engine.register_regex_entity("on (?P<Task>.*)")

works, but

engine.register_regex_entity("(?P<Task>.*)")

results in


Traceback (most recent call last):
  File "/home/traverseda/bin/ti", line 518, in <module>
    for intent in engine.determine_intent(' '.join(sys.argv[1:])):
  File "/usr/lib/python3.5/site-packages/adapt/engine.py", line 57, in determine_intent
    for result in parser.parse(utterance, N=num_results):
  File "/usr/lib/python3.5/site-packages/adapt/parser.py", line 20, in parse
    tagged = self._tagger.tag(utterance.lower())
  File "/usr/lib/python3.5/site-packages/adapt/entity_tagger.py", line 87, in tag
    entities = self._sort_and_merge_tags(entities)
  File "/usr/lib/python3.5/site-packages/adapt/entity_tagger.py", line 32, in _sort_and_merge_tags
    decorated.sort()
TypeError: unorderable types: dict() < dict()


I presume that's intentional, I'm registering a regex instead of just handing it an function/regex-object. But it's still inconvenient.

Why is confidence only 0.375 for the regex example?

Hi guys, I like the framework a lot and plan to use it and contribute to it.
I was playing with the regex example.
and executing the command, it returns a low confidence.

python regex.py "what's the weather like in tokyo"

    "intent_type": "WeatherIntent",
    "WeatherKeyword": "weather",
    "Location": "tokyo",
    "target": null,
    "confidence": 0.375

DomainIntentDeterminationEngine

An alternate implementation (or perhaps just an extension of IntentDeterminationEngine) would allow for specifying a "domain" (reminders, music, etc) when registering vocabulary and intents. The parser would then create candidate parse results for each domain, and yield in order of confidence (like the current implementation). This will help alleviate some issues where entity matches are breaking up wildcard regex entities (mentioning a radio inside a sms message could break the message body).

error in TrieNode.is_prefix

TrieNode.is_prefix always crashes with exception (and all execution paths return False).

Example:

from adapt.tools.text.trie import Trie

trie = Trie()

trie.insert("play", "PlayVerb")
trie.insert("the big bang theory", "Television Show")
trie.insert("the big", "Not a Thing")
trie.insert("barenaked ladies", "Radio Station")

print(trie.root.is_prefix("play"))

produces:

Traceback (most recent call last):
  File "prueba.py", line 10, in <module>
    trie.root.is_prefix("play")
  File "/home/pma/.virtualenvs/mycroft/local/lib/python2.7/site-packages/adapt/tools/text/trie.py", line 80, in is_prefix
    return self.children[iterable[index]].is_prefix(iterable, index + 1)
  File "/home/pma/.virtualenvs/mycroft/local/lib/python2.7/site-packages/adapt/tools/text/trie.py", line 80, in is_prefix
    return self.children[iterable[index]].is_prefix(iterable, index + 1)
  File "/home/pma/.virtualenvs/mycroft/local/lib/python2.7/site-packages/adapt/tools/text/trie.py", line 80, in is_prefix
    return self.children[iterable[index]].is_prefix(iterable, index + 1)
  File "/home/pma/.virtualenvs/mycroft/local/lib/python2.7/site-packages/adapt/tools/text/trie.py", line 80, in is_prefix
    return self.children[iterable[index]].is_prefix(iterable, index + 1)
  File "/home/pma/.virtualenvs/mycroft/local/lib/python2.7/site-packages/adapt/tools/text/trie.py", line 79, in is_prefix
    if iterable[index] in self.children:
IndexError: string index out of range

see related pull request for cause and solution.

When multiple entities match, only one is returned

Hey folks - incredible project here!

I bumped across an issue in my testing and wanted to provide a patch. Am opening an issue to refer to in the commit. If I've overlooked something obvious or if I'm approaching this the wrong way, please point me in the right direction.

When determining intent it's possible that more than one entity will provide a match. Currently, Adapt returns the first match. It should provide a list of all matches.

I ran into this when creating a simple test intent locate my friends. It matched on a command like "Where is Bob?"

engine = IntentDeterminationEngine()

for keyword in ['locate', 'where']:
    engine.register_entity(keyword, "LocateKeyword")


for name in ["Bob", "Smith", "Bob Smith"]:
    engine.register_entity(name, "Person", alias_of='bsmith')

for name in ["Bob", "Jones", "Bob Jones"]:
    engine.register_entity(name, "Person", alias_of='bjones')

for name in ["Mike", "Jones", "Mike Jones"]:
    engine.register_entity(name, "Person", alias_of='mjones')


locate_person_intent = IntentBuilder("LocatePersonIntent")\
    .require("LocateKeyword")\
    .require("Person")\
    .build()

engine.register_intent_parser(locate_person_intent)

Searching for our friend Bob will find the correct intent, but it will only reference one of the two Bobs.

>>> for intent in engine.determine_intent("Where is Bob?", num_results=5):
>>>     print(intent)
{'confidence': 1.0, 'Person': 'bjones', 'target': None, 'intent_type': 'LocatePersonIntent', 'LocateKeyword': 'where'}

I think it would be helpful if it returned a list of all matches:

{'confidence': 1.0, 'Person': ['bjones', 'bsmith'], 'target': None, 'intent_type': 'LocatePersonIntent', 'LocateKeyword': 'where'}

note, this is different than the suggestion in issue #42

watchOS support

Hi,

We're trying to get intent parsing working on watchOS (version 4.0+) with audio as input. Is there somewhere/someone we can be pointed to to help us port Adapt or Padatious to iOS? Or are there plans in the road map to support iOS and watchOS?

Bug causing .optionally regex to not execute, but it works with .required. IntentBuilder

I've observed that when doing a relatively simple regex with the IntentBuilder, the regex doesn't match when I include it with .optionally, but it works with .required.

This is most easily demonstrated with this example code: https://github.com/InconsolableCellist/test-skill/tree/optionally_bug

Steps to reproduce:

  1. Clone repo into mycroft skills directory; make sure you're on the optionally_bug branch
  2. Make sure mycroft loads it
  3. Note line 26 init.py
  4. Enter the following utterance to mycroft's debug console: test a by artist
  5. Change line init.py:26 to use "optionally" instead of "required"
  6. Enter test a by artist again

Expected behavior
The skill prints an INFO message: "Artist found! artist" on both steps 4 AND 6

Observed behavior
The INFO message is only printed on step 4, not on step 6, indicating that the regex doesn't seem to match when you build the intent by optionally including the regex rather than requiring it.

Regex Matches Wonky

How to submit an Issue to a Mycroft repository

  • Running on latest dev branch
  • Running via test runner or live testing same results.

Try to provide steps that we can use to replicate the Issue

On the code https://github.com/btotharye/mycroft-homeassistant/tree/add_climate I have the following regex setup:

(set) (?P<Entity>.*) thermostat to (?P<temp>[0-9]*)

From the message payload I'm getting the below which appears to be finding the temp match group but its not adding it to the actual object it appears so I get key errors when trying to get the temp:

06:56:31.758 - SKILLS - DEBUG - {"type": "mycroft.skill.handler.start", "data": {"name": "HomeAssistantSkill.handle_set_thermostat_intent"}, "context": {"target": null}}
06:56:31.813 - urllib3.connectionpool - DEBUG - http://167.99.144.205:8123 "GET /api/components HTTP/1.1" 200 297
06:56:31.815 - btotharye-home-assistant_btotharye - DEBUG - Entity: ecobee
06:56:31.815 - btotharye-home-assistant_btotharye - DEBUG - This is the message data: {'intent_type': 'btotharye-home-assistant.btotharye:SetThermostatIntent', 'btotharye_home_assistant_btotharyeClimateKeyword': 'thermostat', 'btotharye_home_assistant_btotharyetemp': '75', 'target': None, 'confidence': 0.375, '__tags__': [{'match': 'set', 'key': 'set', 'start_token': 0, 'entities': [{'key': 'set', 'match': 'set', 'data': [['set', 'mycroft_configuration_mycroftaiSetKeyword'], ['set', 'btotharye_home_assistant_btotharyeSetVerb']], 'confidence': 1.0}], 'end_token': 0, 'from_context': False}, {'start_token': 1, 'entities': [{'key': 'ecobee', 'match': 'ecobee', 'data': [['ecobee', 'btotharye_home_assistant_btotharyeEntity']], 'confidence': 0.5}], 'confidence': 0.5, 'end_token': 1, 'match': 'ecobee', 'key': 'ecobee', 'from_context': False}, {'start_token': 2, 'entities': [{'key': 'thermostat', 'match': 'thermostat', 'data': [['thermostat', 'btotharye_home_assistant_btotharyeClimateKeyword']], 'confidence': 1.0}], 'confidence': 1.0, 'end_token': 2, 'match': 'thermostat', 'key': 'thermostat', 'from_context': False}, {'start_token': 4, 'entities': [{'key': '75', 'match': '75', 'data': [['75', 'btotharye_home_assistant_btotharyetemp'], ['75', 'btotharye_home_assistant_btotharyeBrightnessValue']], 'confidence': 0.5}], 'confidence': 0.5, 'end_token': 4, 'match': '75', 'key': '75', 'from_context': False}], 'utterance': 'set ecobee thermostat to 75', 'SetVerb': 'set', 'entity': 'ecobee'}
06:56:31.820 - mycroft.skills.core:wrapper:607 - ERROR - An error occurred while processing a request in Home Assistant Skill
Traceback (most recent call last):
  File "/home/btotharye/Documents/Github/mycroft-core/mycroft/skills/core.py", line 598, in wrapper
    handler(message)
  File "/opt/mycroft/skills/btotharye-home-assistant.btotharye/__init__.py", line 441, in handle_set_thermostat_intent
    temperature = message.data["temp"]
KeyError: 'temp'

I've tried a lot of different ways but nothing ever seems to hit on this but this matches fine in Pythex and other regex verification tools. Let me know if you need anything else. The jenkins log for the build can be found at the below link which is also running the mycroft testrunner:

https://jenkins.btotharye.com/job/home_assistant_skill/108/console

The odd thing about this jenkins build is it corresponds to commit https://github.com/btotharye/mycroft-homeassistant/pull/50/commits/dba3c6975151f2a344b3929c1d3a4eea491481cc and shows the temp reading right but yet I cannot get this working on the same dev setup locally that I use in jenkins.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.