Jump to content

Determine sentence type: Difference between revisions

→‎{{header|Raku}}: Add a Raku example
m (Thundergnat moved page Determine Sentence Type to Determine sentence type: Capitalization policy)
(→‎{{header|Raku}}: Add a Raku example)
Line 163:
Are you sure?!?! How can you know? -> EQ|Q
</pre>
 
=={{header|Raku}}==
 
<lang perl6>use Lingua::EN::Sentence;
 
my $paragraph = q:to/PARAGRAPH/;
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
PARAGRAPH
 
say join '|', $paragraph.&get_sentences.map: {
$_ ~~ /(<:punct>)$/;
given $0 {
when '!' { 'E' };
when '?' { 'Q' };
when '.' { 'S' };
default { 'N' };
}
}</lang>
{{out}}
<pre>Q|S|E|N</pre>
10,333

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.