段落の先頭から1つの空白を削除して、段落の最初の文字を大文字にする方法は?先導スペースと大文字
入力:
this is a sample sentence. This is a sample second sentence.
出力:
This is a sample sentence. This is a sample second sentence.
私の努力は、これまで:
import spacy, re
nlp = spacy.load('en_core_web_sm')
doc = nlp(unicode(open('2.txt').read().decode('utf8')))
tagged_sent = [(w.text, w.tag_) for w in doc]
normalized_sent = [w.capitalize() if t in ["NN","NNS"] else w for (w,t) in tagged_sent]
normalized_sent1 = normalized_sent[0].capitalize()
string = re.sub(" (?=[\.,'!?:;])", "", ' '.join(normalized_sent1))
rtn = re.split('([.!?] *)', string)
final = ''.join([i.capitalize() for i in rtn])
print final
これは段落の先頭を除くすべての段落の文章の最初の単語を大文字に?
Output:
on the insert tab, the galleries include items that are designed to coordinate with the overall look of your document. You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks. When you create pictures, charts, or diagrams, they also coordinate with your current document look.
Expected output:
On the insert tab, the galleries include items that are designed to coordinate with the overall look of your document. You can use these galleries to insert tables, headers, footers, lists, cover pages, and other document building blocks. When you create pictures, charts, or diagrams, they also coordinate with your current document look.
あなたがこれまでに試してみました何を?あなたのコードを投稿してください。 – James
"段落"を定義します。 – Sweeper
'nltk'ライブラリを使っても問題ありませんか? –