Determine sentence type: Difference between revisions
Content added Content deleted
m (→{{header|Python}}: Reinterpreted N tag as 'not puncuated') |
|||
Line 355: | Line 355: | ||
def go(sentences): |
def go(sentences): |
||
return [ |
return [ |
||
(tagDict.get(k, ' |
(tagDict.get(k, 'Not punctuated'), list(v)) |
||
for (k, v) in groupby( |
for (k, v) in groupby( |
||
sorted(sentences, key=last), |
sorted(sentences, key=last), |
||
Line 393: | Line 393: | ||
# main :: IO () |
# main :: IO () |
||
def main(): |
def main(): |
||
''' |
'''Join, segmentation, tags''' |
||
tags = {'!': 'E', '?': 'Q', '.': 'S'} |
tags = {'!': 'E', '?': 'Q', '.': 'S'} |
||
Line 405: | Line 405: | ||
"Feels as light as polystyrene filler.", |
"Feels as light as polystyrene filler.", |
||
"But perhaps substance isn't the goal!", |
"But perhaps substance isn't the goal!", |
||
"Just make sure you don't break |
"Just make sure you don't break off before the" |
||
]) |
]) |
||
Line 459: | Line 459: | ||
('S', ["I'd like to present to you the washing machine 9001.", 'Feels as light as polystyrene filler.']) |
('S', ["I'd like to present to you the washing machine 9001.", 'Feels as light as polystyrene filler.']) |
||
('Q', ['Hi there, how are you today?', 'Might it be possible to add some challenge to this task?']) |
('Q', ['Hi there, how are you today?', 'Might it be possible to add some challenge to this task?']) |
||
(' |
('Not punctuated', ["Just make sure you don't break off before the"])</pre> |
||
=={{header|Raku}}== |
=={{header|Raku}}== |