Python通过标点符号断句
Python通过标点符号断句 # 常见的断句标点text = '小明说:"我将来想成为科学家."'punc = """,.?!;: 、|,。?!;:《》「」【】/<>|\“ ”‘ ’"""punc_re = '|'.join(re.escape(x) for x in punc)tokens = re.sub(punc_re, lambda x: ' ' + x.group() + ' ', text)tokens = tokens.split()结果:[‘小明说’, ‘:’,
原创
2021-10-20 15:29:26 ·
1768 阅读 ·
0 评论