Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing commands in vocabulary.json results in KeyError #89

Open
sweetmandm opened this issue Jun 7, 2015 · 1 comment
Open

Changing commands in vocabulary.json results in KeyError #89

sweetmandm opened this issue Jun 7, 2015 · 1 comment

Comments

@sweetmandm
Copy link
Contributor

I think I've fixed this here but it's really hacky:
sweetmandm@d9f3be3

Basically, it looks like in most cases a vocabulary should specify {spoken: executed}. However in the case of _vocabulary.py it's expecting {executed: spoken}. If you change vocabulary.json to try to use a different spoken command, the original key is referenced later and breaks on KeyError.

This is what I get when I change vocabulary.json to include "enable vocab <vocabulary>": "enable vocabulary <vocabulary>"

Error loading _vocabulary from C:\NatLink\NatLink\MacroSystem\_vocabulary.py
Traceback (most recent call last):
  File "C:\NatLink\NatLink\MacroSystem\core\natlinkmain.py", line 340, in loadFile
    imp.load_module(modName,fndFile,fndName,fndDesc)
  File "C:\NatLink\NatLink\MacroSystem\_vocabulary.py", line 62, in <module>
    class EnableRule(dragonfly.CompoundRule):
  File "C:\NatLink\NatLink\MacroSystem\_vocabulary.py", line 63, in EnableRule
    spec = command_table['enable vocabulary <vocabulary>']
KeyError: 'enable vocabulary <vocabulary>'
@calmofthestorm
Copy link
Member

Confirmed that this is a problem. Basically make_grammar_commands is set up to be fed into a MappingRule which is how most grammars use it, but a few of the grammars that have deeper responsibilities need more complex rules I would still like to let users redefine easily.

Take a look at https://github.com/dictation-toolbox/aenea/tree/fix_command_table, which I believe should fix this problem, by adding a second helper to make command tables for grammars that want the reverse. Does this work for you?

@djr7C4 Could you take a quick look as well? I want to ensure I'm not going too far down the rabbit hole of reimplementing the work you did on Aliases, and that I'm using them right.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants