Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tools/reading_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# tool: reading_time
# description: Estimates reading time in minutes (assuming 200 wpm)
# author: @PurpleSwtr
# example: reading_time "400 words of text here" -> "2"


import sys


def run(*args) -> str:
text = args[0] if args else sys.stdin.read()

word_count = len(text.strip().split())

if word_count == 0:
return "0"

minutes = (word_count + 100) // 200
return str(minutes)