Determine sentence type: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Thundergnat moved page Determine Sentence Type to Determine sentence type: Capitalization policy) |
Thundergnat (talk | contribs) (→{{header|Raku}}: Add a Raku example) |
||
Line 163: | Line 163: | ||
Are you sure?!?! How can you know? -> EQ|Q |
Are you sure?!?! How can you know? -> EQ|Q |
||
</pre> |
</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> |