importListexposing(map,map2,filter,foldl,member)importStringexposing(words,replace,toUpper)importTupleexposing(first,pair,second)lowerPositives=["are","can","could","did","do","had","has","have","is","might","must","should","was","were","would"]lowerNegatives=["aren't","can't","couldn't","didn't","don't","hadn't","hasn't","haven't","isn't","might not","mustn't","shouldn't","wasn't","weren't","wouldn't"]upperPositives=maptoUpperlowerPositivesupperNegatives=maptoUpperlowerNegativescorrections=map2pairlowerPositiveslowerNegatives|>append(map2pairlowerNegativeslowerPositives)|>append(map2pairupperPositivesupperNegatives)|>append(map2pairupperNegativesupperPositives)correct(invalid,valid)speech=speech-- "I do like pizza"|>replaceinvalidvalid-- "I don't like pizza"neededCorrectionsspeechcorrection=speech-- "I do like pizza."|>words-- ["I", "do", "like", "pizza"]|>member(firstcorrection)-- [("do", "don't")]correctSpeechspeech=corrections-- [("are", "aren't"), ("can", "can't"), ...)]|>filter(neededCorrectionsspeech)-- [("do", "don't")]|>foldlcorrectspeech-- "I don't like pizza." (that's not true, I love pizza)
Elm
Maybe not the best algorithm, show me yours!
Playground
Test it here.
What if the string is "Should I go?" or generally speaking when they come at the starting of a sentence?
You are right and this solution is not 100% bulletproof. Hence my little message just before saying that I'm curious about other answer.
What do you think we should do to resolve this issue?