+ 2

Problem with a dictionary based sentiment analysis

Hey, I am trying to create a dictionary based sentiment analysis on the basis of the dictionary, that contains a list of hate words. So the idea that I found in Internet is That when the words from the text are in that dictionary, the function returns -1 or 1 depends on the negative or positive words in the text. But when I run this function the score differs from the -1 or 1. So there is a simple example https://code.sololearn.com/c50cS6c651a3/?ref=app Is there something wrong with the function?

2nd Sep 2022, 10:31 AM
Katja
Katja - avatar
1 Answer
+ 2
I am not sure if I understand the approach of your current code correctly but if you rectify it, it should return a value [0; 1]? edit: Do you want it to return either -1 or 1 or a value [-1; 1]? edit 2: I think, I found the issue: You need to split the input text properly and then use the list of words (not the text) for counting: https://code.sololearn.com/cQ7dxO45WDev/?ref=app
2nd Sep 2022, 1:15 PM
Lisa
Lisa - avatar