Function rnltk::token::get_term_frequencies_from_word_vector
source · pub fn get_term_frequencies_from_word_vector(
word_tokens: Vec<&str>
) -> BTreeMap<String, f64>
Expand description
Gets a count of all words from a vector of word_tokens
.
Examples
use std::collections::BTreeMap;
use rnltk::token;
let arg = vec!["fear", "leads", "to", "anger", "anger", "leads", "to", "hatred", "hatred", "leads", "to", "conflict", "conflict", "leads", "to", "suffering"];
let word_counts = BTreeMap::from([("fear".to_string(), 1.), ("leads".to_string(), 4.), ("to".to_string(), 4.), ("anger".to_string(), 2.), ("hatred".to_string(), 2.), ("conflict".to_string(), 2.), ("suffering".to_string(), 1.)]);
let term_frequencies = token::get_term_frequencies_from_word_vector(arg);
assert_eq!(word_counts, term_frequencies);