Chatterbot: export_example.py empty output file

Created on 20 Sep 2017  路  6Comments  路  Source: gunthercox/ChatterBot

After running example "export_example.py" I got "my_export.json" in the same directory but it was empty. What could be wrong?

possible bug

All 6 comments

@evgenibers which version of chatterbot are you using? To know chatterbot version try python -m chatterbot --version

I tried on my machine it is working fine.

(env)vkosuri@vkosuri:~/ChatterBot$ python -m chatterbot --version
0.7.6

(env)vkosuri@vkosuri:~/ChatterBot$ python export_example.py 
ai.yml Training: [####################] 100%
botprofile.yml Training: [####################] 100%
computers.yml Training: [####################] 100%
conversations.yml Training: [####################] 100%
drugs.yml Training: [####################] 100%
emotion.yml Training: [####################] 100%
food.yml Training: [####################] 100%
gossip.yml Training: [####################] 100%
greetings.yml Training: [####################] 100%
history.yml Training: [####################] 100%
humor.yml Training: [####################] 100%
literature.yml Training: [####################] 100%
money.yml Training: [####################] 100%
movies.yml Training: [####################] 100%
politics.yml Training: [####################] 100%
psychology.yml Training: [####################] 100%
science.yml Training: [####################] 100%
sports.yml Training: [####################] 100%
trivia.yml Training: [####################] 100%

(env)vkosuri@vkosuri:~/ChatterBot$ ls -lhrt my_export.json 
-rw-rw-r-- 1 developer developer 48K Sep 21 15:24 my_export.json

I am using 0.7.6 version
Python version is 2.7.6
I have installed chatter bot using pip install chatterbot

I also ran into this issue using Chatterbot installed with pip.
Apparently changing json.dumps() to json.dump() on _chatterbot.trainers_ fix this.

I, likewise, ran into this issue.
The change from json.dumps() to json.dump() solved the empty file problem.

However, I got the UnicodeEncodeError: 'ascii' codec can't encode character u'xbf' in position 2: ordinal not in range(128)... when I used Spanish

I solved this by adding decode() in the _generate_export_data() function of chatterbot.trainers, as follows:
result.append([response.text.encode("utf-8"), statement.text.encode("utf-8")])

I'm going to close this ticket off as this issue appears to have been fixed.

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