From 96737318bee587d1803f6899dfe8166239d48819 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Sat, 27 Feb 2010 01:01:31 +0100 Subject: Minor enhancement. --- utils.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils.py') diff --git a/utils.py b/utils.py index 4289a7ee..e2294446 100644 --- a/utils.py +++ b/utils.py @@ -26,8 +26,8 @@ def remove_html_tags(data): def top_words(dic_articles, n=10): """ + Return the n most frequent words in a list. """ - N = 10 words = {} articles_content = "" for rss_feed_id in dic_articles.keys(): @@ -40,7 +40,7 @@ def top_words(dic_articles, n=10): for word in words_gen: words[word] += 1 top_words = sorted(words.iteritems(), - key=lambda(word, count): (-count, word))[:N] + key=lambda(word, count): (-count, word))[:n] return top_words def create_histogram(words, file_name="./var/histogram.png"): @@ -161,4 +161,4 @@ def load_feed(): c.close() return (articles, feeds) - return (articles, feeds) \ No newline at end of file + return (articles, feeds) -- cgit