| 37 | |
| 38 | # https://stackoverflow.com/questions/33139531/preserve-empty-lines-with-nltks-punkt-tokenizer |
| 39 | class CustomLanguageVars(nltk.tokenize.punkt.PunktLanguageVars): |
| 40 | |
| 41 | _period_context_fmt = r""" |
| 42 | \S* # some word material |
| 43 | %(SentEndChars)s # a potential sentence ending |
| 44 | \s* # <-- THIS is what I changed |
| 45 | (?=(?P<after_tok> |
| 46 | %(NonWord)s # either other punctuation |
| 47 | | |
| 48 | (?P<next_tok>\S+) # <-- Normally you would have \s+ here |
| 49 | ))""" |
| 50 | |
| 51 | class IdentitySplitter(object): |
| 52 | def tokenize(self, *text): |