Chatette
Chatette copied to clipboard
Can argument be as another aliase?
Question about usage of argument: https://github.com/SimGus/Chatette/wiki/Generation-modifiers#argument
Example was provided in link:
~[greetings$NAME]
Hi $NAME
Hello $NAME!
I would like to use instead of $NAME another alias:
~[NAME]
John
Elvis
Following usage
~[greetings$~[NAME]]
cause SyntaxError: Invalid token
Is there a way to use alias as argument?
Hello!
There is currently no way to do that, though it's a feature I found myself needing as well.
I worked on implementing such a thing (there might still be a branch on this repo with what I tested out), but it was not clear what the best syntax for that would be: I think we'll agree ~[alias$~[some other alias]] is quite hard to read.
I'm still trying to figure out a good syntax, along with other questions (should I allow more than a single alias as an argument? should I allow nested arguments, i.e. an alias as an argument of another alias which is itself an argument to a third one? etc). Once I have an answer, I'll implement it (I'll try to do this shortly).
For the moment, you will need to write your template files in a different way, to avoid the need of an alias argument. There are actually a few (arguably ugly) workaround you can use:
- Use the alias directly instead of an argument:
~[greetings]
Hi ~[NAME]
Hello ~[NAME]!
instead of
~[greetings$NAME]
Hi $NAME
Hello $NAME!
- Break your alias into a beginning and end, and use the alias (or whatever template) in between:
~[greetings-start]
Hi
Hello
~[greetings-end]
!
, how are you?
~[greetings]
~[greetings-start] ~[NAME] ~[greetings-end]
instead of
~[greetings$~[NAME]]
Hi ~[NAME]!
Hi ~[NAME], how are you?
Hello ~[NAME]!
Hello ~[NAME], how are you?
I know that none of those workarounds is fully satisfying, which is why I'm still willing to implement such a feature.
I hope this helps!
Hi @SimGus , thank you a lot for your quick reply!
- Actually in my task I need to use nested alias. I mean structure like this:
~[NAME]
~[FIRST_NAME] ~[SURNAME]
~[FIRST_NAME]
John
Bill
~[SURNAME]
Smith
Brown
- I think it will be also useful to add functionality to support entity as argument as well :
@[NAME]
John
Elvis
@[FIRST_NAME]
John
Bill
@[SURNAME]
Smith
Brown
~[greetings$NAME]
Hi $NAME
Hello $NAME!
So for different intents it can be used as:
%[intent_name]
~[greetings$@[NAME]]
%[intent_first_name]
~[greetings$@[FIRST_NAME]]
%[intent_surname]
~[greetings$@[SURNAME]]
Hi!
I see the kind of use case you have, it's quite similar to what I tried to do a few months back.
I still need to think a little bit more to find a good syntax for this, but once it's done I'll start implementing it. I'll hit you up when I update the code, but I must warn you this is a quite large modification to the current codebase, so this might take time.
Thanks for your feedback :)