diff --git a/application/functions/sentiment.py b/application/functions/sentiment.py index 2cb47eb..b264b50 100644 --- a/application/functions/sentiment.py +++ b/application/functions/sentiment.py @@ -14,6 +14,7 @@ def sentiment_prediction(data): def clear_data(data): data = [re.sub(r"[^A-Za-zżźćńółęąśŻŹĆĄŚĘŁÓŃ ']+", r"", i) for i in data['sentences']] + data = [x for x in data if x != ''] data = [i.strip() for i in data] data = [i.lower() for i in data] return data @@ -46,5 +47,5 @@ def scrapp_comments(url): for comment in post['comments_full']: comments.append(comment['comment_text']) all['post'] = text_post - all['comments'] = comments + all['sentences'] = comments return all diff --git a/application/services/sentiment_service.py b/application/services/sentiment_service.py index 9e378a0..11723dc 100644 --- a/application/services/sentiment_service.py +++ b/application/services/sentiment_service.py @@ -10,7 +10,8 @@ sentiment_service = Blueprint("sentiment_service", __name__) @sentiment_service.route("/get_sentiment_data", methods=['POST']) def get_data(): data = request.get_json() - data_clear = clear_data(data) #czyszczenie danych wejsciowych + data_clear = clear_data(data) + print(data_clear) #czyszczenie danych wejsciowych predicitons = sentiment_prediction(data_clear) #predykcje count_labels = count_predictions(predicitons) #dane do wykresu @@ -23,6 +24,10 @@ def get_data(): @sentiment_service.route("/scrapp_comments", methods=['POST']) def scrapp(): - url = request.get_json() - result = scrapp_comments(url['link']) - return result \ No newline at end of file + try: + url = request.get_json() + result = scrapp_comments(url['link']) + result['status'] = True + return result + except: + return jsonify({'status':False}) \ No newline at end of file