Comments (6)
@max-niederman Awesome, let me know when you merge it into master and then I'll rewrite and finish my PR 👍🏻
from ttyper.
I would like to work on this 😄
from ttyper.
I laid out the rough outline for this solution right now but it's a little hacky in my opinion. Storing the keys as [Fraction; 256]
makes it really annoying to get the data, particularly sorting to get the worst keys. I feel like rewriting to use a HashMap<char, Fraction> would be much cleaner and more extendible. @max-niederman What do you think?
// get top 5 worst keys
let mut worst_key_display_str = String::from("Worst Keys:");
let mut key_and_cps_list: Vec<(char, f64)> = Vec::new();
for i in 0..256 {
let temp = self.cps.per_key[i];
let ascii_char = i as u8 as char;
if temp.is_nan() || ascii_char == AsciiChar::BackSpace {
continue;
}
key_and_cps_list.push((ascii_char, temp));
}
key_and_cps_list.sort_by(|a, b| {
let f1 = a.1;
let f2 = b.1;
f1.partial_cmp(&f2).unwrap()
});
for key_and_cps_pair in key_and_cps_list[0..std::cmp::min(key_and_cps_list.len(), 5)].iter()
{
worst_key_display_str = format!(
"{}\n- '{}' at {:.2} cps",
worst_key_display_str, key_and_cps_pair.0, key_and_cps_pair.1
);
}
info_text.extend(Text::from(worst_key_display_str))
Below is an example of the output. I'm not really feeling this implementation with cps
, and I'm going to use accuracy
instead.
from ttyper.
Storing the keys as
[Fraction; 256]
makes it really annoying to get the data, particularly sorting to get the worst keys. I feel like rewriting to use a HashMap<char, Fraction> would be much cleaner and more extendible.
Yeah, it would probably be a good idea to rewrite the results to use a HashMap<char, T>
not only for this feature, but also to better support unicode.
from ttyper.
Actually, now I think about it, we could just use a HashMap<KeyEvent, T>
. @reaganmcf I'm going to work on switching to HashMap for the Results code.
from ttyper.
@reaganmcf I've merged the changes with master
from ttyper.
Related Issues (20)
- Add CLI arg to disable the backspace key
- Pull real world quotes from Wikipedia or similar.
- Fails with "cargo install ttyper"! HOT 2
- wordcount to screen HOT 1
- [Feature Request] Sudden death mode HOT 1
- [Feature Request] Add option to not show the typing output HOT 1
- Code clarity: consider renaming "Test" to "Exam" or something HOT 1
- "Bug" report: Holding control while typing letters causes the letters to be typed still
- [Feature request] Option to read text data for typing from file or stdin HOT 1
- Incorrectly showing underlines in Conemu on Windows 7 HOT 2
- [Feature Request] Import quotes or paragraph from json file or standard output. HOT 1
- [Feature Request] add the keybind to restart the typing test on click of "TAB" key HOT 2
- Piped text into ttyper can sometimes prematurely terminate
- [Feature] Keystroke dwelling (or key-hold) time stat
- Add a flag to only allow move to next word if the current word is correct HOT 1
- Terminal output breaks when invalid language is passed HOT 1
- Add an option to provide the punctuation marks
- custom default_language filepath
- Option for hard corners
- Command line arguments specification with '=' doesn't work HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ttyper.