Determine sentence type: Difference between revisions

→‎{{header|Lua}}: added Lua solution
(Added Epoxy)
(→‎{{header|Lua}}: added Lua solution)
Line 462:
Just make sure you don't break it ==> N
</pre>
 
=={{header|Lua}}==
<lang lua>text = "hi there, how are you today? I'd like to present to you the washing machine 9001. You have been nominated to win one of these! Just make sure you don't break it"
p2t = { [""]="N", ["."]="S", ["!"]="E", ["?"]="Q" }
for s, p in text:gmatch("%s*([^%!%?%.]+)([%!%?%.]?)") do
print(s..p..": "..p2t[p])
end</lang>
{{out}}
<pre>hi there, how are you today?: Q
I'd like to present to you the washing machine 9001.: S
You have been nominated to win one of these!: E
Just make sure you don't break it: N</pre>
 
=={{header|Perl}}==
Anonymous user