Sha256: c4101b6e1c93f3f7149b9eb3c534bc4c9df4455c0d3fa94c74cb16e8f5e5566e

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

require "dogeify_guru/version"
require 'engtagger'

module DogeifyGuru
  # Your code goes here...
  ADJECTIVES = %w(so such very much many).freeze

  def initialize
    @tagger = EngTagger.new
  end

  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

  def adjective(i)
    ADJECTIVES[i % ADJECTIVES.size]
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dogeify_guru-0.1.0 lib/dogeify_guru.rb