def api_label_item(project_id): # noqa: F401 """Label item This request handles the document identifier and the corresponding label. The result is stored in a temp location. If this storage exceeds a certain amount of values, then the model is triggered. The values of the location are passed to the model and the storaged is cleared. This model will run in the background. """ # return the combination of document_id and label. doc_id = request.form.get('doc_id') label = request.form.get('label') is_prior = request.form.get('is_prior', default=False) retrain_model = False if is_prior == "1" else True # [TODO]project_id, paper_i, label, is_prior=None label_instance( project_id, doc_id, label, retrain_model=retrain_model ) response = jsonify({'success': True}) response.headers.add('Access-Control-Allow-Origin', '*') return response
def api_update_classify_instance(project_id, doc_id): """Update classification result.""" doc_id = request.form['doc_id'] label = request.form['label'] move_label_from_labeled_to_pool(project_id, doc_id) label_instance(project_id, doc_id, label, retrain_model=True) response = jsonify({'success': True}) response.headers.add('Access-Control-Allow-Origin', '*') return response
def api_classify_instance(project_id, doc_id): # noqa: F401 """Retrieve classification result. This request handles the document identifier and the corresponding label. The result is stored in a temp location. If this storage exceeds a certain amount of values, then the model is triggered. The values of the location are passed to the model and the storaged is cleared. This model will run in the background. """ # return the combination of document_id and label. doc_id = request.form['doc_id'] label = request.form['label'] label_instance(project_id, doc_id, label, retrain_model=True) response = jsonify({'success': True}) response.headers.add('Access-Control-Allow-Origin', '*') return response