Ejemplo n.º 1
0
def train_intent_classifier(intents):
    """
    Train intent classifier model
    :param intents:
    :return:
    """
    X = []
    y = []
    for intent in intents:
        training_data = intent.trainingData
        for example in training_data:
            if example.get("text").strip() == "":
                continue
            X.append(example.get("text"))
            y.append(str(intent.id))

    intent_classifier = EmbeddingIntentClassifier()
    intent_classifier.train(X,y)
Ejemplo n.º 2
0
def train_intent_classifier(intents):
    """
    Train intent classifier model
    :param intents:
    :return:
    """
    X = []
    y = []
    for intent in intents:
        training_data = intent.trainingData
        for example in training_data:
            if example.get("text").strip() == "":
                continue
            X.append(example.get("text"))
            y.append(str(intent.intentId))

    intent_classifier = EmbeddingIntentClassifier()
    intent_classifier.train(X,y)
    intent_classifier.persist(model_dir=app.config["MODELS_DIR"])
Ejemplo n.º 3
0
def train_intent_classifier(intents):
    """
    Train intent classifier model
    :param intents:
    :return:
    """
    X = []
    y = []
    for intent in intents:
        training_data = intent.trainingData
        for example in training_data:
            if example.get("text").strip() == "":
                continue
            X.append(example.get("text"))
            y.append(str(intent.intentId.encode('utf8')))

    intent_classifier = EmbeddingIntentClassifier(use_word_vectors=app.config['USE_WORD_VECTORS'])
    intent_classifier.train(X, y)
    intent_classifier.persist(model_dir=app.config["MODELS_DIR"])