exact_data2023/application/services/irony_service.py
2023-06-11 14:49:02 +02:00

21 lines
694 B
Python

from flask import(
request,
jsonify,
Blueprint,
)
from application.functions.irony import irony_prediction, count_predictions, clear_data
irony_service = Blueprint("irony_service", __name__)
@irony_service.route("/get_irony_data", methods=['POST'])
def get_data():
data = request.get_json()
data_clear = clear_data(data)
predicitons = irony_prediction(data_clear)
count_labels = count_predictions(predicitons)
for i in range(0, len(predicitons)):
predicitons[i]['sentence'] = data['sentences'][i]
predicitons[i]['label'] = predicitons[i]['label'][6:]
return jsonify({"predictions": predicitons, "count_labels": count_labels})