Determine sentence type: Difference between revisions
Content added Content deleted
(Added Epoxy) |
|||
Line 217: | Line 217: | ||
{{out}} |
{{out}} |
||
<pre>QSEN</pre> |
<pre>QSEN</pre> |
||
=={{header|Epoxy}}== |
|||
<lang epoxy>const SentenceTypes: { |
|||
["?"]:"Q", |
|||
["."]:"S", |
|||
["!"]:"E" |
|||
} |
|||
fn DetermineSentenceType(Char) |
|||
return SentenceTypes[Char]||"N" |
|||
cls |
|||
fn GetSentences(Text) |
|||
var Sentences: [], |
|||
Index: 0, |
|||
Length: #Text |
|||
loop i:0;i<Length;i+:1 do |
|||
var Char: string.subs(Text,i,1) |
|||
var Type: DetermineSentenceType(Char) |
|||
if Type != "N" || i==Length-1 then |
|||
log(string.sub(Text,Index,i+1)+" ("+Type+")") |
|||
Index:i+2; |
|||
cls |
|||
cls |
|||
cls |
|||
GetSentences("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")</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|Factor}}== |
=={{header|Factor}}== |