From b49d8e8083f5d1d84cf8d3f75ebdddb942aa4ba3 Mon Sep 17 00:00:00 2001 From: Duncan Lock Date: Sun, 23 Jun 2013 10:54:54 -0700 Subject: [PATCH] Minor tidy. simplified read_minutes calculation --- post_stats/post_stats.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/post_stats/post_stats.py b/post_stats/post_stats.py index 7ab30af..f8a91f2 100644 --- a/post_stats/post_stats.py +++ b/post_stats/post_stats.py @@ -11,7 +11,8 @@ word_count: frquency count of all the words in the article; can be used for tag/ """ -from pelican import signals, contents +from pelican import signals +# import math # import nltk @@ -26,6 +27,7 @@ from collections import Counter def calculate_stats(instance): + # How fast do average people read? WPM = 250 if instance._content is not None: @@ -64,7 +66,8 @@ def calculate_stats(instance): stats['word_counts'] = word_count stats['wc'] = sum(word_count.values()) - stats['read_minutes'] = (stats['wc'] + WPM // 2) // WPM + # stats['read_minutes'] = math.ceil(float(stats['wc']) / float(WPM)) + stats['read_minutes'] = (stats['wc'] + WPM - 1) // WPM instance.stats = stats instance.raw_text = raw_text