-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchatbot.py
65 lines (52 loc) · 2.14 KB
/
chatbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# chatbot.py
# from chatterbot import ChatBot
# from chatterbot.trainers import ListTrainer
import os
# from chatbot_diagnostics import *
questionnaire_loader = lambda name: json_loader("questionnaires/", name)
index = questionnaire_loader("index.json")
# training data is stored in an sqlite3 file, but we don't want user-inputted data to be stored across multiple sessions
# this makes sure the training data is reset every time the bot is loaded - so it doesn't use past data
# os.remove("db.sqlite3")
# CORPUS_FILE = [] # list of supportive responses
# with open("data/bot_responses.txt", "r") as file:
# for line in file.read().split("\n"):
# CORPUS_FILE.append(line.strip())
# chatbot = ChatBot("Brainy", read_only = True)
# chatbot.storage.drop()
# trainer = ListTrainer(chatbot)
# trainer.train(CORPUS_FILE)
# exit_conditions = [":q", "quit", "exit"]
# questionnaires = [PHQ9(filename = "phq-9.json"), GAD7(filename="gad-7.json"), ASRS5(filename="asrs-5.json"),
# ZFOCS(filename="zf-ocs.json"), PCPTSD(filename="pc-ptsd.json", cut_point=4)]
# questionnaires = [PHQ9(filename = "phq-9.json")]
print ("\nHello, I am a chatbot.")
PHQ9(filename = "phq-9.json")
# GAD7(filename = "gad-7.json")
# ASRS5(filename="asrs-5.json")
# ZFOCS(filename="zf-ocs.json")
# PCPTSD(filename="pc-ptsd.json", cut_point=4)
# while True:
# # for quest in questionnaires:
# # # query = input(f"\n{quest}: ")
# # query = input(f"\n{quest}\n")
# # if query in exit_conditions:
# # break
# # break
# # query = input(f"\nklajshdfls: \n")
# # if query in exit_conditions:
# # break
# # else:
# # print(f"Brainy: {chatbot.get_response(query)}\n")
# print ("\nThank you for your responses.")
# break
print ("\nThank you for your responses.")
# general support services to recommend after survey is complete
try:
print("\nIf you are in need of immediate support, please consider services like the following:\n")
with open("data/services.txt", "r") as file:
for line in file.read().split("\n"):
print(line.strip())
except:
FileNotFoundError
# break