aenea icon indicating copy to clipboard operation
aenea copied to clipboard

Changing commands in vocabulary.json results in KeyError

Open sweetmandm opened this issue 10 years ago • 1 comments

I think I've fixed this here but it's really hacky: https://github.com/sweetmandm/aenea/commit/d9f3be3394e76f370764d8b796ecb0980bcef685

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>'

sweetmandm avatar Jun 07 '15 15:06 sweetmandm

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.

calmofthestorm avatar Jun 12 '15 04:06 calmofthestorm