custom_config/
custom_config.rs1use kenlm::{ArpaLoadComplain, Config, LoadMethod, Model};
2use std::env;
3
4fn main() -> Result<(), kenlm::KenlmError> {
5 let model_path = env::args()
6 .nth(1)
7 .unwrap_or_else(|| "lm/test.arpa".to_string());
8
9 let config = Config {
10 show_progress: false,
11 arpa_complain: ArpaLoadComplain::None,
12 load_method: LoadMethod::Lazy,
13 ..Config::default()
14 };
15
16 let model = Model::with_config(model_path, config)?;
17
18 for word in ["looking", "definitely-not-in-this-model", "<s>", "</s>"] {
19 let index = model.index(word)?;
20 println!("{word}\tindex={index}\tin_vocab={}", model.contains(word)?);
21 }
22
23 Ok(())
24}