Beispiel #1
0
def train():
    model_id = int(request.form["model_id"])
    model = db.session.query(EmbeddingModel).get(
        model_id)  # type: EmbeddingModel
    if model is None:
        raise ValueError("No embedding model found by id {0}".format(model_id))

    separator = request.form["separator"]
    text_column = int(request.form["text_column"])
    tag_column = int(request.form["tag_column"])
    positive_tag = request.form["positive_tag"]
    negative_tag = request.form["negative_tag"]
    uploaded_files = []
    for filename, file_stream in request.files.items():
        file = File()
        file.separator = separator
        file.text_column = text_column
        file.tag_column = tag_column
        file.positive_tag = positive_tag
        file.negative_tag = negative_tag
        uploaded_files.append(file_logic.save(file, file_stream))

    extend_vocabulary = True if request.form[
        "extend_vocabulary"] == "true" else False

    model = emb_model_logic.init_training(model_id,
                                          [file.id for file in uploaded_files],
                                          extend_vocabulary)

    return jsonify(model.to_dict())
Beispiel #2
0
def train():
    net_id = int(request.form["net_id"])
    net = net_logic.get(net_id)  # type: Net

    separator = request.form["separator"]
    text_column = int(request.form["text_column"])
    tag_column = int(request.form["tag_column"])
    positive_tag = request.form["positive_tag"]
    negative_tag = request.form["negative_tag"]
    uploaded_files = []
    for filename, file_stream in request.files.items():
        file = File()
        file.separator = separator
        file.text_column = text_column
        file.tag_column = tag_column
        file.positive_tag = positive_tag
        file.negative_tag = negative_tag
        uploaded_files.append(file_logic.save(file, file_stream))

    extend_vocabulary = True if request.form[
        "extend_vocabulary"] == "true" else False

    net = net_logic.init_training(net.id, [file.id for file in uploaded_files],
                                  extend_vocabulary)

    net_info = net.to_dict(_hide=[])
    return jsonify(net_info)
Beispiel #3
0
def extend():
    vocabulary_id = request.form["vocabulary_id"]

    separator = request.form["file"]["separator"]
    text_column = request.form["file"]["text_column"]
    tag_column = request.form["file"]["tag_column"]
    positive_tag = request.form["file"]["positive_tag"]
    negative_tag = request.form["file"]["negative_tag"]
    uploaded_files = []
    for filename, file_stream in request.files.items():
        file = File()
        file.separator = separator
        file.text_column = text_column
        file.tag_column = tag_column
        file.positive_tag = positive_tag
        file.negative_tag = negative_tag
        uploaded_files.append(file_logic.save(file, file_stream))

    vocabulary = vocabulary_logic.init_extending(
        vocabulary_id, [file.id for file in uploaded_files])
    return jsonify(vocabulary.to_dict())