pub fn get_term_frequencies_from_sentences(
    sentences: &[&str]
) -> Vec<BTreeMap<String, f64>>
Expand description

Gets a count of all words from a vector of sentences.

Examples

use std::collections::BTreeMap;
use rnltk::token;
 
let sentences = vec!["fear leads to anger", "anger leads to hatred", "hatred leads to conflict", "conflict leads to suffering."];
let word_counts1 = BTreeMap::from([
    ("fear".to_string(), 1.), ("leads".to_string(), 1.), ("to".to_string(), 1.), ("anger".to_string(), 1.), ("hatred".to_string(), 0.), ("conflict".to_string(), 0.), ("suffering".to_string(), 0.)
]);
let word_counts2 = BTreeMap::from([
    ("fear".to_string(), 0.), ("leads".to_string(), 1.), ("to".to_string(), 1.), ("anger".to_string(), 1.), ("hatred".to_string(), 1.), ("conflict".to_string(), 0.), ("suffering".to_string(), 0.)
]);
let word_counts3 = BTreeMap::from([
    ("fear".to_string(), 0.), ("leads".to_string(), 1.), ("to".to_string(), 1.), ("anger".to_string(), 0.), ("hatred".to_string(), 1.), ("conflict".to_string(),1.), ("suffering".to_string(), 0.)
]);
let word_counts4 = BTreeMap::from([
    ("fear".to_string(), 0.), ("leads".to_string(), 1.), ("to".to_string(), 1.), ("anger".to_string(), 0.), ("hatred".to_string(), 0.), ("conflict".to_string(), 1.), ("suffering".to_string(), 1.)
]);
let term_frequencies = token::get_term_frequencies_from_sentences(&sentences);

assert_eq!(vec![word_counts1, word_counts2, word_counts3, word_counts4], term_frequencies);