Exemplo n.º 1
0
def evaluate_download(id, index):
    task_success, task_value = utils.get_task_result(tasks.evaluate_files, id)
    index = int(index)
    if task_success:
        file_paths = task_value[1]
        return send_file(file_paths[index], as_attachment=True)
    return "Error"
Exemplo n.º 2
0
def get_translation():
    task_id = request.form.get('task_id')
    task_success, task_value = utils.get_task_result(tasks.translate_text, task_id)
    if task_success:
        return {"result": 200, "lines": task_value}
    elif task_success is None:
        return {"result": -1}
    else:
        return {"result": -2}
Exemplo n.º 3
0
def train_test_status():
    if user_utils.is_normal(): return redirect(url_for('index'))

    task_id = request.form.get('task_id')
    task_success, task_value = utils.get_task_result(tasks.test_training,
                                                     task_id)
    if task_success is not None:
        if not task_success:
            return jsonify({"result": -2})
        return jsonify({"result": 200, "test": task_value})
    else:
        return jsonify({"result": -1})
Exemplo n.º 4
0
def get_evaluation():
    task_id = request.form.get('task_id')
    task_success, task_value = utils.get_task_result(tasks.evaluate_files,
                                                     task_id)
    if task_success:
        evaluation_result = task_value[0]
        return jsonify({
            "result": 200,
            "task_id": task_id,
            "evaluation": evaluation_result
        })
    else:
        return jsonify({"result": -1})
Exemplo n.º 5
0
def data_upload_status():
    task_id = request.form.get('task_id')
    task_success, task_value = utils.get_task_result(tasks.process_upload_request, task_id)
    if task_success is not None:
        if not task_success:
            exception_text = task_value if type(task_value) is Exception else None
            Flash.issue("Something went wrong" if exception_text is None else "Something went wrong: {}".format(exception_text), Flash.ERROR)
            return jsonify({ "result": -2 })

        Flash.issue("Corpus successfully uploaded and added to <a href='#your_corpora'>your corpora</a>.",
                    Flash.SUCCESS, markup=True)
        return jsonify({ "result": 200 })
    else:
        return jsonify({ "result": -1 })