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 to get random strings rather than all permutations #29

Closed
etlweather opened this issue Nov 22, 2019 · 4 comments
Closed

How to get random strings rather than all permutations #29

etlweather opened this issue Nov 22, 2019 · 4 comments
Labels
bug Something isn't working question Interrogation on the functioning of the program

Comments

@etlweather
Copy link

This is a very useful tool, thanks for it!

Maybe I'm just doing something wrong, but when I read the Wiki, it seems like I should get "random" strings. But it really looks more like all permutations.

Let's say I have this configuration file:

~[and-amp]
   and
   &

~[name]
   Clifford Woods
   Lorenzo Malvasi
   Ryan Wade

I run the interactive mode and I issue this command:

rule "~[name] ~[and-amp] ~[name] went to town."

The generated text output is a careful permutation of all possibilities, in sequence.

Generated examples:
Text: 'Clifford Woods & Clifford Woods went to town.'
        Entities: []
Text: 'Clifford Woods & Lorenzo Malavasi went to town.'
        Entities: []
Text: 'Clifford Woods & Ryan Wade went to town.'
        Entities: []
Text: 'Clifford Woods and Clifford Woods went to town.'
        Entities: []
Text: 'Clifford Woods and Lorenzo Malavasi went to town.'
        Entities: []
Text: 'Clifford Woods and Ryan Wade went to town.'
        Entities: []
Text: 'Lorenzo Malavasi & Clifford Woods went to town.'
        Entities: []
Text: 'Lorenzo Malavasi & Lorenzo Malavasi went to town.'
        Entities: []
Text: 'Lorenzo Malavasi & Ryan Wade went to town.'
        Entities: []
Text: 'Lorenzo Malavasi and Clifford Woods went to town.'
        Entities: []
Text: 'Lorenzo Malavasi and Lorenzo Malavasi went to town.'
        Entities: []
Text: 'Lorenzo Malavasi and Ryan Wade went to town.'
        Entities: []
Text: 'Ryan Wade & Clifford Woods went to town.'
        Entities: []
Text: 'Ryan Wade & Lorenzo Malavasi went to town.'
        Entities: []
Text: 'Ryan Wade & Ryan Wade went to town.'
        Entities: []
Text: 'Ryan Wade and Clifford Woods went to town.'
        Entities: []
Text: 'Ryan Wade and Lorenzo Malavasi went to town.'
        Entities: []
Text: 'Ryan Wade and Ryan Wade went to town.'
        Entities: []

Also, your animated gif on the homepage of the project show a number after the rule command for the number of generation, but I get an error if I put a number. And your output is different... Probably the Gif was made from an older version prior to 1.6.1.

Anyway, I was wondering if it is possible to get more random than permutation. For example, I would want just one pair of names and sometimes and and other times &. But not all name pairs with and and again all name pairs with &.

@SimGus SimGus added bug Something isn't working question Interrogation on the functioning of the program labels Nov 23, 2019
@SimGus
Copy link
Owner

SimGus commented Nov 23, 2019

Hi,

First of all, I just checked and indeed, there is a problem with the "number" parameter for the rule command of the interactive mode: the program currently crashes if you provide it. I'll fix it as soon as I can.

Now for your question, I am not entirely sure I understand what you're asking.
I guess your question is about the interactive mode, right? When you say you want "more random than permutations", do you mean you would like to have the same kind of output as you show in your question, but with fewer sentences (i.e. not all possible permutations), or am I misunderstanding here?

If so, that is exactly what the "number" parameter of the rule command is meant for: you ask the program to generate this number of sentences given a rule. Basically, rule "[a|b|c]" 2 would generate 2 of the 3 possible sentences (a, b and c), while rule "[a|b|c]" would generate all of them.
As you pointed out though, this feature is currently broken.

If what you meant was that you want to allow duplicates in the generated output, that is not currently implemented as I don't see a use case for that at the moment. If that is the case, could you please tell me more about what you are trying to do, so that I can see if such a feature is worth adding to the program? :)

All that being said, if what you care about is getting the output and you don't really need to have an interactive experience, you can just add your rule as part of an intent in your template file, give this intent a maximum number of examples to generate and run Chatette on it in normal more. In the case you show, you would add this line to your template file:

%[intent](5)
   ~[name] ~[and-amp] ~[name] went to town.

Of course, you can replace the 5 by any number you like and you will get that number of examples generated (without duplicates).
You can use the jsonl or rasamd adapters to get output files which are easy to reuse in other projects (other than as an input to Rasa NLU).

I hope this helps. Feel free to ask questions if you need to!

@etlweather
Copy link
Author

Thanks!

I think the bug on the "number" parameter is really the underlying problem, because I just want, say, 5 examples, but with all my options, the possible combinations is much higher.

So I suppose if I ask for only 5, I will get random ones...

I just tried with the non-interactive and indeed, if I ask for less examples than the total permutation, I get something that's more random looking than just a sequential list of permutations.

So I guess really what thew me off is due to not being able to put a number parameter, I ended up with seeing all permutation so I kind of assumed that if I asked for 3, I would get the top 3 of the total permutation instead of 3 random ones.

@SimGus
Copy link
Owner

SimGus commented Nov 25, 2019

Yes, if you ask for 5 examples, you will get 5 examples taken at random amongst the possible permutations. I will make the documentation clearer about this.

I'll try to have this fixed soon.

@SimGus
Copy link
Owner

SimGus commented Nov 26, 2019

The problem with the rule command is fixed on branch dev. This fix will be included in the next release.

@SimGus SimGus closed this as completed in 941cc51 Dec 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Interrogation on the functioning of the program
Projects
None yet
Development

No branches or pull requests

2 participants