t4ngo / dragonfly

ARCHIVED! - Speech recognition framework allowing powerful Python-based scripting and extension of Dragon NaturallySpeaking (DNS) and Windows Speech Recognition (WSR)
GNU Lesser General Public License v3.0
364 stars 82 forks source link

Mysterious text gets typed in this grammar #70

Closed dylan-chong closed 6 years ago

dylan-chong commented 6 years ago

This following grammar I have below behaves really strangely. As you can see in the spec in the code, I should either be able to say this or this should not get typed, and then some stuff gets printed to the nat link console. This behaviour works as expected.

Another weird thing is that I can say should not get typed and then the text should not get typed gets typed into my host OS. Why??? 😕

import aenea.config
import aenea.configuration

from aenea.proxy_contexts import ProxyAppContext

from dragonfly import (
    AppContext,
    CompoundRule,
    Grammar,
)

def load():
    global git_grammar
    context = aenea.wrappers.AeneaContext(
        ProxyAppContext(
            match='regex',
            app_id='.*',
        ),
        AppContext(title='git'),
    )
    git_grammar = Grammar('git', context=context)

    git_grammar.add_rule(GitRule())
    git_grammar.load()

def unload():
    global git_grammar
    if git_grammar:
        git_grammar.unload()
    git_grammar = None

class GitRule(CompoundRule):
    def __init__(self):
        super(GitRule, self).__init__(
            spec='this [should not get typed]',
            extras=[],
        )

    def _process_recognition(self, node, extras):
        print('_process_recognition', extras)

load()
dylan-chong commented 6 years ago

Wrong repository