forked from alfredfrancis/ai-chatbot-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·48 lines (37 loc) · 1.15 KB
/
manage.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
from flask_script import Manager
from app import app
manager = Manager(app)
@manager.command
def install_nltk_dependencies():
# Downloading necessary NLTK datasets
from nltk import download
download("stopwords")
download("wordnet")
download('averaged_perceptron_tagger')
download('punkt')
print "Done"
@manager.command
def init():
from app.agents.models import Bot
# create default bot
bot = Bot()
bot.name = "default"
bot.save()
print("Created default bot")
# import some default intents
from app.intents.controllers import import_json
json_file = open("examples/default_intents.json", "r+")
stories = import_json(json_file)
print("Imported {} Stories".format(len(stories)))
try:
print("Training models..")
from app.nlu.tasks import train_models
train_models()
print("Training models finished..")
except Exception as e:
e = str(e)
if e == "NO_DATA":
e = "load Data first into mongodb. Reffer Readme."
print("Could not train models..skipping.. (reason: {})".format(e))
if __name__ == "__main__":
manager.run()