You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi I'm having the same problem as in the issue #91 (comment), and I'm using the last version:
Cell In[41], line 3 in deteccion_sentimiento_vader
probas_vader = analyzer_vader.polarity_scores(texto)
File ~\anaconda3\lib\site-packages\vaderSentiment\vaderSentiment.py:273 in polarity_scores
sentiments = self.sentiment_valence(valence, sentitext, item, i, sentiments)
File ~\anaconda3\lib\site-packages\vaderSentiment\vaderSentiment.py:290 in sentiment_valence
if item_lowercase == "no" and words_and_emoticons[i + 1].lower() in self.lexicon:
IndexError: list index out of range
This error appears with a sentence that's ends with "no"
The text was updated successfully, but these errors were encountered:
The above issue might appears to be related to the way it processes the word "no" when it is at the end of a sentence. Specifically, the code tries to access the next word after "no", which does not exist, resulting in an IndexError.
Try out these changes and tell if it works or not?
Preprocess the Text:-
Ensure that the input text does not end with "no". You can add a space or another character to the end of the text to avoid this issue
def preprocess_text(text):
if text.strip().endswith("no"):
text += " "
return text
texto = preprocess_text(texto)
probas_vader = analyzer_vader.polarity_scores(texto)
Try upgrading the vader sentiment library
OR the last case you can do is that, modify the library code to handle the above edge case:-
This involves adding a check to ensure that the index does not go out of range.
Find the vaderSentiment.py file in your site-packages directory and locate the sentiment_valence function. Modify the function to include a check for the length of words_and_emoticons:
def sentiment_valence(self, valence, sentitext, item, i, sentiments):
item_lowercase = item.lower()
if item_lowercase == "no" and i + 1 < len(sentitext.words_and_emoticons) and sentitext.words_and_emoticons[i + 1].lower() in self.lexicon:
#existing logic here
Hi I'm having the same problem as in the issue #91 (comment), and I'm using the last version:
Cell In[41], line 3 in deteccion_sentimiento_vader
probas_vader = analyzer_vader.polarity_scores(texto)
File ~\anaconda3\lib\site-packages\vaderSentiment\vaderSentiment.py:273 in polarity_scores
sentiments = self.sentiment_valence(valence, sentitext, item, i, sentiments)
File ~\anaconda3\lib\site-packages\vaderSentiment\vaderSentiment.py:290 in sentiment_valence
if item_lowercase == "no" and words_and_emoticons[i + 1].lower() in self.lexicon:
IndexError: list index out of range
This error appears with a sentence that's ends with "no"
The text was updated successfully, but these errors were encountered: