0

Vader.py of NLTK is a bit different from the "updated" version of Vader itself (https://github.com/cjhutto/vaderSentiment/blob/master/vaderSentiment/vaderSentiment.py). I have been trying to add the pieces of code that are missing, but I'm having issues with this specific function:

    def __init__(self, lexicon_file="vader_lexicon.zip/vader_lexicon/vader_lexicon.txt", emoji_lexicon="emoji_utf8_lexicon.txt"):
        _this_module_file_path_ = os.path.abspath(getsourcefile(lambda: 0))
        lexicon_full_filepath = os.path.join(os.path.dirname(_this_module_file_path_), lexicon_file)
        with codecs.open(lexicon_full_filepath, encoding='utf-8') as f:
            self.lexicon_full_filepath = f.read()
        self.lexicon = self.make_lex_dict()

        emoji_full_filepath = os.path.join(os.path.dirname(_this_module_file_path_), emoji_lexicon)
        with codecs.open(emoji_full_filepath, encoding='utf-8') as f:
            self.emoji_full_filepath = f.read()
        self.emojis = self.make_emoji_dict()

The error says FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\annas\\PycharmProjects\\fine-grained-sentiment-master\\venv\\lib\\site-packages\\nltk\\sentiment\\vader_lexicon.zip/vader_lexicon/vader_lexicon.txt', but I checked and it's there. What am I doing wrong?

ewokx
  • 2,204
  • 3
  • 14
  • 27
Anna
  • 369
  • 2
  • 10
  • what about changing the ```/``` to ```\\```? – ewokx Aug 31 '20 at 09:23
  • same error unfortunately: FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\annas\\PycharmProjects\\fine-grained-sentiment-master\\venv\\lib\\site-packages\\nltk\\sentiment\\vader_lexicon.zip\\vader_lexicon\\vader_lexicon.txt' – Anna Aug 31 '20 at 09:25
  • not 100% sure but it could be because you are editing a file inside of a zipped archive? It might not be possible to update an existing file. You might need to read the file you want to edit and create a new archive including the file that you edited and the other files that were originally present in the original archive. – john taylor Aug 31 '20 at 13:00
  • you can maybe do something like this https://stackoverflow.com/questions/25738523/how-to-update-one-file-inside-zip-file-using-python – john taylor Aug 31 '20 at 13:03

0 Answers0