相关疑难解决方法(0)

在Python中查找所有出现的子字符串

Python已经string.find()并且string.rfind()在字符串中获取子字符串的索引.

我想知道,也许有类似的东西string.find_all()可以返回所有已创建的索引(不仅从开始或从头到尾)?

例如:

string = "test test test test"

print string.find('test') # 0
print string.rfind('test') # 15

#this is the goal
print string.find_all('test') # [0,5,10,15]
Run Code Online (Sandbox Code Playgroud)

python regex string

325
推荐指数
12
解决办法
39万
查看次数

Python在句子上分割文本

我有一个文本文件.我需要一个句子列表.

如何实施?有许多细微之处,例如在缩写中使用点.

我的旧正则表达式很糟糕.

re.compile('(\. |^|!|\?)([A-Z][^;?\.<>@\^&/\[\]]*(\.|!|\?) )',re.M)
Run Code Online (Sandbox Code Playgroud)

python text split

85
推荐指数
9
解决办法
11万
查看次数

如何在Python中用句子分解段落

我需要解析Python中段落的句子.是否有现成的包,或者我应该尝试在这里使用正则表达式?

python regex text-segmentation

9
推荐指数
1
解决办法
2万
查看次数

准确地分裂句子

我的程序采用一个文本文件,并将每个句子分成一个列表,使用的split('.')意思是,当它注册一个完整的停止时它会分裂但是它可能是不准确的.

例如

str='i love carpets. In fact i own 2.4 km of the stuff.'
Run Code Online (Sandbox Code Playgroud)

产量

listOfSentences = ['i love carpets', 'in fact i own 2', '4 km of the stuff']

期望的输出

 listOfSentences = ['i love carpets', 'in fact i own 2.4 km of the stuff']
Run Code Online (Sandbox Code Playgroud)

我的问题是:我如何分割句子的结尾,而不是每一个句号.

python parsing nlp

5
推荐指数
1
解决办法
1319
查看次数

标签 统计

python ×4

regex ×2

nlp ×1

parsing ×1

split ×1

string ×1

text ×1

text-segmentation ×1