如何使用FreqDist中的fd.items()来总结词频数量?使用FreqDist总结词频数量,python
>>> fd = FreqDist(text)
>>> most_freq_w = fd.keys()[:10] #gives me the most 10 frequent words in the text
>>> #here I should sum up numbers of each of these 10 freq words appear in the text
例如,如果most_freq_w
中的每个单词出现10次,结果应该是100
!!!我不需要这个数字的所有词语的文字,只是最常见的10
认为(这几乎是侮辱性的简单)。或者至少向我们展示你的尝试。 – delnan 2010-11-17 17:05:06
我试过的是将'fd.items'从'most_freq_w'中取出 - 但这是绝对错误的,因为结果为'0' – Gusto 2010-11-17 17:27:14