1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
pub use crateutils; // for doctest
use cratescramble_word;
/// typoglycemia() takes a string input and will scramble it according to
/// typoglycemic rules, i.e. where the first and last character of each word or
/// chunk remains in their position, respectively but interior characters
/// are randomly shuffled, e.g. "hello" => "hlelo"
///
/// # Arguments
///
/// - `s` (`&str`) - The input string or sentence
///
/// # Returns
///
/// - `String` - A typoglycemified String object
///
/// # Examples
///
/// ```
/// use typoglycemia::typoglycemia;
/// let result = typoglycemia("hello world");
/// let parts: Vec<&str> = result.split_whitespace().collect();
///
/// let v1 = vec!["hello", "hlelo", "hlleo"];
/// let v2 = vec!["world", "wolrd", "wlord", "wlrod", "wrlod", "wrold"];
///
/// let first_scrambled_word = parts.get(0).unwrap();
/// let second_scrambled_word = parts.get(1).unwrap();
///
/// assert!(v1.contains(first_scrambled_word));
/// assert!(v2.contains(second_scrambled_word));
///
/// ```
/// typoglycemia_leet() behaves the same as typoglycemia() but will do a
/// Leet-like substitution for certain characters, depending on the
/// level chosen.
///
/// Examples:
/// 'A' => 'Д'
/// 'B' | 'b' => '8'
/// 'c' => '¢'
/// 'E' => '€'
/// 'e' => '3'
/// 'H' => 'н'
/// 'I' | 'i' => '1'
/// 'M' => 'м'
/// 'N' => 'И'
/// 'n' => 'и'
/// 'O' => '0'
/// 'R' => 'Я'
/// 'S' | 's' => '$'
/// 'v' => '√'
/// 'W' => 'Ш'
/// 'Y' | 'y' => 'Ч'
/// '0' => 'O'
///
///
/// # Arguments
///
/// - `s` (`&str`) - The input string or sentence
/// - `level` (`u8`) - 1-3: Transliteration level with 1 being the most human readable
///
/// # Returns
///
/// - `String` - A typoglycemified String object
///
/// # Examples
///
/// ```
/// use typoglycemia::typoglycemia_leet;
/// let result = typoglycemia_leet("Rover", 1);
/// println!("{}", result);
///
/// let v1 = vec![
/// String::from("Яo√er"),
/// String::from("Яoe√r"),
/// String::from("Я√eor"),
/// String::from("Я√oer"),
/// String::from("Яeo√r"),
/// String::from("Яe√or")
/// ];
///
/// assert!(v1.contains(&result));
/// ```
///