Last active
July 3, 2020 14:32
-
-
Save dardanxhymshiti/9f1504a5d64627cbee9fcae8ec18626c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_sentences(text): | |
import re | |
pattern = r'([A-Z][^\.!?]*[\.!?])' | |
pattern_compiled = re.compile(pattern, re.M) | |
list_of_sentences = re.findall(pattern, text) | |
return list_of_sentences | |
# Test | |
text = """This is the most frequent question we're asked by prospective students. And our response? Absolutely! We've trained people from all walks of life.""" | |
get_sentences(text) | |
# [ | |
# "This is the most frequent questions we're asked by prospective students.", | |
# 'And our response?', | |
# 'Absolutely!', | |
# "We've trained people from all walks of life." | |
# ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment