diff options
author | cedricbonhomme <devnull@localhost> | 2012-03-03 19:07:18 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2012-03-03 19:07:18 +0100 |
commit | 1710f5891646f2182224e38e94780d3a75881e43 (patch) | |
tree | f662ff7940815dfb585143a1879483baf4ba9eb2 /utils.py | |
parent | Main page almost working. (diff) | |
download | newspipe-1710f5891646f2182224e38e94780d3a75881e43.tar.gz newspipe-1710f5891646f2182224e38e94780d3a75881e43.tar.bz2 newspipe-1710f5891646f2182224e38e94780d3a75881e43.zip |
Feed information page is working with MongoDB.
Diffstat (limited to 'utils.py')
-rwxr-xr-x | utils.py | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -165,16 +165,15 @@ def normalize_filename(name): file_name = strip_accents(file_name, "utf-8") return os.path.normpath(file_name) -def top_words(feeds, n=10, size=5): +def top_words(articles, n=10, size=5): """ Return the n most frequent words in a list. """ words = Counter() wordre = re.compile(r'\b\w{%s,}\b' % size, re.I) - for feed in feeds: - for article in feed: - for word in wordre.findall(clear_string(article["article_content"])): - words[word.lower()] += 1 + for article in articles: + for word in wordre.findall(clear_string(article["article_content"])): + words[word.lower()] += 1 return words.most_common(n) def tag_cloud(tags, query="word_count"): |