def match (body, keywords)
keywords.each do |keyword|
keyword = keyword.downcase.strip
if body.include?(keyword)
return true
end
end
return false
end
def what_problem?
problem_list = "Electricity ๐ก \n" + "Plumbing ๐ฐ \n" + "Leak ๐ง \n" + "Heating ๐ฅ \n" + "Pests ๐ \n" + "Cleaning Service ๐งน"
sympathy_responses = ["Oh no!", "Sorry to hear that."]
sympathy_responses.sample + " What sort of problem is it? \n" + problem_list
end
ELECTRICITY = ["๐ก", "Electricity ๐ก", "electricity", "electric", "power", "cable", "wire", "Electricity", "electricity ๐ก", "โก๏ธ"]
PLUMBING = ["๐ฐ", "Plumbing ๐ฐ", "plumbing", "clog", "clogged", "drain", "plumber", "plumbing ๐ฐ"]
LEAK = ["๐ง", "Leak ๐ง", "leaking", "leak ๐ง", "leakage", "leak"]
HEATING = ["๐ฅ", "heating", "Heating ๐ฅ", "heating ๐ฅ", "heater", "furnace"]
PESTS = ["๐", "Pests ๐", "pests", "Pests", "exterminate"]
MESSY = ["Just messy ๐งน", "๐งน", "messy", "just messy", "messy house", "dirty", "cleaner", "clutter"]
def pick_problem incoming_text
restate_problem = "Ahh, let me see if I can find someone who can help with your #{incoming_text} problem. \n" +
"Message me your zipcode so I can find you some options nearby!"
if match(incoming_text, ELECTRICITY)
puts "problem is electricity - #{incoming_text}"
return restate_problem
elsif match(incoming_text, PLUMBING)
puts "problem is plumbing - #{incoming_text}"
return restate_problem
elsif match(incoming_text, LEAK)
puts "problem is leak - #{incoming_text}"
return restate_problem
elsif match(incoming_text, HEATING)
puts "problem is heating- #{incoming_text}"
return restate_problem
elsif match(incoming_text, PESTS)
puts "problem is pests - #{incoming_text}"
return restate_problem
elsif match(incoming_text, MESSY)
puts "problem is messy - #{incoming_text}"
return restate_problem
else
return error_response
end
end
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .