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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
pub mod unicode_block_hebrew {
use hebrew_unicode_script::HebrewUnicodeScript;
use std::borrow::Cow;
/// Shows all Hebrew acccents that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_accent;
///
/// let input_str = "לַ֭מְנַצֵּחַ";
/// let input_str_showed = show_hbr_accent(input_str);
/// assert_eq!(input_str_showed.as_ref(), "ל֭מנצח");
/// ```
pub fn show_hbr_accent(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_accent())
.collect()
}
/// Shows all Hebrew marks that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_mark;
///
/// let input_str = "כַ a כ֯ כׄ כׅ";
/// let input_str_showed = show_hbr_mark(input_str);
/// assert_eq!(input_str_showed.as_ref(),"כ a כ֯ כׄ כׅ");
/// ```
pub fn show_hbr_mark(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_mark())
.collect()
}
/// Shows all Hebrew points that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_point;
///
/// let input_str = "חֲ֝קַרְתַּ֗נִי";
/// let input_str_showed = show_hbr_point(input_str);
/// assert_eq!(input_str_showed.as_ref(),"חֲקַרְתַּנִי");
/// ```
pub fn show_hbr_point(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_point())
.collect()
}
/// Shows all Hebrew point vowels that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_point_vowel;
///
/// let input_str = "חֲ֝קַרְתַּ֗נִי";
/// let input_str_showed = show_hbr_point_vowel(input_str);
/// assert_eq!(input_str_showed.as_ref(),"חקַרתַנִי");
/// ```
pub fn show_hbr_point_vowel(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_point_vowel())
.collect()
}
/// Shows all Hebrew point semi-vowels that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_point_semi_vowel;
///
/// let input_str = "abc כֳ כֲ כֱ כְ";
/// let input_str_showed = show_hbr_point_semi_vowel(input_str);
/// assert_eq!(input_str_showed.as_ref(),"abc כֳ כֲ כֱ כְ");
/// ```
pub fn show_hbr_point_semi_vowel(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_point_semi_vowel())
.collect()
}
/// Shows all Hebrew point reading signs that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_point_reading_sign;
///
/// let input_str = "אִם־אֶסַּק";
/// let input_str_showed = show_hbr_point_reading_sign(input_str);
/// assert_eq!(input_str_showed.as_ref(),"אםאסּק");
/// ```
pub fn show_hbr_point_reading_sign(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_point_reading_sign())
.collect()
}
/// Shows all Hebrew punctuations that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_punctuation;
///
/// let input_str = "וַֽיְהִי־בֹ֖קֶר";
/// let input_str_showed = show_hbr_punctuation(input_str);
/// assert_eq!(input_str_showed.as_ref(),"ויהי־בקר");
/// ```
pub fn show_hbr_punctuation(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_punctuation())
.collect()
}
/// Shows all Hebrew letters (final and normal) that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_consonant;
///
/// let input_str = "A ֱאB ֟ףC";
/// let input_str_showed = show_hbr_consonant(input_str);
/// assert_eq!(input_str_showed.as_ref(),"A אB ףC");
/// ```
pub fn show_hbr_consonant(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant())
.collect()
}
/// Shows all Hebrew normal letters that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_consonant_normal;
///
/// let input_str = "AאB ףC";
/// let input_str_showed = show_hbr_consonant_normal(input_str);
/// assert_eq!(input_str_showed.as_ref(),"AאB C");
/// ```
pub fn show_hbr_consonant_normal(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant_normal())
.collect()
}
/// Shows all Hebrew final letters that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_consonant_final;
///
/// let input_str = "A אB ףC";
/// let input_str_showed = show_hbr_consonant_final(input_str);
/// assert_eq!(input_str_showed.as_ref(),"A B ףC");
/// ```
pub fn show_hbr_consonant_final(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant_final())
.collect()
}
/// Shows all Hebrew yod triangles that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_yod_triangle;
///
/// let input_str = format!("A{}Z לּ",'\u{05EF}');
/// let input_str_showed = show_hbr_yod_triangle(&input_str);
/// let expected_result = format!("A{}Z ל",'\u{05EF}');
/// assert_eq!(input_str_showed.as_ref(),expected_result);
/// ```
pub fn show_hbr_yod_triangle(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_yod_triangle())
.collect()
}
/// Shows all Yiddish ligatures that are found in the given string.
///
/// # Examples
/// ```
/// use hebrew_unicode_utils::show_hbr_ligature_yiddish;
///
/// let input_str = "X װױײ Z כֱ";
/// let input_str_showed = show_hbr_ligature_yiddish(input_str);
/// assert_eq!(input_str_showed.as_ref(),"X װױײ Z כ");
/// ```
pub fn show_hbr_ligature_yiddish(string: &str) -> Cow<'_, str> {
string
.chars()
.filter(|&c| !c.is_hbr_block() || c.is_hbr_consonant() || c.is_hbr_ligature_yiddish())
.collect()
}
}
#[cfg(test)]
mod unit_test {
use crate::*;
// #[test]
// fn test_showing_hbr_block() {
// let input_str = "וַֽיְחִי־שֵׁ֗םאַֽחֲרֵי֙הוֹלִיד֣וֹת׃";
// let input_str_showed = show_hbr_block(input_str);
// assert_eq!(input_str_showed.as_ref(), "");
// }
#[test]
fn test_showing_hbr_accent() {
let input_str = "בְּרֵאשִׁ֖ית";
let input_str_showed = show_hbr_accent(input_str);
assert_eq!(input_str_showed.as_ref(), "בראש֖ית");
}
#[test]
pub fn test_showing_hbr_mark() {
let input_str = "Q מִצְרָ֑יְמָה ה֯";
let input_str_showed = show_hbr_mark(input_str);
assert_eq!(input_str_showed.as_ref(), "Q מצרימה ה֯");
}
#[test]
pub fn test_showing_hbr_point() {
let input_str = "שִׁבְעִ֣ים";
let input_str_showed = show_hbr_point(input_str);
assert_eq!(input_str_showed.as_ref(), "שִׁבְעִים");
}
#[test]
pub fn test_showing_hbr_point_vowel() {
let input_str = "שִׁבְעִ֣יםֱ";
let input_str_showed = show_hbr_point_vowel(input_str);
assert_eq!(input_str_showed.as_ref(), "שִבעִים");
}
#[test]
pub fn test_showing_hbr_point_semi_vowel() {
let input_str = "ֲדְ נָפֶשׁ גֱכֳע";
let input_str_showed = show_hbr_point_semi_vowel(input_str);
assert_eq!(input_str_showed.as_ref(), "ֲדְ נפש גֱכֳע");
}
#[test]
pub fn test_showing_hbr_point_reading_sign() {
let input_str = "נִתְחַכְּמָה";
let input_str_showed = show_hbr_point_reading_sign(input_str);
assert_eq!(input_str_showed.as_ref(), "נתחכּמה");
}
#[test]
pub fn test_showing_hbr_punctuation() {
let input_str = "וַֽיְהִי־בֹ֖קֶר";
let input_str_showed = show_hbr_punctuation(input_str);
assert_eq!(input_str_showed.as_ref(), "ויהי־בקר");
}
#[test]
pub fn test_showing_hbr_consonant() {
let input_str = "A ֱאB ֵףC";
let input_str_showed = show_hbr_consonant(input_str);
assert_eq!(input_str_showed.as_ref(), "A אB ףC");
}
#[test]
pub fn test_showing_hbr_consonant_normal() {
let input_str = "A ֱאB ָףC";
let input_str_showed = show_hbr_consonant_normal(input_str);
assert_eq!(input_str_showed.as_ref(), "A אB C");
}
#[test]
pub fn test_showing_hbr_consonant_final() {
let input_str = "A ֱאB ָףC";
let input_str_showed = show_hbr_consonant_final(input_str);
assert_eq!(input_str_showed.as_ref(), "A B ףC");
}
#[test]
pub fn test_showing_hbr_yod_triangle() {
let input_str = format!("A הָבָה {} Z", '\u{05EF}');
let input_str_showed = show_hbr_yod_triangle(&input_str);
let expected_output = format!("A הבה {} Z", '\u{05EF}');
assert_eq!(input_str_showed.as_ref(), expected_output);
}
#[test]
pub fn test_showing_hbr_ligature_yiddish() {
let input_str = "X נִֽתְחַכְּמָ֖ה װױײ Z";
let input_str_showed = show_hbr_ligature_yiddish(input_str);
assert_eq!(input_str_showed.as_ref(), "X נתחכמה װױײ Z");
}
}