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(input) click to toggle source
# File lib/dogeify.rb, line 11
def process(input)
  input = input.downcase

  nouns =find_nouns_in_text(input)

  phrases = prefix_nouns_with_adjectives(nouns)

  phrases = end_phrases_with_wow(phrases)

  phrases.join(' ')
end

Private Instance Methods

adjective(i) click to toggle source
# File lib/dogeify.rb, line 25
def adjective(i)
  ADJECTIVES[i % ADJECTIVES.size]
end
end_phrases_with_wow(phrases) click to toggle source
# File lib/dogeify.rb, line 44
def end_phrases_with_wow(phrases)
  phrases << 'wow.'
end
find_nouns_in_text(input) click to toggle source
# File lib/dogeify.rb, line 33
def find_nouns_in_text(input)
  tagged_input = tag_text(input)
  nouns =@tagger.get_nouns(tagged_input).keys
end
prefix_nouns_with_adjectives(nouns) click to toggle source
# File lib/dogeify.rb, line 38
def prefix_nouns_with_adjectives(nouns)
  phrases = nouns.each_with_index.map do |noun, i|
    "#{adjective(i)} #{noun}."
  end
end
tag_text(input) click to toggle source
# File lib/dogeify.rb, line 29
def tag_text(input)
  @tagger.add_tags(input)
end