silentrob / superscript-editor

NOT MAINTAINED - A Editor for authoring chatbots with SuperScript
MIT License
27 stars 16 forks source link

Capturing wildcards clarification. #16

Closed mariusursache closed 9 years ago

mariusursache commented 9 years ago

Need clarification on which wildcards are capturable.

Currently, the current SuperScript docs are a bit confusing on this matter:

image

then

image

And your comment in #14:

Variable length wildcards should not capture data at all. Perhaps displaying undefinedis a bug. This functionality is by design, and is documented in the docs. The workaround is to use (~2) This is also the same for open wildcards \ anything that can be zero is skipped.

Testing the following scenarios with the user input Hello John with the same hello back <cap> reply:

Trigger Input Reply
hello *~2 Hello John Doe Hello back John Doe
hello *~2 Hello John Hello back John
hello *~2 Hello Does not match! See #15
hello (*~2) Hello John Doe Hello back John Doe
hello (*~2) Hello John Hello back John
hello (*~2) Hello Does not match
hello *1 Hello John Hello back john
hello * Hello John Hello back undefined

This is from a previous reply on chatbots.org and makes things clear (also SS works this way now—tested:

Let me know if this is right, and I will update the wiki draft documentation with it.

mariusursache commented 9 years ago

Ah... regarding this:

Only wildcards that are NOT ZERO length can be used to capture input. So wildcards will not capture the text back, but exact length wildcards and optionals will capture the input.

Actually optionals don't capture the input right now. Maybe they should, though... Right now, capturing works for variable-length, fixed-length wildcards, alternates and wordnet.

silentrob commented 9 years ago

Correct. I had an issue trying to capture zero length things because we gobble up the sentence boundary and I don't know if we are capturing the word in question, or the next word - false positive.

Here are the tests for wildcard behaviour. https://github.com/silentrob/superscript/blob/master/test/script.js#L9-L210 And the fixture https://github.com/silentrob/superscript/blob/master/test/fixtures/script/script.ss

Also, relevant Ive added matching interface just a few weeks back and is slightly more powerful, but has yet to be documented.

Min/Max Wildcards *(n-m) Where n is min, and m is max. https://github.com/silentrob/superscript/blob/master/test/script.js#L114-L143

I believe *(n) defaults to exact match behaviour.

mariusursache commented 9 years ago

I am documenting the new behavior in the new documentation. We can close this issue.