Class: ProgramR::Gender

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

Instance Method Summary collapse

Constructor Details

#initializeGender

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

#executeObject 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

#inspectObject



342
# File 'lib/programr/aiml_elements.rb', line 342

def inspect(); "gender -> #{execute}" end