Skip to content

Pelican plugin that calculates post statistics such as word count, reading ease, and more.

Notifications You must be signed in to change notification settings

pelican-plugins/statistics

Repository files navigation

Statistics: A Plugin for Pelican

Build Status PyPI Version Downloads License

Statistics is a Pelican plugin that calculates post statistics such as word count, reading ease, and more.

Installation

This plugin can be installed via:

python -m pip install pelican-statistics

As long as you have not explicitly added a PLUGINS setting to your Pelican settings file, then the newly-installed plugin should be automatically detected and enabled. Otherwise, you must add statistics to your existing PLUGINS list. For more information, please see the How to Use Plugins documentation.

Usage

This plugin calculates various statistics about a post and stores them in an article.statistics dictionary:

  • wc: the number of words in the article
  • read_mins: how many minutes it would take to read this article, based on 250 WPM
  • word_counts: frequency count of all the words in the article — can be used for tag/word clouds
  • fi: Flesch Reading Ease
  • fk: Flesch–Kincaid Grade Level

article.statistics dictionary example:

{
    'wc': 2760,
    'fi': '65.94',
    'fk': '7.65',
    'word_counts': Counter({"to": 98, "a": 90, "the": 83, "of": 50, ...}),
    'read_mins': 12
}

This article.statistics dictionary allows you to output these values in your templates. For example:

<p title="~{{ article.statistics['wc'] }} words">~{{ article.statistics['read_mins'] }} min read</p>
<ul>
    <li>Flesch Reading Ease: {{ article.statistics['fi'] }}</li>
    <li>Flesch–Kincaid Grade Level: {{ article.statistics['fk'] }}</li>
</ul>

The word_counts variable is a python Counter dictionary and looks something like the following, with each unique word and its frequency:

Counter({"to": 98, "a": 90, "the": 83, "of": 50, "karma": 50, .....

This word_counts variable can be used to create a tag/word cloud for a post.

Contributing

Contributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on existing issues.

To start contributing to this plugin, review the Contributing to Pelican documentation, beginning with the Contributing Code section.

License

This project is licensed under the AGPL-3.0 license.

About

Pelican plugin that calculates post statistics such as word count, reading ease, and more.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages