Skip to content

Commit

Permalink
Actual boolean matching for English.
Browse files Browse the repository at this point in the history
  • Loading branch information
waywardmonkeys committed Jul 24, 2016
1 parent e860d6d commit 8089dc1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/matchers/english/boolean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@ pub fn register(parser: &mut Parser) {
name: "English Booleans",
language: langtag!(en),
result_type: ValueType::Boolean,
matcher: Box::new(move |_text: &str| -> Option<HumanValue> {
Some(HumanValue::Boolean(true))
}),
matcher: Box::new(match_boolean),
});
}

fn match_boolean(text: &str) -> Option<HumanValue> {
match &*text.to_lowercase() {
"on" | "yes" | "true" | "ok" | "1" | "okay" => Some(HumanValue::Boolean(true)),
"off" | "no" | "false" | "0" => Some(HumanValue::Boolean(false)),
_ => None,
}
}

0 comments on commit 8089dc1

Please sign in to comment.