Generic NGram class