add irony service
This commit is contained in:
parent
1be5f4b898
commit
85cac92433
@ -7,7 +7,10 @@ def create_app():
|
|||||||
|
|
||||||
from application.services.sentiment_service import sentiment_service
|
from application.services.sentiment_service import sentiment_service
|
||||||
from application.services.errors_service import errors_service
|
from application.services.errors_service import errors_service
|
||||||
|
from application.services.irony_service import irony_service
|
||||||
|
|
||||||
application.register_blueprint(sentiment_service)
|
application.register_blueprint(sentiment_service)
|
||||||
application.register_blueprint(errors_service)
|
application.register_blueprint(errors_service)
|
||||||
|
application.register_blueprint(irony_service)
|
||||||
|
|
||||||
return application
|
return application
|
11
application/functions/irony.py
Normal file
11
application/functions/irony.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
from transformers import pipeline
|
||||||
|
|
||||||
|
pipe = pipeline('text-classification', model="olczig/irony-polish-detection", tokenizer = "olczig/irony-polish-detection")
|
||||||
|
|
||||||
|
def irony_prediction(data):
|
||||||
|
result = pipe(data)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def clear_data(data):
|
||||||
|
#czyszczenie danych
|
||||||
|
return data
|
19
application/services/irony_service.py
Normal file
19
application/services/irony_service.py
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
from flask import(
|
||||||
|
request,
|
||||||
|
jsonify,
|
||||||
|
Blueprint,
|
||||||
|
)
|
||||||
|
from application.functions.irony import irony_prediction
|
||||||
|
|
||||||
|
irony_service = Blueprint("irony_service", __name__)
|
||||||
|
|
||||||
|
@irony_service.route("/get_irony_data", methods=['POST'])
|
||||||
|
def get_data():
|
||||||
|
data = request.get_json()
|
||||||
|
predicitons = irony_prediction(data['sentences'])
|
||||||
|
|
||||||
|
for i in range(0, len(predicitons)):
|
||||||
|
predicitons[i]['sentence'] = data['sentences'][i]
|
||||||
|
predicitons[i]['label'] = predicitons[i]['label'][6:]
|
||||||
|
|
||||||
|
return jsonify({"predictions": predicitons})
|
Loading…
Reference in New Issue
Block a user