Crates.io | yesorno |
lib.rs | yesorno |
version | 0.1.0 |
source | src |
created_at | 2021-09-12 13:54:56.31024 |
updated_at | 2021-09-12 13:54:56.31024 |
description | Useful for validating answers of a CLI prompt. |
homepage | https://github.com/sathishsoundharajan/yesorno |
repository | https://github.com/sathishsoundharajan/yesorno |
max_upload_size | |
id | 450100 |
size | 8,008 |
Useful for validating answers of a CLI prompt.
extern crate yesorno;
fn main() {
let is_yes = yesorno::is_yes("yes");
println!("Is Yes ? : {}", is_yes);
let is_no = yesorno::is_no("no");
println!("Is No ? : {}", is_no);
let is_lenient_yes = yesorno::is_lenient_yes("yrs");
println!("Is lenient Yes ? : {}", is_lenient_yes);
let is_lenient_no = yesorno::is_lenient_no("ni");
println!("Is lenient No ? : {}", is_lenient_no);
let is_yes_false = yesorno::is_yes("no");
println!("Is Yes ? : {}", is_yes_false);
}
Use key distance based score to leniently accept typos of yes
and no
. This is slightly simple
the original algorithm solved here in perl
Keyboard distance for fuzzy string matching. Keyboard distance is a measure of the physical distance between two keys on a keyboard. For example, 'g' has a distance of 1 from the keys 'r', 't', 'y', 'f', 'h', 'v', 'b', and 'n'. Immediate diagonals (like ''r, 'y', 'v', and 'n') are considered to have a distance of 0.75 and others are considered 0.25.