aichaos / rivescript-js

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

how to use russian language? #353

Closed Daniyar111 closed 4 years ago

Daniyar111 commented 4 years ago

Hello, I'm using your library and it's very awesome! But how to use other languages in rive file? I read old issues like Portuguese and Arabic language (I'm using new RiveScript({utf8: true}); and ? sign instead +, but it's also doesn't work ->

  let bot = new RiveScript({utf8: true});
  bot.loadFile('brain.rive').then(brainReady).catch(brainError);

  function brainReady() {
    console.log('Chatbot ready!');
    bot.sortReplies();
  }

  function brainError() {
    console.log('Chatbot error!');
  }

  // output after input
  let reply = await bot.reply('local-user', input);
  console.log(reply)

rive file ->

! version = 2.0

+ *
- скажи что-нибудь

? Данияр
- привет, Данияр

It always make output "скажи что-нибудь". What's the problem? Or I'm doing incorrect?

dcsan commented 4 years ago

unless i'm misreading, you have a catch all right at the start + * it's been awhile since i wrote rivescript but I recall rules work basically from top to bottom, so try putting them the other way around.

I believe there is a sort on the rules, so that more complex matchers would get checked first, but not sure exactly. I was using RS for chinese and we had a ton of problems with any kind of complex matching, in the end it was hard to use without a lot of duplication. I longed for just pure regex support https://github.com/aichaos/rivescript-js/issues?q=is%3Aissue+chinese+is%3Aclosed