class Dogeify
Constants
- ADJECTIVES
Public Class Methods
new()
click to toggle source
# File lib/curre.rb, line 6 def initialize @tagger = EngTagger.new end
Public Instance Methods
process(str)
click to toggle source
# File lib/curre.rb, line 10 def process(str) # Convert input to lowercase. str = str.downcase # Extract nouns, prefixing each with one of the # above adjectives into sentences of 2 words. tagged_str = @tagger.add_tags(str) phrases = @tagger.get_nouns(tagged_str).keys phrases = phrases.each_with_index.map do |phrase, i| "#{adjective(i)} #{phrase}." end # End every input with "wow". phrases << 'wow.' # Return a string, separating each sentence # with a space. phrases.join(' ') end
Private Instance Methods
adjective(i)
click to toggle source
# File lib/curre.rb, line 32 def adjective(i) ADJECTIVES[i % ADJECTIVES.size] end