def whitespace_nlp_with_sentences(doc, entity_type=None, tag_type=None):
pat = re.compile(r"([A-Z][^\.!?]*[\.!?])", re.M)
sents = []
for sent in pat.findall(doc):
toks = []
for tok in re.split(r"(\W)", sent):
pos = "WORD"
After Change
def whitespace_nlp_with_sentences(doc, entity_type=None, tag_type=None):
pat = re.compile(r"([^\.!?]*?[\.!?$])", re.M)
sents = []
raw_sents = pat.findall(doc)if len(raw_sents) == 0:
raw_sents = [doc]
for sent in raw_sents:
toks = []
for tok in re.split(r"(\W)", sent):
if len(tok) > 0: