Class: NamePattern
- Inherits:
-
Object
- Object
- NamePattern
- Defined in:
- lib/solvers/namepattern.rb
Instance Method Summary collapse
Instance Method Details
#solve(question) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/solvers/namepattern.rb', line 3 def solve(question) omit = ['What', 'If', 'The'] answer = nil question = question.gsub(/'s/,"") tokens = question.gsub(/[^\w\d\s]/,"").split if tokens.include?("name") for i in (0..tokens.size) if !omit.include?(tokens[i]) && (tokens[i] == tokens[i].to_s.capitalize) answer = tokens[i].downcase end end end answer end |