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

Vocola does not handle contextual commands correct #1

Open
quintijn opened this issue Jun 25, 2020 · 9 comments
Open

Vocola does not handle contextual commands correct #1

quintijn opened this issue Jun 25, 2020 · 9 comments

Comments

@quintijn
Copy link
Collaborator

When using contextual commands in a Vocola "grammar", rules are not reswitched on when the context re-appears. In fact nog rules are switched on when a specific context is lost.

This should be solved in the Vocola python generating files in C:\DT\Natlink\Vocola\exec\vcl2py (DT being my root directory).

Also see https://www.knowbrainer.com/forums/forum/messageview.cfm?catid=25&threadid=34503&enterthread=y

@quintijn
Copy link
Collaborator Author

I basically found the error, but I did not succeed to delve into the vocola compiler via a debugger in order to see what happens exactly. Also printing info is very difficult as things are wrapped very deep.

@quintijn
Copy link
Collaborator Author

quintijn commented Jun 26, 2020

I put my "manual"fix file in the Natlink\Vocola directory, filename fix_example_contexts.py

The essentials:

    def activate_rule(self, rule, window, status):
        if status:
            try:
                # print("activate rule %s for window: %s"% (rule,window))
                self.activate(rule, window)
            except natlink.BadWindow:
                pass
        else:
            # print('deactivate rule %s for window %s'% (rule, window))
            self.deactivate(rule, noError=1)


    def gotBegin(self,moduleInfo):
        self.firstWord = 0
        # Return if wrong application
        window = matchWindow(moduleInfo,'brave','')
        if not window: return None
        # Return if same window and title as before
        if moduleInfo == self.currentModule: return None
        self.currentModule = moduleInfo



        title = moduleInfo[1].lower()
        for titlepart, rule in [('knowbrainer', 'sequence_set2'), ('faunabescherming', 'sequence_set3')]:
            status = title.find(titlepart) >= 0
            if status:
                self.activate_rule(rule, moduleInfo[2], True)
                print('set rule %s (%s)'% (rule, titlepart))
                break
        else:
            print('set default rule sequence')
            self.activate_rule('sequence', moduleInfo[2], True)

So a simplified activate_rule function, and an adapted gotBegin function, as the activate_rule (and deactivate_rule) of natlinkutils already keeps the bookkeeping.
Note a smarter way to go through the contexts in example above, falling back on the default one if none of the special contexts meet the requirements.

The essentials in the .vcl file are, giving those two extra contexts (apart from the default one):

KnowBrainer:
    knowbrainer test = MSG("context knowbrainer");
    
Faunabescherming:
    faunabescherming test een = MSG("context aaZZaunabescherming");
    faunabescherming test twee = MSG("context faunabescherming twee");

@quintijn
Copy link
Collaborator Author

@LexiconCode LexiconCode transferred this issue from dictation-toolbox/natlink Aug 9, 2020
quintijn pushed a commit that referenced this issue Jan 21, 2021
Merge pull request #5 from dougransom/master
@mdbridge
Copy link

mdbridge commented Jan 4, 2022

I was able to reproduce this with the following file:

KnowBrainer:

is this KnowBrainer = MsgBoxConfirm("absolutely", 64, "Debug info");

:

is this chrome = MsgBoxConfirm("chrome is here", 64, "Debug info");

When I switch to a different tab, the Vocola grammar file deactivates just the rule for KnowBrainer but somehow that also stops the rule for the global context as well. This appears to be a Dragon bug.

Adding debugging to NatLink code shows it isn't doing anything funny -- its state mirrors what Vocola thinks it should be.

@mdbridge
Copy link

fixed in version 2.9

@quintijn
Copy link
Collaborator Author

quintijn commented Jan 1, 2024

Hi Mark, I now see, that I noticed this problem long time ago. Forgot about this. You now say "fixed in version 2.9", but I see no changes in the github source code, and no new pip version. Could we have contact about this, and preferably with Doug Ransom too, as he recently streamlined the release on pip procedure.

Thanks, Quintijn

@quintijn
Copy link
Collaborator Author

quintijn commented Jan 1, 2024

BTW, on my computer the contextual commands work well. I really don't know what might be the cause of them not functioning for other users!

@mdbridge
Copy link

mdbridge commented Feb 5, 2024

version 2.9 is currently on a branch, dragonfly. I will merge it into master once I have released 2.8.8

@mdbridge
Copy link

mdbridge commented Feb 5, 2024

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