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

Can argument be as another aliase? #44

Open
TatianaParshina opened this issue Apr 20, 2020 · 3 comments
Open

Can argument be as another aliase? #44

TatianaParshina opened this issue Apr 20, 2020 · 3 comments
Labels
improvement Improvement of an existing feature question Interrogation on the functioning of the program

Comments

@TatianaParshina
Copy link

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?

@SimGus
Copy link
Owner

SimGus commented Apr 20, 2020

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!

@SimGus SimGus added improvement Improvement of an existing feature question Interrogation on the functioning of the program labels Apr 20, 2020
@TatianaParshina
Copy link
Author

Hi @SimGus , thank you a lot for your quick reply!

  1. 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
  1. 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]]

@SimGus
Copy link
Owner

SimGus commented Apr 21, 2020

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement of an existing feature question Interrogation on the functioning of the program
Projects
None yet
Development

No branches or pull requests

2 participants