python re包_使用Python中的re包将句子分成子句

我有一个很多句子的数据,关于一个例子作为下面的句子,我想把它分成2个子句子:

Both whole plasma and the d < 1.006 g/ml density fraction of plasma

from 2/2 mice show this broad beta-migration pattern (Fig. 1 B)

|T:**1SP3E3| ; |I:**1SP3E3| |L:**1SP3E3| in contrast, 3/3 plasma shows

virtually no lipid staining at the beta-position. |T:**1SN3E3|

|I:**1SN3E3| |L:**1SN3E3|

将它拆分为:

Both whole plasma and the d < 1.006 g/ml density fraction of plasma

from 2/2 mice show this broad beta-migration pattern (Fig. 1 B)

in contrast, 3/3 plasma shows virtually no lipid staining at the

beta-position.

我的代码是:

newData =[]

for item in Data:

test2= re.split(r" (?:\|.*?\| ?)+", item[0])

test2 =test2[:-1]

for tx in test2:

newData.append(tx)

print len(newData)

print newData

但是,我在结果中得到了3个项目,包括;我查了一下原来的句子,发现了,在| T:** 1SP3E3 | ; | I:** 1SP3E3 |,所以我需要删除它;从结果出来.我修改了我的代码

test2= re.split(r" (?:\|.*?\| ?;?)+", item[0])

但我无法得到正确的结果.有人可以帮忙吗?非常感谢.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值