1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use std::collections::hash_map::{HashMap};
use klpair::KLPair;
#[derive(Clone, Debug)]
pub struct Exceptions(pub HashMap<String, Vec<u32>>);
impl Exceptions {
pub fn empty() -> Exceptions {
Exceptions(HashMap::new())
}
pub fn insert(&mut self, klpair: KLPair) {
let (p, tally) = klpair;
let Exceptions(ref mut m) = *self;
m.insert(p, tally);
}
pub fn score(&self, word: &str) -> Option<&Vec<u32>> {
let Exceptions(ref m) = *self;
let w = word.to_lowercase();
m.get(&w)
}
}