2023-05-27 15:10:30 +02:00
|
|
|
from flask import(
|
|
|
|
request,
|
|
|
|
jsonify,
|
|
|
|
Blueprint,
|
|
|
|
)
|
2023-05-27 16:44:44 +02:00
|
|
|
from application.functions.sentiment import sentiment_prediction, count_predictions
|
2023-05-27 15:10:30 +02:00
|
|
|
|
|
|
|
sentiment_service = Blueprint("sentiment_service", __name__)
|
|
|
|
|
|
|
|
@sentiment_service.route("/get_sentiment_data", methods=['GET'])
|
|
|
|
def get_data():
|
|
|
|
data = request.get_json()
|
2023-05-27 16:44:44 +02:00
|
|
|
predicitons = sentiment_prediction(data['sentences']) #predykcje
|
|
|
|
count_labels = count_predictions(predicitons) #dane do wykresu
|
|
|
|
|
|
|
|
return jsonify({"predictions": predicitons, "count_labels": count_labels})
|