Skip to content

Commit

Permalink
change: use AHashMap instead
Browse files Browse the repository at this point in the history
  • Loading branch information
shenxiangzhuang committed May 14, 2024
1 parent 16208a9 commit 0d47640
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/ngram.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use counter::Counter;
use std::collections::HashMap;
use ahash::AHashMap;

/// Here the tokens' type is `&[String]` rather than `&Vec<String>`
/// to fix `clippy::not_unsafe_ptr_arg_deref` error.
pub fn get_token_ngram_counter(tokens: &[String], max_order: usize) -> HashMap<&[String], usize> {
let mut count_map: HashMap<&[String], usize> = HashMap::new();
pub fn get_token_ngram_counter(tokens: &[String], max_order: usize) -> AHashMap<&[String], usize> {
let mut count_map: AHashMap<&[String], usize> = AHashMap::new();
for order in 1..=max_order {
for start_index in 0..(tokens.len().saturating_sub(order - 1)) {
let ngram = &tokens[start_index..(start_index + order)];
Expand Down

0 comments on commit 0d47640

Please sign in to comment.