Class: ProgramR::Gender
- Inherits:
-
Object
- Object
- ProgramR::Gender
- Defined in:
- lib/programr/aiml_elements.rb
Instance Method Summary collapse
- #add(anObj) ⇒ Object
- #execute ⇒ Object (also: #to_s)
-
#initialize ⇒ Gender
constructor
A new instance of Gender.
- #inspect ⇒ Object
Constructor Details
#initialize ⇒ Gender
Returns a new instance of Gender.
318 |
# File 'lib/programr/aiml_elements.rb', line 318 def initialize; @sentence = [] end |
Instance Method Details
#add(anObj) ⇒ Object
319 |
# File 'lib/programr/aiml_elements.rb', line 319 def add(anObj); @sentence.push(anObj) end |
#execute ⇒ Object Also known as: to_s
320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/programr/aiml_elements.rb', line 320 def execute res = '' @sentence.each{|tocken| res += tocken.to_s } res.gsub(/\b(she|he|him|his|(for|with|on|in|to) her|her)\b/i){ pronoun = $1.downcase if(pronoun == 'she') 'he' elsif(pronoun == 'he') 'she' elsif(pronoun == 'him' || pronoun == 'his') 'her' elsif(pronoun == 'her') 'his' else $2.downcase + ' ' + 'him' end } end |
#inspect ⇒ Object
342 |
# File 'lib/programr/aiml_elements.rb', line 342 def inspect(); "gender -> #{execute}" end |