exact_data2023/application/services/irony_service.py

21 lines
694 B
Python
Raw Normal View History

2023-06-10 01:51:01 +02:00
from flask import(
request,
jsonify,
Blueprint,
)
from application.functions.irony import irony_prediction, count_predictions, clear_data
2023-06-10 01:51:01 +02:00
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)
2023-06-10 01:51:01 +02:00
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})