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

how does one put arbitrary text into a command? #169

Closed
kendonB opened this issue Feb 2, 2017 · 5 comments
Closed

how does one put arbitrary text into a command? #169

kendonB opened this issue Feb 2, 2017 · 5 comments
Labels
Question Questions regarding utilization of Castor

Comments

@kendonB
Copy link
Collaborator

kendonB commented Feb 2, 2017

It would be something like:

"verbatim <text>": R(Text("<text>"), rdescript=""), 

But this produces the error:

Exception: Unknown reference name '<text>' in '<text>'

Question as an aside: would you prefer these types of questions on stackoverflow?

@synkarius
Copy link
Collaborator

synkarius commented Feb 2, 2017 via email

@kendonB
Copy link
Collaborator Author

kendonB commented Feb 2, 2017

I'm not sure how to go about that. The "extras" argument is to the R function? But I'm not sure how to create a Dictation object. Thanks so much for the help!

@synkarius
Copy link
Collaborator

Glad to help. Have a look at this extra in sample.py: https://github.com/synkarius/caster/blob/master/sample.py#L63

That is what you should do with your own rule.

If you still have trouble after looking at that, post your entire rule and I'll help you fix it.

@kendonB
Copy link
Collaborator Author

kendonB commented Feb 3, 2017

Thanks so much for this. I got it to work. The essential elements for future visitors:


def type_function(textnv):
    Text(str(textnv)).execute()    
"type function [<textnv>]":    Function(type_function, extra={'text'})+Key("lparen"),
    }
    extras = [
              Dictation("textnv"),
             ]
    defaults = {"textnv": "", }

@kendonB kendonB closed this as completed Feb 3, 2017
@synkarius
Copy link
Collaborator

Or even more simply:

    "type function [<t>]":     Text("%(t)s"),
}
extras = [
    Dictation("t"),
]
defaults = {
    "t": "",
}

@LexiconCode LexiconCode added the Question Questions regarding utilization of Castor label Mar 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Questions regarding utilization of Castor
Projects
None yet
Development

No branches or pull requests

3 participants