所以我在列表中有一些句子,比如:
some_list = ['Joe is travelling via train.'
'Joe waited for the train, but the train was late.'
'Even after an hour, there was no sign of the
train. Joe then went to talk to station master about the
train's situation.']
然后我使用了nltk的句子标记器,因为我想单独分析完整句子中的每个句子。所以现在O/P在列表格式中看起来像这样:
sent_tokenize_list = [['Joe is travelling via train.'],
['Joe waited for the train,',
'but the train was late.'],
['Even after an hour,',
'there was no sign of the
train.',
'Joe then went to talk to station master about
the train's situation.']]
现在,从这个列表列表中,我如何选择仅包含1个以上句子的列表,即我的示例中的第2个和第3个列表,并以单独列表的形式使用它们。
即O/p应为
['Joe waited for the train,','but the train was late.']
['Even after an hour,','there was no sign of the train.',
'Joe then went to talk to station master about the train's situation.']
您可以使用
len
检查列表中的句子数。你知道吗例如:
输出:
相关问题 更多 >
编程相关推荐