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))
def build_models(): """ Build Intent classification and NER Models :return: """ train_models() return build_response.sent_ok()
def intial_training(): 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))
def delete_intent(id): """ Delete a intent :param id: :return: """ Intent.objects.get(id=ObjectId(id)).delete() try: train_models() except BaseException: pass # remove NER model for the deleted stoy try: os.remove("{}/{}.model".format(app.config["MODELS_DIR"], id)) except OSError: pass return build_response.sent_ok()