【发布时间】:2020-04-28 14:24:06
【问题描述】:
我在从数据框中计算每个句子的平均单词数时遇到问题。这就是我想做的事情
"On Saturday, September 17 at 8:30 pm EST, an explosion rocked West 23 Street in Manhattan, in the neighborhood commonly referred to as Chelsea, injuring 29 people, smashing windows and initiating street closures. There were no fatalities. Officials maintain that a homemade bomb, which had been placed in a dumpster, created the explosion.
2+6+8+8+3+6/6 = 5.6 for first sentence
4/1 = 4 for second sentence
6+7+3/3=5.1 for the third sentence
之后,我想保存列表中每篇文章中每个句子的平均单词。
非常感谢任何人的帮助,谢谢!
【问题讨论】:
-
如何定义一个句子?我敢肯定我的定义和你的不一样。 :-)
-
你如何定义一个词?我敢肯定我的定义和你的不一样。 :)
-
@erip 一个句子通过看句号来定义:")
-
@OliverMason 日期、数字、时间也字
-
第二句有4个词,长度分别为5、4、2、10。所以
4/4 = 1 for the second sentence似乎是错误的。你确定你的结果是正确的?