Created
November 24, 2020 14:39
-
-
Save prettyirrelevant/13711f4fd9e4968ff4373503e143a1dc to your computer and use it in GitHub Desktop.
a python script that calculates the time it'll take to read a given text( i think it's buggy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_time_to_read(text: str): | |
striped_text = strip_tags(text) | |
word_cleaned = re.sub(r" /[^\w ]/g", "", striped_text) | |
word_count = len(word_cleaned.split(" ")) | |
reading_time = math.floor(word_count / 200) | |
if reading_time <= 1: | |
return f"{str(reading_time)} min" | |
else: | |
return f"{str(reading_time)} mins" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment