OleMchls / atom-wordcount

Counts the words in your current document
https://atom.io/packages/wordcount
MIT License
38 stars 27 forks source link

Long reading times not properly shown #120

Open mwermelinger opened 5 years ago

mwermelinger commented 5 years ago

I have a file with 4137 words and in the settings I have put a reading speed of 35 words per minute. It's a pedagogical text and I want to account for my students' time to re-read and highlight passages, write notes, etc. hence the low WPM.

So the text should take 4137/35 = 118.2 minutes = 118 minutes and 12 seconds to process, but the display only shows 18:12. The most significant digit is gone! The error also occurs if the display of the word and character count is disabled, so it's not a lack of space issue. I'm using word count 3.1.0.

I'm not quite sure what's the point of providing the reading time to the second given that any word counting algorithm and reading speed setting will be approximate. I'd rather have hours and minutes, so 1:58 in this case. If the file is a whole novel or play (think Project Gutenberg) then these longer times will occur even with higher WPM speeds and should be correctly displayed.

Thanks in advance for looking into this.

MasterOfTheTiger commented 5 years ago

I wrote some code associcated with this. I may have not considered this case. I agree that hour:minute would probably be better, since the margin of error is likely much greater than several seconds when it comes to estimating reading time, and that level of accuracy simply isn't necessary.

There are two ways I can see fixing this:

It could also change systems depending on how long the text is. E.g. 30s, 10m, 2.5h, 2d, etc. But that would require a bigger change on the functionality of the estimated time feature.

MasterOfTheTiger commented 5 years ago

@davidlday I am willing to work on this, but how should it be resolved?

mwermelinger commented 5 years ago

Thanks for this. My preference would be to do as in your 2nd bullet point

davidlday commented 5 years ago

@davidlday I am willing to work on this, but how should it be resolved?

Option 2 would also be my preference. @OleMchls - any preference?

OleMchls commented 5 years ago

I’m also for option two. However, I’d like to highlight that I think the correct solution would include this part that @MasterOfTheTiger mentioned:

It could also change systems depending on how long the text is. E.g. 30s, 10m, 2.5h, 2d, etc. But that would require a bigger change on the functionality of the estimated time feature.

davidlday commented 5 years ago

@MasterOfTheTiger - I assigned you, if you still have time to work on it. Let me know if you need any help or guidance.

MasterOfTheTiger commented 5 years ago

@davidlday I will work on this, if you are willing to be a bit patient. I may be able to get it written within a week realistically.

MasterOfTheTiger commented 5 years ago

This is as far as I have gotten. It doesn't work, but I am too tired to figure it out at the moment.

  charactersToHMS: (words) ->
    # 1- calculate minutes and seconds for reading
    wpm = atom.config.get('wordcount.wordsPerMinute')
    minutes = words / wpm
    hours = minutes / 60
    # 2- recalculate minutes based on hours
    minutes = parseInt(hours * 60)
    # 60 minutes in 1 hour
    # 3- Calculate remainder of minutes without hours and vice versa
    hours = Math.round(hours % 60)
    minutes = Math.round(minutes % 60)
    # 4- Return time
    minutes = ('0' + minutes).slice(-2)
    hours + ':' + minutes
mwermelinger commented 5 years ago

Thanks for working on this. I don't know which language Atom is written in, but in Python one could work just with integers and then convert to a string in the end:

words = 4137     # values from my original post
wpm = 35
minutes = round(words / wpm)  # could also be floor division to ignore the seconds
hours = minutes // 60        # floor division
minutes = minutes % 60
return str(hours) + ':' + ('0' if minutes < 10 else '') + str(minutes) 

There are other ways of formatting strings in Python but this is probably the simplest to adapt to your language.