cum 0.2.0

Cumulative operation helper functions
Documentation
use std::collections::HashMap;
use std::collections::HashSet;

/// Creates a tuple of overlapping words and their 
/// frequency found within a vector of Strings.
///
/// Arguments:
///
/// * `vec`: A vector of Strings, with each String
/// representing a sentence.
///
/// Returns:
///
/// A matrix where each row is a unique word and
/// a second column representing its frequency
///
pub fn overlap(vec: Vec<String>) -> HashSet<(String, u32)> {
    let mut words: HashSet<(String, u32)> = HashSet::new();
    let mut word_freq: HashMap<String, u32> = HashMap::new();

    // Strings
    for string in vec.iter() {
        // Words
        for word in string.split_ascii_whitespace() {
            let presumed_value: u32 = *word_freq.get(&word.to_owned()).unwrap_or(&1);

            word_freq.insert(word.to_owned(), presumed_value+1);
        }
    }

    for (k, v) in word_freq.iter() {
        words.insert((k.clone(), *v));
    }

    println!("{:?}", words);

    words
}