So as the code goes as below, I want to be able to make my bot run a second python program when a certain phrase is said. Such as
can you start a webcam bot?
etc. etc. I just need something that calls the python file with the script in it, and like I said, not cause the bot to close.
Code as follows
from chatterbot import ChatBot
from chatterbot.training.trainers import ChatterBotCorpusTrainer
# Create a new instance of a ChatBot
bot = ChatBot("NOSTAW",
storage_adapter="chatterbot.adapters.storage.JsonDatabaseAdapter",
logic_adapters=[
"chatterbot.adapters.logic.MathematicalEvaluation",
"chatterbot.adapters.logic.TimeLogicAdapter",
"chatterbot.adapters.logic.ClosestMatchAdapter"
],
input_adapter="chatterbot.adapters.input.TerminalAdapter",
output_adapter="chatterbot.adapters.output.TerminalAdapter",
database="../SecondaryDataBase.json"
)
bot.set_trainer(ChatterBotCorpusTrainer)
# Train the chat bot with the entire english corpus
bot.train("chatterbot.corpus.english")
print("Type thoughts to bot.")
# The following loop will execute each time the user enters input
while True:
try:
# We pass None to this method because the parameter
# is not used by the TerminalAdapter
bot_input = bot.get_response(None)
# Press ctrl-c or ctrl-d on the keyboard to exit
except (KeyboardInterrupt, EOFError, SystemExit):
break
If anyone could help, please post the code, and some sites I could learn further about this topic. Thank you.
该hack将满足您的需求
os.system("python otherfile.py")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.