我想将文本拆分为子句。我该怎么做?
例如:
text = "Hi, this is an apple. Hi, that is pineapple."
结果应该是:
['Hi,',
'this is an apple.',
'Hi,',
'that is pineapple.']
(附:我尝试使用 string.split(r'[,.]')
,但它会删除分隔符。)
最佳答案
也许这也行:
text.replace(', ', ',, ').replace('. ', '., ').split(', ')
结果:
['Hi,', 'this is an apple.', 'Hi,', 'that is pineapple.']
关于python - 如何使用 python 将文本拆分为子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47964378/