rivescript-python icon indicating copy to clipboard operation
rivescript-python copied to clipboard

extension * and extension array declaration

Open kuznecovavs96 opened this issue 4 years ago • 0 comments

  1. Behavior of ""*

Behavior of "*" has expanded. Now it can mean the absence of characters, as well as prefixes and endings. This is more convenient than combing these options. In regular expressions with an asterisk, '(. +?)' was replaced with '(. *?)' handling different variants. (If an asterisk is written with a word, endings / prefixes may change. There may also be no prefixes. When an asterisk is at the beginning of a line with a space, there may or may not be a word. Asterisk at the end of a line after a space will also work. New functionality is placed into the 'asterisk_processing' function. Tests are added into the 'tests' directory for all cases.

Examples: 1.1.

  • i am from rus*

Are you from Russia? This will work for "I am from Russia" or "I am from RussiaFederation" etc.

1.2.

  • i am from *lia

== brasi => Are you from Brasilia? Are you from big city? This will work for "I am from Brasilia" or "I am from Sicilia" etc.

1.3.

  • hello my * *friend

I love you, my ! This will work for "Hello my best friend" or "Hello my best best friend" or "Hello my best little bestfriend" or "Hello my friend" etc.

  1. [] syntax

When creating arrays, we've added [] syntax. Square brackets mean that a phrase can contain either a word within those brackets, or the absence of a word. We achieved this with a specific regex that replaces square brackets.

Examples:

1.1. ! array hi = hi|[hello] hi|welcome

  • (@hi)

Hi Hi! This will work for "welcome" or "Hello, Hi" etc.

kuznecovavs96 avatar Nov 22 '21 09:11 kuznecovavs96