Class: Crowsad::Generate_Dangling_Modifiers

Inherits:
Object
  • Object
show all
Defined in:
lib/crowsad.rb

Overview

Generating the dangling modifier datapoint from input vectors.

Class Method Summary collapse

Class Method Details

.formulate_phraseObject



134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/crowsad.rb', line 134

def self.formulate_phrase
  bot_name = File.read("bot_identity/bot_name.txt").strip

  old_data = File.read("data/output/modifier_list.txt")
  
  # Grammar A
  present_action      = File.readlines("dictionary/present_action.txt").sample.strip
  present_preposition = File.readlines("dictionary/present_preposition.txt").sample.strip
  first_object        = File.readlines("dictionary/first_object.txt").sample.strip
  
  # Grammar B
  second_object       = File.readlines("dictionary/second_object.txt").sample.strip
  next_preposition    = File.readlines("dictionary/next_preposition.txt").sample.strip
  next_action         = File.readlines("dictionary/next_action.txt").sample.strip
  
  # Final object
  third_object        = File.readlines("dictionary/third_object.txt").sample.strip
  
  # Inquire
  why_did = " Why did the"
  why_was = " why was the"
  
  grammar_a = "#{present_action}ing #{present_preposition} #{first_object}, "
  grammar_b = "#{second_object} #{next_action}s #{next_preposition} #{third_object}."
  
  inquire   = "#{why_did} #{second_object} #{next_action} #{next_preposition} #{third_object}?"
  for_that  = "For that matter,#{why_was} #{first_object} #{present_action} anything?"
  
  open("data/output/modifier_list.txt", "w") { |f|
    f.puts old_data
    
    f.puts "#{bot_name}: #{grammar_a}#{grammar_b} #{inquire} #{for_that}"
  }
end