keiffster / program-y

Python 3.x based AIML 2.0 Chatbot interpreter, framework, related programs and knowledge files
https://keiffster.github.io/program-y/
Other
348 stars 138 forks source link

How to prioritize pattern which uses regex? #232

Closed dilyararimovna closed 4 years ago

dilyararimovna commented 4 years ago

Hello!

I have a necessity to prioritize some patterns like:

<pattern><regex pattern="(ALICE|BOB)" /> DO #</pattern>

I want the pattern above be have higher priority when matching than

<pattern># DO #</pattern>

How can I do this? In some AIML tutorials I found info about using $ but in this case it didn't work.

keiffster commented 4 years ago

The $ directive only works with text strings, so you cannot apply it to other tags, however see my response to the you other issue #231. I would remove the regex pattern and replace it with

<pattern>ALICE * DO *</pattern

and

<pattern>BOB * DO *</pattern

If you also have a catch all such as

<pattern>* * DO *</pattern

Then this will come after BOB and ALICE patterns in precendence order

dilyararimovna commented 4 years ago

Thank you for the answers!

Yes, I understood this variant of scripting, I just was wondering if it is possible to make it more compact without copy-pasting=)

Thanks again!

dilyararimovna commented 4 years ago

I am wondering if replicating a lot of rules is slower than using sets?

keiffster commented 4 years ago

It’s a trade off between maintain one or more sets vs using srai tag and reduction so

BOB . -> srai ALICE -> srai

Is simple, but if you have lots of names the

-> srai

Is easier

Regards

Keith 07771 597630

On 12 Sep 2019, at 10:38, Dilyara Baymurzina notifications@github.com wrote:

I am wondering if replicating a lot of rules is slower than using sets?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

dilyararimovna commented 4 years ago

Yes, it's a good idea. Thank you!