For simple in your case, you can use flair which is based on LSTM model, that takes sequences of words into account for prediction.
1. installing flair
!pip3 install flair
2. code
import flair
flair_sentiment = flair.models.TextClassifier.load('en-sentiment')
sentence1 = 'the movie received critical acclaim'
sentence2 = 'the movie did not attain critical acclaim'
s1 = flair.data.Sentence(sentence1)
flair_sentiment.predict(s1)
s1_sentiment = s1.labels
print(s1_sentiment)
s2 = flair.data.Sentence(sentence2)
flair_sentiment.predict(s2)
s2_sentiment = s2.labels
print(s2_sentiment)
3. result
print(s1_sentiment)
[POSITIVE (0.9995)]
print(s2_sentiment)
[NEGATIVE (0.9985)]
For more details about flair, you can visit this github repo.
sentiment analysis
. They are bothclassification
problems but keep in mind your labels convey different supervision, they are showing if the verb is positive or negative.0.0
forsubjectivity
too? That suggests your code is not set up correctly, and it is not actually parsing anything.