langram/
lib.rs

1#[allow(unused_macros)]
2macro_rules! ahashmap {
3    (@single $($x:tt)*) => (());
4    (@count $($rest:expr),*) => (<[()]>::len(&[$(ahashmap!(@single $rest)),*]));
5
6    ($($key:expr => $value:expr,)+) => { ahashmap!($($key => $value),+) };
7    ($($key:expr => $value:expr),*) => {
8        {
9            let _cap = ahashmap!(@count $($key),*);
10            let mut _map = ::ahash::AHashMap::with_capacity(_cap);
11            $(
12                let _ = _map.insert($key, $value);
13            )*
14            _map.into()
15        }
16    };
17}
18
19#[allow(unused_macros)]
20macro_rules! ahashset {
21    (@single $($x:tt)*) => (());
22    (@count $($rest:expr),*) => (<[()]>::len(&[$(ahashset!(@single $rest)),*]));
23
24    ($($key:expr,)+) => { ahashset!($($key),+) };
25    ($($key:expr),*) => {
26        {
27            let _cap = ahashset!(@count $($key),*);
28            let mut _set = ::ahash::AHashSet::with_capacity(_cap);
29            $(
30                let _ = _set.insert($key);
31            )*
32            _set.into()
33        }
34    };
35}
36
37pub use alphabet_detector::ScriptLanguage;
38
39pub const NGRAM_MAX_SIZE: usize = 5;
40
41mod detector;
42mod file_model;
43mod fraction;
44mod ngrams;
45
46pub use detector::{Detector, DetectorConfig, ModelsStorage};
47pub use file_model::FileModel;
48pub use fraction::Fraction;