MCPcopy Create free account
hub / github.com/daisy/MathCAT / test_intent

Function test_intent

src/infer_intent.rs:428–456  ·  view source on GitHub ↗
(mathml: &str, target: &str, intent_error_recovery: &str)

Source from the content-addressed store, hash-verified

426
427
428 fn test_intent(mathml: &str, target: &str, intent_error_recovery: &str) -> bool {
429 use crate::interface::*;
430 // this forces initialization
431 crate::interface::set_rules_dir(super::super::abs_rules_dir_path()).unwrap();
432 crate::speech::SpeechRules::initialize_all_rules().unwrap();
433 set_preference("IntentErrorRecovery".to_string(), intent_error_recovery.to_string()).unwrap();
434 let package1 = &parser::parse(mathml).expect("Failed to parse test input");
435 let mathml = get_element(package1);
436 trim_element(&mathml);
437 debug!("test: {}", crate::pretty_print::mml_to_string(&mathml));
438
439 let package2 = &parser::parse(target).expect("Failed to parse target input");
440 let target = get_element(package2);
441 trim_element(&target);
442 debug!("target: {}", crate::pretty_print::mml_to_string(&target));
443
444 let result = match crate::speech::intent_from_mathml(mathml, package2.as_document()) {
445 Ok(e) => e,
446 Err(e) => {
447 debug!("{}", crate::interface::errors_to_string(&e));
448 return false; // could be intentional failure
449 }
450 };
451 debug!("result: {}", crate::pretty_print::mml_to_string(&result));
452 match is_same_element(&result, &target) {
453 Ok(_) => return true,
454 Err(e) => panic!("{}", e),
455 }
456 }
457
458 #[test]
459 fn infer_binomial() {

Callers

nothing calls this directly

Calls 7

set_rules_dirFunction · 0.85
set_preferenceFunction · 0.85
get_elementFunction · 0.85
trim_elementFunction · 0.85
intent_from_mathmlFunction · 0.85
is_same_elementFunction · 0.85
abs_rules_dir_pathFunction · 0.70

Tested by

no test coverage detected