From b4b36de45e11330ddabdf6ebac6c56aa2d2bff48 Mon Sep 17 00:00:00 2001 From: Alex Saad Date: Fri, 22 Oct 2021 10:42:46 +0200 Subject: [PATCH 1/2] Convert override scores for neutral sentiment from int to float --- aspect_based_sentiment_analysis/professors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspect_based_sentiment_analysis/professors.py b/aspect_based_sentiment_analysis/professors.py index a50b6bc..2b125b9 100755 --- a/aspect_based_sentiment_analysis/professors.py +++ b/aspect_based_sentiment_analysis/professors.py @@ -47,7 +47,7 @@ def review( if review.is_reference is False: sentiment = Sentiment.neutral - scores = [0, 0, 0] + scores = [0.0, 0.0, 0.0] prediction = PredictedExample.from_example( example, sentiment=sentiment, scores=scores, review=review) From cc9e20511be44d0a1f25f0b743957f46ae97277a Mon Sep 17 00:00:00 2001 From: Alex Saad Date: Fri, 22 Oct 2021 10:44:56 +0200 Subject: [PATCH 2/2] Ensure that scores is an array of floats --- aspect_based_sentiment_analysis/pipelines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspect_based_sentiment_analysis/pipelines.py b/aspect_based_sentiment_analysis/pipelines.py index fdbdd1a..c3c1340 100755 --- a/aspect_based_sentiment_analysis/pipelines.py +++ b/aspect_based_sentiment_analysis/pipelines.py @@ -299,7 +299,7 @@ def postprocess( examples = batch_examples[start:end] # Examples should have the same aspect (an implicit check). aspect, = {e.aspect for e in examples} - scores = np.max([e.scores for e in examples], axis=0) + scores = np.max([e.scores for e in examples], axis=0).astype(float) scores /= np.linalg.norm(scores, ord=1) sentiment_id = np.argmax(scores).astype(int) aspect_document = CompletedSubTask(