Sha256: 8ef64cf3db2b461b47534673f697c7225b49a02cd1e6d37d4d43925371aeaa0c

Contents?: true

Size: 836 Bytes

Versions: 1

Compression:

Stored size: 836 Bytes

Contents

require "dogeify/version"
require 'engtagger'
require 'pry'

class Dogeify
  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)
    #binding.pry
    phrases = @tagger.get_nouns(tagged_str).keys
    phrases = phrases.each_with_index.map do |phrase, i|
      "#{adjective(i)} #{phrase}."
    end
    #binding.pry
    # End every input with "wow".
    phrases << 'wow.'
    #binding.pry
    # 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_dere-1.0.1 lib/dogeify.rb