Bootstrap

使用正则表达式切分英文句子,将标点和句子分开

[x.strip() for x in re.split(r'(\w+)?', sent) if x and x !=' ']

可将如下句子:
Mary moved to the bedroom.
切分结果:
[‘Mary’, ‘moved’, ‘to’, ‘the’, ‘bedroom’, ‘.’]

;