class VaderSentimentRuby::LexiconDictionaryCreator

Converts lexicon file to a dictionary

Public Instance Methods

call() click to toggle source

@return [Hash]

# File lib/vader_sentiment_ruby/lexicon_dictionary_creator.rb, line 7
def call
  lexicon_file = File.open("#{__dir__}/data/vader_lexicon.txt").read
  lex_dict = {}
  lines = lexicon_file.strip.split("\n")
  lines.each do |line|
    next unless line

    word, measure = line.strip.split("\t")[0..1]
    lex_dict[word] = measure.to_f
  end

  lex_dict
end