Skip to content

sathishsoundharajan/yesorno

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

yesorno

Useful for validating answers of a CLI prompt.

Usage

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);
}

What is lenient ?

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.

Similar Question

About

Useful for validating answers of a CLI prompt for yes or no

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages