Skip to content

Commit

Permalink
return fail if too low
Browse files Browse the repository at this point in the history
  • Loading branch information
flammie committed Jan 29, 2025
1 parent 706c4d5 commit 0637c74
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions accuracy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ fn main() -> Result<(), Box<dyn Error>> {
.takes_value(true)
.help("Truncate typos list to max number of words specified"),
)
.arg(
Arg::with_name("threshold")
.short("T")
.takes_value(true)
.help("Minimum precision @ 5 for automated testing"),
)
.get_matches();

let cfg: SpellerConfig = match matches.value_of("config") {
Expand Down Expand Up @@ -292,7 +298,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let report = Report {
metadata: archive.metadata(),
config: &cfg,
summary,
summary: summary.clone(),
results,
start_timestamp,
total_time,
Expand Down Expand Up @@ -343,5 +349,16 @@ fn main() -> Result<(), Box<dyn Error>> {
};

println!("Done!");
Ok(())
match matches.value_of("threshold") {
Some(threshold) => {
if threshold.parse::<f32>().unwrap() < (summary.top_five as f32/
summary.total_words as f32 * 100.0) {
Ok(())
}
else {
Err("accuracy @5 lower threshold")?
}
},
None => Ok(())
}
}

0 comments on commit 0637c74

Please sign in to comment.