diff --git a/src/lib.rs b/src/lib.rs index 6295c0e..73d86f4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,11 +39,12 @@ impl Segmenter { unigrams: HashMap, bigrams: HashMap<(String, String), f64>, ) -> Self { + let total = unigrams.values().sum(); Self { unigrams, bigrams, limit: DEFAULT_LIMIT, - total: DEFAULT_TOTAL, + total, } } @@ -201,7 +202,6 @@ impl Index> for Ascii { type HashMap = std::collections::HashMap; const DEFAULT_LIMIT: usize = 24; -const DEFAULT_TOTAL: f64 = 1_024_908_267_229.0; const SEGMENT_SIZE: usize = 250; #[cfg(test)]