1#[deprecated(since="2.0.0", note="!!!THIS CRATE SHOULD NOT BE USED AS IT WON'T BE LONGER MAINTAINED!!! async_get_words() is deprecated! use get_words() instead!")]
2pub async fn async_get_words (){
3 println!("async_get_words() is deprecated! use get_words() instead");
4 std::process::exit(-1);
5}
6
7#[deprecated(since="2.1.0", note="!!!THIS CRATE SHOULD NOT BE USED AS IT WON'T BE LONGER MAINTAINED!!!")]
8#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Clone, Default)]
9pub struct Word{
10 pub value: String,
11 pub amount: u64
12}
13
14#[deprecated(since="2.1.0", note="!!!THIS CRATE SHOULD NOT BE USED AS IT WON'T BE LONGER MAINTAINED!!!")]
15pub fn get_words(input: &str, ignored_chars: std::collections::HashSet<char>) -> Vec<Word>{
16 let mut inside_closure = (false, ' ');
17 let mut temp_buf = Vec::new();
18 let mut final_vector = Vec::new();
19 let mut temp_hashmap : std::collections::HashMap<String, u64> = std::collections::HashMap::new();
20 for c in input.chars().collect::<Vec<char>>(){
21 if inside_closure == (true, '\"') && c == '\"'{
22 if let Some(element) = temp_hashmap.get(&String::from_iter(temp_buf.iter())) {
23 temp_hashmap.insert(String::from_iter(temp_buf.iter()).trim().to_string(), *element+1);
24 }
25 else{
26 temp_hashmap.insert(String::from_iter(temp_buf.iter()).trim().to_string(), 1);
27 }
28 temp_buf = Vec::new();
29 inside_closure = (false, ' ');
30 continue;
31 }
32 else if inside_closure == (true, '\'') && c == '\"'{
33 if let Some(element) = temp_hashmap.get(&String::from_iter(temp_buf.iter()).trim().to_string()) {
34 temp_hashmap.insert(String::from_iter(temp_buf.iter()).trim().to_string(), *element+1);
35 }
36 else{
37 temp_hashmap.insert(String::from_iter(temp_buf.iter()).trim().to_string(), 1);
38 }
39 temp_buf = Vec::new();
40 inside_closure = (false, ' ');
41 continue;
42 }
43 else if inside_closure == (false, ' ') && c == '\"' || c == '\''{
44 inside_closure = (true, c);
45 continue;
46 }
47 else if c == ' ' && inside_closure == (false, ' '){
48 if let Some(element) = temp_hashmap.get(&String::from_iter(temp_buf.iter()).trim().to_string()) {
49 temp_hashmap.insert(String::from_iter(temp_buf.iter()).trim().to_string(), *element+1);
50 }
51 else{
52 temp_hashmap.insert(String::from_iter(temp_buf.iter()).trim().to_string(), 1);
53 }
54 temp_buf = Vec::new();
55 }
56 else{
57 if !ignored_chars.contains(&c){
58 temp_buf.push(c);
59 }
60 }
61 }
62
63 if !temp_buf.is_empty(){
64 if let Some(element) = temp_hashmap.get(&String::from_iter(temp_buf.iter()).trim().to_string()) {
65 temp_hashmap.insert(String::from_iter(temp_buf.iter()).trim().to_string(), *element+1);
66 }
67 else{
68 temp_hashmap.insert(String::from_iter(temp_buf.iter()).trim().to_string(), 1);
69 }
70 }
71
72 for key in temp_hashmap.keys(){
73 if let Some(el) = temp_hashmap.get(key){
74 final_vector.push(Word{value: key.clone(), amount: *el});
75 }
76 }
77
78 return final_vector;
79}