Class: VaderSentimentRuby::EmojisDictionaryCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/vader_sentiment_ruby/emojis_dictionary_creator.rb

Overview

Converts emoji lexicon file to a dictionary

Instance Method Summary collapse

Instance Method Details

#callHash

Returns:

  • (Hash)


7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/vader_sentiment_ruby/emojis_dictionary_creator.rb', line 7

def call
  emoji_file = File.open("#{__dir__}/data/emoji_utf8_lexicon.txt").read
  emoji_dict = {}
  lines = emoji_file.strip.split("\n")
  lines.each do |line|
    next unless line

    emoji, description = line.strip.split("\t")[0..1]
    emoji_dict[emoji] = description
  end

  emoji_dict
end