stop_words/
language_names.rs

1//! Module containing the huge language enum and formatting for it
2
3/// Enum containing available language names
4#[non_exhaustive]
5#[derive(Clone, Debug)]
6pub enum LANGUAGE {
7    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
8    /// Arabic (ISO 639-1 Code: ar)
9    Arabic,
10
11    #[cfg(feature = "nltk")]
12    /// Azerbaijani (ISO 639-1 Code: az)
13    Azerbaijani,
14
15    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
16    /// Danish (ISO 639-1 Code: da)
17    Danish,
18
19    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
20    /// Dutch (ISO 639-1 Code: nl)
21    Dutch,
22
23    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
24    /// English (ISO 639-1 Code: en)
25    English,
26
27    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
28    /// Finnish (ISO 639-1 Code: fi)
29    Finnish,
30
31    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
32    /// French (ISO 639-1 Code: fr)
33    French,
34
35    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
36    /// German (ISO 639-1 Code: de)
37    German,
38
39    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
40    /// Greek (ISO 639-1 Code: el)
41    Greek,
42
43    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
44    /// Hungarian (ISO 639-1 Code: hu)
45    Hungarian,
46
47    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
48    /// Indonesian (ISO 639-1 Code: id)
49    Indonesian,
50
51    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
52    /// Italian (ISO 639-1 Code: it)
53    Italian,
54
55    #[cfg(feature = "nltk")]
56    /// Kazakh (ISO 639-1 Code: kk)
57    Kazakh,
58
59    #[cfg(feature = "nltk")]
60    /// Nepali (ISO 639-1 Code: ne)
61    Nepali,
62
63    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
64    /// Norwegian (ISO 639-1 Code: no)
65    Norwegian,
66
67    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
68    /// Portuguese (ISO 639-1 Code: pt)
69    Portuguese,
70
71    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
72    /// Romanian (ISO 639-1 Code: ro)
73    Romanian,
74
75    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
76    /// Russian (ISO 639-1 Code: ru)
77    Russian,
78
79    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
80    /// Slovenian (ISO 639-1 Code: sl)
81    Slovenian,
82
83    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
84    /// Spanish (ISO 639-1 Code: sp)
85    Spanish,
86
87    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
88    /// Swedish (ISO 639-1 Code: sv)
89    Swedish,
90
91    #[cfg(feature = "nltk")]
92    /// Tajik (ISO 639-1 Code: tg)
93    Tajik,
94
95    #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
96    /// Turkish (ISO 639-1 Code: tk)
97    Turkish,
98
99    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
100    /// Afrikaans (ISO 639-1 Code: af)
101    Afrikaans,
102
103    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
104    /// Armenian (ISO 639-1 Code: hy)
105    Armenian,
106
107    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
108    /// Basque (ISO 639-1 Code: eu)
109    Basque,
110
111    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
112    /// Bengali (ISO 639-1 Code: bn)
113    Bengali,
114
115    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
116    /// Breton (ISO 639-1 Code: br)
117    Breton,
118
119    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
120    /// Bulgarian (ISO 639-1 Code: bg)
121    Bulgarian,
122
123    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
124    /// Catalan (ISO 639-1 Code: ca)
125    Catalan,
126
127    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
128    /// Czech (ISO 639-1 Code: cs)
129    Czech,
130
131    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
132    /// Chinese (ISO 639-1 Code: zh)
133    Chinese,
134
135    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
136    /// Esperanto (ISO 639-1 Code: eo)
137    Esperanto,
138
139    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
140    /// Estonian (ISO 639-1 Code: eo)
141    Estonian,
142
143    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
144    /// Persian (ISO 639-1 Code: fa)
145    Persian,
146
147    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
148    /// Irish (ISO 639-1 Code: ga)
149    Irish,
150
151    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
152    /// Galician (ISO 639-1 Code: gl)
153    Galician,
154
155    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
156    /// Gujarati (ISO 639-1 Code: gu)
157    Gujarati,
158
159    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
160    /// Hausa (ISO 639-1 Code: ha)
161    Hausa,
162
163    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
164    /// Hebrew (ISO 639-1 Code: he)
165    Hebrew,
166
167    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
168    /// Hindi (ISO 639-1 Code: hi)
169    Hindi,
170
171    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
172    /// Croatian (ISO 639-1 Code: hr)
173    Croatian,
174
175    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
176    /// Japanese (ISO 639-1 Code: ha)
177    Japanese,
178
179    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
180    /// Korean (ISO 639-1 Code: ko)
181    Korean,
182
183    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
184    /// Kurdish (ISO 639-1 Code: ku)
185    Kurdish,
186
187    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
188    /// Latin (ISO 639-1 Code: la)
189    Latin,
190
191    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
192    /// Latvian (ISO 639-1 Code: lv)
193    Latvian,
194
195    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
196    /// Lithuanian (ISO 639-1 Code: lt)
197    Lithuanian,
198
199    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
200    /// Marathi (ISO 639-1 Code: mr)
201    Marathi,
202
203    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
204    /// Malay (ISO 639-1 Code: ms)
205    Malay,
206
207    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
208    /// Polish (ISO 639-1 Code: pl)
209    Polish,
210
211    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
212    /// Slovak (ISO 639-1 Code: sk)
213    Slovak,
214
215    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
216    /// Somali (ISO 639-1 Code: so)
217    Somali,
218
219    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
220    /// Sotho (ISO 639-1 Code: st)
221    Sotho,
222
223    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
224    /// Swahili (ISO 639-1 Code: sw)
225    Swahili,
226
227    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
228    /// Taglog (ISO 639-1 Code: tl)
229    Tagalog,
230
231    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
232    /// Thai (ISO 639-1 Code: th)
233    Thai,
234
235    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
236    /// Ukrainian (ISO 639-1 Code: uk)
237    Ukrainian,
238
239    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
240    /// Urdu (ISO 639-1 Code: ur)
241    Urdu,
242
243    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
244    /// Vietnamese (ISO 639-1 Code: vi)
245    Vietnamese,
246
247    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
248    /// Yoruba (ISO 639-1 Code: yo)
249    Yoruba,
250
251    #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
252    /// Zulu (ISO 639-1 Code: zu)
253    Zulu,
254
255    #[cfg(feature = "unimplemented")]
256    /// Afar (ISO 639-1 Code: aa)
257    Afar,
258
259    #[cfg(feature = "constructed")]
260    /// Quenya (ISO 639-3 Code: qya)
261    Quenya,
262
263    #[cfg(feature = "constructed")]
264    /// Sindarin (ISO 639-3 Code: sjn)
265    Sindarin,
266
267    #[cfg(feature = "constructed")]
268    /// Klingon (ISO 639-3 Code: tlh)
269    Klingon,
270
271    #[cfg(feature = "constructed")]
272    /// Dothraki (ISO 639-3 Code: N/A, so _dot_ is used here)
273    Dothraki,
274
275    #[cfg(feature = "constructed")]
276    /// Dovahzul (ISO 639-3 Code: N/A, so _dov_ is used here)
277    Dovahzul,
278
279    #[cfg(feature = "constructed")]
280    /// Navi (ISO 639-3 Code: N/A, so _nav_ is used here)
281    Navi,
282
283    #[cfg(feature = "constructed")]
284    /// High Valyrian (ISO 639-3 Code: N/A, so _val_ is used here)
285    HighValyrian,
286}
287
288impl LANGUAGE {
289    /// Return the ISO language code for this variant.
290    #[must_use]
291    #[allow(clippy::too_many_lines)]
292    pub const fn as_str(&self) -> &'static str {
293        match self {
294            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
295            LANGUAGE::Arabic => "ar",
296            #[cfg(feature = "nltk")]
297            LANGUAGE::Azerbaijani => "az",
298            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
299            LANGUAGE::Danish => "da",
300            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
301            LANGUAGE::Dutch => "nl",
302            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
303            LANGUAGE::English => "en",
304            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
305            LANGUAGE::Finnish => "fi",
306            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
307            LANGUAGE::French => "fr",
308            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
309            LANGUAGE::German => "de",
310            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
311            LANGUAGE::Greek => "el",
312            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
313            LANGUAGE::Hungarian => "hu",
314            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
315            LANGUAGE::Indonesian => "id",
316            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
317            LANGUAGE::Italian => "it",
318            #[cfg(feature = "nltk")]
319            LANGUAGE::Kazakh => "kk",
320            #[cfg(feature = "nltk")]
321            LANGUAGE::Nepali => "ne",
322            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
323            LANGUAGE::Norwegian => "no",
324            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
325            LANGUAGE::Portuguese => "pt",
326            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
327            LANGUAGE::Romanian => "ro",
328            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
329            LANGUAGE::Russian => "ru",
330            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
331            LANGUAGE::Slovenian => "sl",
332            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
333            LANGUAGE::Spanish => "es",
334            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
335            LANGUAGE::Swedish => "sv",
336            #[cfg(feature = "nltk")]
337            LANGUAGE::Tajik => "tg",
338            #[cfg(all(any(feature = "nltk", feature = "iso"), not(feature = "constructed")))]
339            LANGUAGE::Turkish => "tr",
340            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
341            LANGUAGE::Afrikaans => "af",
342            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
343            LANGUAGE::Armenian => "hy",
344            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
345            LANGUAGE::Basque => "eu",
346            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
347            LANGUAGE::Bengali => "bn",
348            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
349            LANGUAGE::Breton => "br",
350            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
351            LANGUAGE::Bulgarian => "bg",
352            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
353            LANGUAGE::Catalan => "ca",
354            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
355            LANGUAGE::Czech => "cs",
356            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
357            LANGUAGE::Chinese => "zh",
358            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
359            LANGUAGE::Esperanto => "eo",
360            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
361            LANGUAGE::Estonian => "et",
362            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
363            LANGUAGE::Persian => "fa",
364            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
365            LANGUAGE::Irish => "ga",
366            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
367            LANGUAGE::Galician => "gl",
368            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
369            LANGUAGE::Gujarati => "gu",
370            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
371            LANGUAGE::Hausa => "ha",
372            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
373            LANGUAGE::Hebrew => "he",
374            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
375            LANGUAGE::Hindi => "hi",
376            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
377            LANGUAGE::Croatian => "hr",
378            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
379            LANGUAGE::Japanese => "ja",
380            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
381            LANGUAGE::Korean => "ko",
382            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
383            LANGUAGE::Kurdish => "ku",
384            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
385            LANGUAGE::Latin => "la",
386            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
387            LANGUAGE::Latvian => "lv",
388            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
389            LANGUAGE::Lithuanian => "lt",
390            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
391            LANGUAGE::Marathi => "mr",
392            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
393            LANGUAGE::Malay => "ms",
394            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
395            LANGUAGE::Polish => "pl",
396            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
397            LANGUAGE::Slovak => "sk",
398            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
399            LANGUAGE::Somali => "so",
400            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
401            LANGUAGE::Sotho => "st",
402            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
403            LANGUAGE::Swahili => "sw",
404            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
405            LANGUAGE::Tagalog => "tl",
406            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
407            LANGUAGE::Thai => "th",
408            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
409            LANGUAGE::Ukrainian => "uk",
410            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
411            LANGUAGE::Urdu => "ur",
412            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
413            LANGUAGE::Vietnamese => "vi",
414            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
415            LANGUAGE::Yoruba => "yo",
416            #[cfg(all(feature = "iso", not(feature = "nltk"), not(feature = "constructed")))]
417            LANGUAGE::Zulu => "zu",
418            #[cfg(feature = "unimplemented")]
419            LANGUAGE::Afar => "aa",
420            #[cfg(feature = "constructed")]
421            LANGUAGE::Quenya => "qya",
422            #[cfg(feature = "constructed")]
423            LANGUAGE::Sindarin => "sjn",
424            #[cfg(feature = "constructed")]
425            LANGUAGE::Klingon => "tlh",
426            #[cfg(feature = "constructed")]
427            LANGUAGE::Dothraki => "dot",
428            #[cfg(feature = "constructed")]
429            LANGUAGE::Dovahzul => "dov",
430            #[cfg(feature = "constructed")]
431            LANGUAGE::Navi => "nav",
432            #[cfg(feature = "constructed")]
433            LANGUAGE::HighValyrian => "val",
434        }
435    }
436}
437
438impl From<LANGUAGE> for String {
439    fn from(value: LANGUAGE) -> Self {
440        value.as_str().to_owned()
441    }
442}
443
444impl AsRef<str> for LANGUAGE {
445    fn as_ref(&self) -> &str {
446        self.as_str()
447    }
448}
449
450impl std::fmt::Display for LANGUAGE {
451    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
452        f.write_str(self.as_ref())
453    }
454}