readtime


Namereadtime JSON
Version 3.0.0 PyPI version JSON
download
home_pagehttps://github.com/alanhamlett/readtime
SummaryCalculates the time some text takes the average human to read, based on Medium's read time forumula
upload_time2023-07-22 06:50:23
maintainer
docs_urlNone
authorAlan Hamlett
requires_python
licenseBSD
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # readtime

[![Tests](https://img.shields.io/github/actions/workflow/status/alanhamlett/readtime/tests.yml?branch=master)](https://github.com/alanhamlett/readtime/actions/workflows/tests.yml)
[![Coverage](https://codecov.io/gh/alanhamlett/readtime/branch/master/graph/badge.svg?token=EbUnuwbra3)](https://codecov.io/gh/alanhamlett/readtime)

Calculates the time some text takes the average human to read, based on Medium's [read time forumula](https://help.medium.com/hc/en-us/articles/214991667-Read-time).


### Algorithm

Medium's Help Center says,

> Read time is based on the average reading speed of an adult (roughly 265 WPM). We take the total word count of a post and translate it into minutes, with an adjustment made for images. For posts in Chinese, Japanese and Korean, it's a function of number of characters (500 characters/min) with an adjustment made for images.

Source: https://help.medium.com/hc/en-us/articles/214991667-Read-time (Read Sept 23rd, 2018)

Double checking with real articles, the English algorithm is:

    seconds = num_words / 265 * 60 + img_weight * num_images

With `img_weight` starting at `12` and decreasing one second with each image encountered, with a minium `img_weight` of `3` seconds.


### Installation

    virtualenv venv
    . venv/bin/activate
    pip install readtime

Or if you like to live dangerously:

    sudo pip install readtime


### Usage

Import `readtime` and pass it some text, HTML, or Markdown to get back the time it takes to read:

    >>> import readtime
    >>> result = readtime.of_text('The shortest blog post in the world!')
    >>> result.seconds
    2
    >>> result.text
    u'1 min'

The result can also be used as a string:

    >>> str(readtime.of_text('The shortest blog post in the world!'))
    u'1 min read'

To calculate read time of Markdown:

    >>> readtime.of_markdown('This is **Markdown**')
    1 min read

To calculate read time of HTML:

    >>> readtime.of_html('This is <strong>HTML</strong>')
    1 min read

To customize the WPM (default 265):

    >>> result = readtime.of_text('The shortest blog post in the world!', wpm=5)
    >>> result.seconds
    96
    >>> result.text
    u'2 min'
    >>> result.wpm
    5


### Contributing

Before contributing a pull request, make sure tests pass:

    virtualenv venv
    . venv/bin/activate
    pip install tox
    tox

Many thanks to all [contributors](https://github.com/alanhamlett/readtime/blob/master/AUTHORS)!



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/alanhamlett/readtime",
    "name": "readtime",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Alan Hamlett",
    "author_email": "alan.hamlett@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e2/9f/a8e3d08eab31d92e49ef2fe6423ce385503e74f793e0e1a81d343ea991d1/readtime-3.0.0.tar.gz",
    "platform": "any",
    "description": "# readtime\n\n[![Tests](https://img.shields.io/github/actions/workflow/status/alanhamlett/readtime/tests.yml?branch=master)](https://github.com/alanhamlett/readtime/actions/workflows/tests.yml)\n[![Coverage](https://codecov.io/gh/alanhamlett/readtime/branch/master/graph/badge.svg?token=EbUnuwbra3)](https://codecov.io/gh/alanhamlett/readtime)\n\nCalculates the time some text takes the average human to read, based on Medium's [read time forumula](https://help.medium.com/hc/en-us/articles/214991667-Read-time).\n\n\n### Algorithm\n\nMedium's Help Center says,\n\n> Read time is based on the average reading speed of an adult (roughly 265 WPM). We take the total word count of a post and translate it into minutes, with an adjustment made for images. For posts in Chinese, Japanese and Korean, it's a function of number of characters (500 characters/min) with an adjustment made for images.\n\nSource: https://help.medium.com/hc/en-us/articles/214991667-Read-time (Read Sept 23rd, 2018)\n\nDouble checking with real articles, the English algorithm is:\n\n    seconds = num_words / 265 * 60 + img_weight * num_images\n\nWith `img_weight` starting at `12` and decreasing one second with each image encountered, with a minium `img_weight` of `3` seconds.\n\n\n### Installation\n\n    virtualenv venv\n    . venv/bin/activate\n    pip install readtime\n\nOr if you like to live dangerously:\n\n    sudo pip install readtime\n\n\n### Usage\n\nImport `readtime` and pass it some text, HTML, or Markdown to get back the time it takes to read:\n\n    >>> import readtime\n    >>> result = readtime.of_text('The shortest blog post in the world!')\n    >>> result.seconds\n    2\n    >>> result.text\n    u'1 min'\n\nThe result can also be used as a string:\n\n    >>> str(readtime.of_text('The shortest blog post in the world!'))\n    u'1 min read'\n\nTo calculate read time of Markdown:\n\n    >>> readtime.of_markdown('This is **Markdown**')\n    1 min read\n\nTo calculate read time of HTML:\n\n    >>> readtime.of_html('This is <strong>HTML</strong>')\n    1 min read\n\nTo customize the WPM (default 265):\n\n    >>> result = readtime.of_text('The shortest blog post in the world!', wpm=5)\n    >>> result.seconds\n    96\n    >>> result.text\n    u'2 min'\n    >>> result.wpm\n    5\n\n\n### Contributing\n\nBefore contributing a pull request, make sure tests pass:\n\n    virtualenv venv\n    . venv/bin/activate\n    pip install tox\n    tox\n\nMany thanks to all [contributors](https://github.com/alanhamlett/readtime/blob/master/AUTHORS)!\n\n\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Calculates the time some text takes the average human to read, based on Medium's read time forumula",
    "version": "3.0.0",
    "project_urls": {
        "Homepage": "https://github.com/alanhamlett/readtime"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e29fa8e3d08eab31d92e49ef2fe6423ce385503e74f793e0e1a81d343ea991d1",
                "md5": "2097831b78c155e0997c6a6c1b4d4f7d",
                "sha256": "76c5a0d773ad49858c53b42ba3a942f62fbe20cc8c6f07875797ac7dc30963a9"
            },
            "downloads": -1,
            "filename": "readtime-3.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "2097831b78c155e0997c6a6c1b4d4f7d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 6271,
            "upload_time": "2023-07-22T06:50:23",
            "upload_time_iso_8601": "2023-07-22T06:50:23.374940Z",
            "url": "https://files.pythonhosted.org/packages/e2/9f/a8e3d08eab31d92e49ef2fe6423ce385503e74f793e0e1a81d343ea991d1/readtime-3.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-22 06:50:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "alanhamlett",
    "github_project": "readtime",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "tox": true,
    "lcname": "readtime"
}
        
Elapsed time: 0.09411s