aichaos / rivescript-js

A RiveScript interpreter for JavaScript. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com/
MIT License
377 stars 145 forks source link

Using Persian language in rivascript #393

Open hamidreza01 opened 2 years ago

hamidreza01 commented 2 years ago

Hi, do I encounter syntax error while using rivaScript with Persian? Do you know any way to fix it?

hamidreza01 commented 2 years ago

using '?' : image using '+ : image

kirsle commented 2 years ago

Hey @hamidreza01 be sure that UTF-8 mode is enabled and these should parse correctly.

The ? command is a special workaround for if you want a "keyword trigger" where it matches if the word is used anywhere in the user's message (equivalent to a trigger of + [*] word [*] but due to JavaScript Unicode issues with that syntax, the ? command was added).

hamidreza01 commented 2 years ago

Thank you and your wonderful library, do you just have a solution for the following command?

? [*] سلام [*] It does not work when it is in Persian, but it works well when it is in English

kirsle commented 2 years ago

Hey @hamidreza01

I think this command may work:

? سلام

The [*] wildcards surrounding the word aren't necessary, as the ? command basically provides the functionality that the [*] wildcards were trying to provide. So if the word "سلام" is seen anywhere in the user's message the above trigger should (hopefully) match it.

hamidreza01 commented 2 years ago

Yes, fortunately, or perhaps unfortunately, it works. But what should I do if I want it not to work for other sentences?