我想将文本拆分为子句。我该怎么做?
例如:
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.']
