查找并替换为以小写字母开头的正确句子案例句子。正则表达式或崇高
find and replace with correct sentence case sentences starting with lowercase. regex or sublime
我有一些句子以小写字母开头的文本。我需要找到它们并用正确的句子替换 case.some 标点符号不正确。即句子在没有 space.
的句号后开始
即
.this sentence
and this.also this. and this.This one is not.
替换为 ->
.This sentence
And this.Also this. And this.This one is not.
sublime text 3 解决方案,正则表达式,或python nltk 解决方案是合适的。
我试过这个解决方案。但它很慢,在句号后找不到没有 space 的句子。
import nltk.data
from nltk.tokenize import sent_tokenize
text = """kjdshkjhf. this sentence
and this.also this. and this. This one is not."""
aa=sent_tokenize(text)
for a in aa:
if (a[0].islower()):
print a
print "****"
你可以使用这个模式
^([^a-zA-Z]*)([a-z])
并使用 \U
作为替代
更新:- 如果你想在每个 .
(句点)之后捕获第一个小写字母,你可以使用这个
^([^a-zA-Z]*)([a-z])|(\.\s*)([a-z])
我有一些句子以小写字母开头的文本。我需要找到它们并用正确的句子替换 case.some 标点符号不正确。即句子在没有 space.
的句号后开始即
.this sentence
and this.also this. and this.This one is not.
替换为 ->
.This sentence
And this.Also this. And this.This one is not.
sublime text 3 解决方案,正则表达式,或python nltk 解决方案是合适的。
我试过这个解决方案。但它很慢,在句号后找不到没有 space 的句子。
import nltk.data
from nltk.tokenize import sent_tokenize
text = """kjdshkjhf. this sentence
and this.also this. and this. This one is not."""
aa=sent_tokenize(text)
for a in aa:
if (a[0].islower()):
print a
print "****"
你可以使用这个模式
^([^a-zA-Z]*)([a-z])
并使用 \U
作为替代
更新:- 如果你想在每个 .
(句点)之后捕获第一个小写字母,你可以使用这个
^([^a-zA-Z]*)([a-z])|(\.\s*)([a-z])