aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xpyAggr3g470r.py2
-rwxr-xr-xutils.py9
2 files changed, 5 insertions, 6 deletions
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index 9a88d05a..f418e950 100755
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -677,7 +677,7 @@ class Root:
dic = {}
#dic[feed.feed_id] = self.feeds[feed.feed_id]
- top_words = utils.top_words([articles], n=50, size=int(word_size))
+ top_words = utils.top_words(articles = self.articles.get_articles_from_collection(feed_id), n=50, size=int(word_size))
html += "</br /><h1>Tag cloud</h1>\n<br />\n"
# Tags cloud
html += 'Minimum size of a word:'
diff --git a/utils.py b/utils.py
index e44239e4..07f39808 100755
--- a/utils.py
+++ b/utils.py
@@ -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"):
bgstack15