Class: VaderSentimentRuby::EmojiDescriber
- Inherits:
-
Object
- Object
- VaderSentimentRuby::EmojiDescriber
- Defined in:
- lib/vader_sentiment_ruby/emojis_describer.rb
Overview
Replaces emoji characters with their descriptions
Instance Method Summary collapse
-
#call ⇒ String
Text with emojis replaced with descriptions.
-
#initialize(text, emoji_dictionary) ⇒ EmojiDescriber
constructor
A new instance of EmojiDescriber.
Constructor Details
#initialize(text, emoji_dictionary) ⇒ EmojiDescriber
Returns a new instance of EmojiDescriber.
8 9 10 11 12 13 |
# File 'lib/vader_sentiment_ruby/emojis_describer.rb', line 8 def initialize(text, emoji_dictionary) @text_array = text.split('') @emoji_dictionary = emoji_dictionary @text_no_emoji = '' @prev_space = true end |
Instance Method Details
#call ⇒ String
Returns Text with emojis replaced with descriptions.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vader_sentiment_ruby/emojis_describer.rb', line 16 def call @text_array.each do |character| if @emoji_dictionary.keys.include?(character) replace_emoji_with_description(character) else handle_simple_character(character) end end @text_no_emoji end |