From edc7ba164fcb99347d9824eeecd8665f7135e820 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Fri, 15 Mar 2013 08:00:40 +0100 Subject: Improved code readability. --- source/mongodb.py | 2 +- source/utils.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/mongodb.py b/source/mongodb.py index 38081780..9e64fe4f 100644 --- a/source/mongodb.py +++ b/source/mongodb.py @@ -45,7 +45,7 @@ class Articles(object): Creates a new collection for a new feed. """ collection = self.db[new_collection["feed_id"]] - collection.create_index([("article_date", pymongo.DESCENDING)], {"unique":False, "sparse":False}) + #collection.create_index([("article_date", pymongo.DESCENDING)], {"unique":False, "sparse":False}) collection.ensure_index('article_content', pymongo.ASCENDING) collection.insert(new_collection) diff --git a/source/utils.py b/source/utils.py index 9b52ce4b..09056bbe 100755 --- a/source/utils.py +++ b/source/utils.py @@ -119,7 +119,9 @@ def top_words(articles, n=10, size=5): words = Counter() wordre = re.compile(r'\b\w{%s,}\b' % size, re.I) for article in articles: - for word in [elem.lower() for elem in wordre.findall(clear_string(article["article_content"])) if elem.lower() not in stop_words]: + for word in [elem.lower() for elem in + wordre.findall(clear_string(article["article_content"])) \ + if elem.lower() not in stop_words]: words[word] += 1 return words.most_common(n) -- cgit