I am using chatterbot module to create a chatbot using python. I want to train the corpus using json file instead of yaml file which is default in chatterbot.
Below is my code:
`
from chatterbot import ChatBot
from chatterbot.trainers import ChatterBotCorpusTrainer
import os
I am using chatterbot module to create a chatbot using python. I want to train the corpus using json file instead of yaml file which is default in chatterbot. Below is my code: ` from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer import os
filepath = "C:/Personal_Project/myPersonalExplore/DataRepositories/" bot = ChatBot('Pinaki', storage_adapter='chatterbot.storage.SQLStorageAdapter', database_uri='sqlite:///database.sqlite3' )
trainer = ChatterBotCorpusTrainer(bot)
for file in os.listdir(filepath): data = open(filepath + file, encoding="utf8").readlines() trainer.train(data)
while True: try: bot_input = bot.get_response(input()) print(bot_input)
When I ran the code, below error message displayed: "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\python.exe" C:/Personal_Project/myPersonalExplore/firstSample.py [nltk_data] Downloading package stopwords to [nltk_data] C:\Users\jprasapi\AppData\Roaming\nltk_data... [nltk_data] Package stopwords is already up-to-date! [nltk_data] Downloading package averaged_perceptron_tagger to [nltk_data] C:\Users\jprasapi\AppData\Roaming\nltk_data... [nltk_data] Package averaged_perceptron_tagger is already up-to- [nltk_data] date! Traceback (most recent call last): File "C:/Personal_Project/myPersonalExplore/firstSample.py", line 16, in
trainer.train(data)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\chatterbot\trainers.py", line 136, in train
data_file_paths.extend(list_corpus_files(corpus_path))
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\chatterbot\corpus.py", line 45, in list_corpus_files
corpus_path = get_file_path(dotted_path, extension=CORPUS_EXTENSION)
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\site-packages\chatterbot\corpus.py", line 20, in get_file_path
parts = dotted_path.split('.')
AttributeError: 'list' object has no attribute 'split'
Process finished with exit code 1 How can I create a corpus trainer out of texts stored in JSON files ? Any help is much appreciated.