You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
14 lines
300 B
14 lines
300 B
8 months ago
|
# -*- coding: utf-8 -*-
|
||
|
|
||
9 months ago
|
import operator
|
||
|
|
||
8 months ago
|
def top_word(word_list):
|
||
9 months ago
|
word_freqs = {}
|
||
|
for w in word_list:
|
||
|
if w in word_freqs:
|
||
|
word_freqs[w] += 1
|
||
|
else:
|
||
|
word_freqs[w] = 1
|
||
|
return sorted(word_freqs.items(), key=operator.itemgetter(1), reverse=True)[:10]
|
||
|
|