Function wordfreq::word_weights_from_text
source · pub fn word_weights_from_text<R: BufRead>(
rdr: R
) -> Result<Vec<(String, Float)>>
Expand description
Parses pairs of a word and its weight from a text file, where each line has a word and its weight sparated by the ASCII whitespace.
<word> <weight>
Examples
let word_weight_text = "las 10\nvegas 30\n";
let word_weights = wordfreq::word_weights_from_text(word_weight_text.as_bytes())?;
assert_eq!(
word_weights,
vec![("las".to_string(), 10.), ("vegas".to_string(), 30.)]
);