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

Add basic functionality for .Flow v2 instruction $aimlMatch #8

Open
nicolasbotanic opened this issue Oct 26, 2018 · 0 comments
Open

Comments

@nicolasbotanic
Copy link
Collaborator

nicolasbotanic commented Oct 26, 2018

This will provide basic pattern matching compatible with AIML 2.0 tag with wildcards * _ ^ #

For more information on AIML 2 see https://pandorabots.github.io/tutorials/wildcards/ and https://gist.github.com/onlurking/f6431e672cfa202c09a7c7cf92ac8a8b

For more information on .Flow v2 pattern matching instructions see https://github.com/SeedVault/flow#intent-matching-instructions

Same as .Flow v2 instruction $regexMatch it should support a 3rd argument with a list of variables to be set with values provided by the wildcards
(see code on /engines/dotflow2/core_functions.py method df2_regexMatch ... also see code on /engines/dotflow2/extensions/chatscript_match.py )

Ex:

{"$aimlMatch": [
    "MY NAME IS * AND I AM * YEARS OLD", 
    "MY NAME IS NICOLÁS AND I AM 40 YEARS OLD", 
    ["name", "age"]
}

This instruction should return True and store in variable "name" the value "NICOLÁS" and in variable "age" with value "40"

Add the code in a new file /engines/dotflow2/extensions/aiml_match.py and add an entry for it into the config file /instance/config_development_example.yml

Do not include any AIML preprocessing or parse any tag inside the pattern tag (like <regex> or any other) (Note in the example I've provided an input text in uppercase and avoiding to use "I'm" to do an exact match)

You can easily test .Flow v2 instructions using the provided console:

BBOT_ENV=development python -m channels.console.app joe testbot 1 nodebug

This will enter to the provided demo bot's console as userid "joe"
You can run any .Flow instruction with the command df2:

Expected result with $aimlMatch:

You: :reset all
Testbot: All user session data erased.
You: :df2 aimlMatch('MY NAME IS * AND I AM * YEARS OLD', 'MY NAME IS NICOLÁS AND I AM 40 YEARS OLD', ['name', 'age'])
Testbot: True
You: :df2 get('name')
Testbot: NICOLÁS
You: :df2 get('age')
Testbot: 40
You: :df2 text('Your are $name and you are $age years old')
Testbot: {'text': 'Your are NICOLÁS and you are 40 years old''}
@nicolasbotanic nicolasbotanic changed the title Add basic support for .Flow v2 instruction $aimlMatch Add basic functionality of .Flow v2 instruction $aimlMatch Oct 30, 2018
@nicolasbotanic nicolasbotanic changed the title Add basic functionality of .Flow v2 instruction $aimlMatch Add basic functionality for .Flow v2 instruction $aimlMatch Oct 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant