aichaos / rivescript-python

A RiveScript interpreter for Python. RiveScript is a scripting language for chatterbots.
https://www.rivescript.com
MIT License
157 stars 71 forks source link

Python inside rivescript has no punctuation (email) #139

Closed Nayar closed 4 years ago

Nayar commented 4 years ago
> object is_email python
  return args
< object
bot = RiveScript()
bot.load_file("chatbot.rs")
bot.unicode_punctuation = re.compile(r'[,!?;:]')
bot.sort_replies()

However, when I call the function with an email: me@example.com, the function returns meexamplecom. UTF-8 has been enabled and works in other triggers

kirsle commented 4 years ago

It should work with the code you've given, but I didn't see utf8=True in the RiveScript() constructor.

Python 3.7.6 (default, Jan 30 2020, 09:44:41) 
[GCC 9.2.1 20190827 (Red Hat 9.2.1-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import re
>>> from rivescript import RiveScript
>>> bot = RiveScript(utf8=True)
>>> bot.unicode_punctuation = re.compile(r'[,!?;:]')
>>> bot.stream('+ my email is *\n- I got that as <star>')
>>> bot.sort_replies()
>>> bot.reply('kirsle', 'my email is name@domain.com')
'I got that as name@domain.com'
Nayar commented 4 years ago

yep. works :)