0
文章を区切り記号として区切り文章に分割しようとしています。私はこれまでのコードは動作しますが、デリミタは単独で行に表示されています。どのように文章と一緒に句読点を保持することができますか?テキストファイルを文章に分割する
import re
string = ""
with open("text.txt") as file:
for line in file:
for l in re.split(r"(\. |\? |\!)",line):
string += l + "\n"
print(string)
出力例:
This is the flag of the Prooshi — ous, the Cap and Soracer
.
This is the bullet that byng the flag of the Prooshious
.
This is the ffrinch that fire on the Bull that bang the flag of the Prooshious
.