write function sentence_segmentation(document) that takes an input parameter document (type string) and returns a list of sentences
Fantastic news! We've Found the answer you've been seeking!
Question:
write function sentence_segmentation(document) that takes an input parameter document (type string) and returns a list of sentences from the given document.If no sentences could be segmented (think about the cases), then it simply returns an empty list.
NB: You are guaranteed that a document will not begin with the full stop character.
For example:
Test | Result |
---|---|
document = "sent1. sent2. sent3. sent4. sent5." sentences = sentence_segmentation(document) print(sentences) | ['sent1.', 'sent2.', 'sent3.', 'sent4.', 'sent5.'] |
document = "sent 1. sent 2... sent 3.... sent 4. sent 5.." sentences = sentence_segmentation(document) print(sentences) | ['sent 1.', 'sent 2...', 'sent 3....', 'sent 4.', 'sent 5..'] |
document = "sent1.sent2.sent3.sent4.sent5." sentences = sentence_segmentation(document) print(sentences) | ['sent1.sent2.sent3.sent4.sent5.'] |
Related Book For
Posted Date: