Exemple #1
0
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))
Exemple #2
0
def build_models():
    """
    Build Intent classification and NER Models
    :return:
    """
    train_models()
    return build_response.sent_ok()
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()
Exemple #5
0
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))
Exemple #6
0
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()