rarity 0.3.0

Library of useful functions.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use super::md_to_plaintext::parse;
use regex::Regex;

pub fn word_count(text: String) -> usize {
	let plain_text = parse(text);
	remove_punctuation(plain_text).split_whitespace().count()
}

pub fn remove_punctuation(text: String) -> String {
	let re = Regex::new(r"!([\'’]([tsd]\b|ve\b|ll\b|re\b))").unwrap();
	let text = re.replace_all(&text, "");
	let re = Regex::new(r"[^\w\s\'’]").unwrap();
	re.replace_all(&text, "").into()
}