Chatterbot: when i use it in Chinese,it don't work in python2

Created on 24 Aug 2017  Ā·  5Comments  Ā·  Source: gunthercox/ChatterBot

when i use it in Chinese,it don't work in python2:

` chatbot.set_trainer(ChatterBotCorpusTrainer)

 chatbot.train(

  "chatterbot.corpus.chinese"

  )`

when i run the code, the error is:

conversations.yml Training: [####################] 100%
greetings.yml Training: [####################] 100%
trivia.yml Training: [####################] 100%

你儽
Traceback (most recent call last):
File "chat.py", line 40, in
print(chatbot.get_response(input(">")))
File "", line 1
你儽

SyntaxError: invalid syntax

i use the latest chatterbot 's version

All 5 comments

@zhouzebiao Could you please provide fallowing details to resolve issue very quickly

  1. version of chatterbot, to know chatterbot version python -m catterbot chatterbot.__version__
  2. corpus data examples
  3. example code snippet that produced erros

Read this documentation to fix python encoding issues http://chatterbot.readthedocs.io/en/stable/encoding.html#how-do-i-fix-python-encoding-errors

This Chinese article may solve your problem, http://blog.just4fun.site/create-a-smart-chat-bot.html, please read the section of "坑", it mention that might be a encoding problem in python2.
Without further ado, you may want to upgrade to python3

I get an error like this when I train Chinese

_sqlalchemy.exc.ProgrammingError: (sqlite3.ProgrammingError) You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). 
It is highly recommended that you instead just switch your application to Unicode strings. 
[SQL: u'SELECT "StatementTable".id AS "StatementTable_id", "StatementTable".text AS "StatementTable_text", "StatementTable".extra_data AS "StatementTable_extra_data" \nFROM "StatementTable" \nWHERE "StatementTable".text = ?\n LIMIT ? OFFSET ?'] [parameters: ('\xe5\x97\xb3\xef\xbc\x8c\xe6\xb8\xa1\xe8\xbe\xb9\xe5\x90\x9b\xef\xbc\x8c\xe7\x9c\x9f\xe5\x96\x9c\xe6\xac\xa2\xe6\x88\x91?', 1, 0)]_

Finally, I install the mongodb and set storage_adapter="chatterbot.storage.MongoDatabaseAdapter", then it works.

I'm closing this off because I _believe_ this was answered? @zhouzebiao feel free to reopen this if you have any further questions on this issue.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings