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

Support non-english text #12

Open
Samyak2 opened this issue Apr 4, 2022 · 1 comment
Open

Support non-english text #12

Samyak2 opened this issue Apr 4, 2022 · 1 comment
Labels
enhancement New feature or request important Issues that need ot be solved soon words Word selection, word lists, language support, etc.

Comments

@Samyak2
Copy link
Owner

Samyak2 commented Apr 4, 2022

What and why?

Currently, the word selection algorithm in toipe only supports English ASCII characters. Any other characters (including ASCII special characters will be ignored).

This is not good because the world doesn't only write in English :). Especially for a typing test app which can be used to measure and improve speeds in other languages too.

Once this is implemented, it would also be good to have built-in word lists for more languages (maybe even auto-detect the user's locale and change word list based on it?)

How?

The changes need to be done in RawWordSelector (source code).

  • Currently, it uses raw bytes (b'a', b'z', etc.) to compare and store characters. This needs to be changed to use the char type.
  • It tracks starting positions of each character in a fixed length array of 26 characters. This needs to be made more general.
  • Use unicode lowercase instead of ASCII -
    let line = buffer.to_ascii_lowercase();
  • Do not use is_ascii_alphabetic here -
    while word.len() < 2 || word.len() > 8 || !word.chars().all(|c| c.is_ascii_alphabetic()) {

This may require some more changes that I'm not yet aware of.

Please drop a comment if you find any inconsistencies or problems with this idea :)

@Samyak2 Samyak2 added enhancement New feature or request important Issues that need ot be solved soon labels Apr 4, 2022
@Samyak2
Copy link
Owner Author

Samyak2 commented Apr 5, 2022

Some suggestions from the author of terminal-typeracer: https://www.reddit.com/r/rust/comments/tvamfz/comment/i3eva1h/

@Samyak2 Samyak2 added the words Word selection, word lists, language support, etc. label Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request important Issues that need ot be solved soon words Word selection, word lists, language support, etc.
Projects
None yet
Development

No branches or pull requests

1 participant