Class: DogeifyJgsa
- Inherits:
-
Object
- Object
- DogeifyJgsa
- Defined in:
- lib/dogeify_jgsa.rb,
lib/dogeify_jgsa/version.rb
Constant Summary collapse
- ADJECTIVES =
%w(so such very much many).freeze
- VERSION =
"1.0.0"
Instance Method Summary collapse
-
#initialize ⇒ DogeifyJgsa
constructor
A new instance of DogeifyJgsa.
- #process(str) ⇒ Object
Constructor Details
#initialize ⇒ DogeifyJgsa
Returns a new instance of DogeifyJgsa.
7 8 9 |
# File 'lib/dogeify_jgsa.rb', line 7 def initialize @tagger = EngTagger.new end |
Instance Method Details
#process(str) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dogeify_jgsa.rb', line 11 def process(str) # Convers input to lowercase str.downcase! # Extracts nouns, prefixing each with one of the above adjectives into # sentences of two words. tagged_str = @tagger.(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 space. phrases.join ' ' end |