2023-06-10 01:51:01 +02:00
|
|
|
from flask import(
|
|
|
|
request,
|
|
|
|
jsonify,
|
|
|
|
Blueprint,
|
|
|
|
)
|
2023-06-11 14:49:02 +02:00
|
|
|
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()
|
2023-06-11 14:49:02 +02:00
|
|
|
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:]
|
|
|
|
|
2023-06-11 14:49:02 +02:00
|
|
|
return jsonify({"predictions": predicitons, "count_labels": count_labels})
|