Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WPM score #21

Closed
Samyak2 opened this issue Apr 7, 2022 · 0 comments · Fixed by #22
Closed

Fix WPM score #21

Samyak2 opened this issue Apr 7, 2022 · 0 comments · Fixed by #22
Labels
bug Something isn't working

Comments

@Samyak2
Copy link
Owner

Samyak2 commented Apr 7, 2022

What and why?

Currently, the WPM (words per minute) score is calculated as such:

wpm = (correctly typed characters / minutes) / (number of words / number of chars)

The (number of words / number of chars) is an estimate of the average number of chars in a word.

This has a few issues:

  • Among a sentence with shorter words (A bit of bet of bat of beet) and a sentence with same number of words but with words being larger (Exceptional extraordinary excitable pepperoni paggliacci postmodern extravagant audacious), the WPM will be disproportionately higher in the former as the number of chars in a word is shorter even though a lot less characters have been typed.
  • This does not consider uncorrected errors. There is no penalty for uncorrected errors. There is no incentive to correct errors as it takes some time and disrupts the rhythm.

A big thank you to Darrien Glasser (author of terminal-typeracer) for explaining the issue thoroughly and providing the solution: https://www.reddit.com/r/rust/comments/tvamfz/comment/i3ewppb/

How?

A good way to calculate the WPM can be found here. To summarize, the final WPM will be:

wpm = ((correctly typed characters) / 5 - (uncorrected errors)) / minutes

A change will have to be made in correctly typed characters since currently the counter will keep increasing if the same char is backspaced and typed repeatedly.

@Samyak2 Samyak2 added the bug Something isn't working label Apr 7, 2022
Samyak2 added a commit that referenced this issue Apr 7, 2022
fixes #21

see issue for the reasoning, etc.

number of correctly typed chars and number of uncorrected errors is
calculated after the typing has completed.

ToipeResults:
- changed field names
- documented fields
- added final_chars_typed_correctly and final_uncorrected_errors fields
- CPM is not available anymore
- WPM is calculated using a fixed 5 chars per word instead of
  calculating it on the fly
    - uncorrected errors are penalized
    - value is clamped to 0.0 to prevent negative WPM
- `num_correct_chars()` did not make sense to keep as a function since
  it's only used in accuracy
    - note: accuracy calculation has not changed
@Samyak2 Samyak2 mentioned this issue Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant