class Dogeify
Constants
- ADJECTIVES
- VERSION
Public Class Methods
new()
click to toggle source
# File lib/dogeify.rb, line 7 def initialize @tagger = EngTagger.new end
Public Instance Methods
process(str)
click to toggle source
# File lib/dogeify.rb, line 11 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/dogeify.rb, line 30 def adjective(i) ADJECTIVES[i % ADJECTIVES.size] end