数据位于文本文件中,我想将其中的数据分组为句子。句子的定义是所有行依次排列,每行至少有 1 个字符。包含数据的行之间有空白行,因此我希望空白行标记句子的开头和结尾。有没有办法通过列表理解来做到这一点?
文本文件中的示例。数据看起来像这样:
This is the
first sentence.
This is a really long sentence
and it just keeps going across many
rows there will not necessarily be
punctuation
or consistency in word length
the only difference in ending sentence
is the next row will be blank
here would be the third sentence
as
you see
the blanks between rows of data
help define what a sentence is
this would be sentence 4
i want to pull data
from text file
as such (in sentences)
where sentences are defined with
blank records in between
this would be sentence 5 since blank row above it
and continues but ends because blank row(s) below it
GCT1015
蝴蝶不菲
相关分类