feat: regex
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
pub use leptess::{LepTess, Variable};
|
||||
|
||||
pub fn init_tesseract() -> Result<LepTess, String> {
|
||||
pub fn init_tesseract(numeric_only: bool) -> Result<LepTess, String> {
|
||||
let mut lep_tess = match LepTess::new(None, "eng") {
|
||||
Ok(lep_tess) => lep_tess,
|
||||
Err(why) => return Err(format!("Failed to initialize Tesseract: {:?}", why)),
|
||||
};
|
||||
match lep_tess.set_variable(Variable::TesseditCharWhitelist, "0123456789") {
|
||||
Ok(_) => (),
|
||||
Err(why) => return Err(format!("Failed to set whitelist: {:?}", why)),
|
||||
};
|
||||
if numeric_only {
|
||||
match lep_tess.set_variable(Variable::TesseditCharWhitelist, "0123456789") {
|
||||
Ok(_) => (),
|
||||
Err(why) => return Err(format!("Failed to set whitelist: {:?}", why)),
|
||||
};
|
||||
}
|
||||
Ok(lep_tess)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user