1#![warn(clippy::all)]
2#![warn(missing_docs)]
3#![warn(clippy::missing_docs_in_private_items)]
4#![doc = include_str!("../README.md")]
5
6mod language_names;
7pub use language_names::LANGUAGE;
8
9pub fn get<T: Into<String>>(input_language: T) -> Vec<String> {
19 let language_name_as_string = input_language.into();
21
22 let json_as_bytes: &[u8] = if cfg!(feature = "nltk") {
24 include_bytes!(concat!(env!("OUT_DIR"), "/stopwords-nltk.json"))
25 } else if cfg!(feature = "constructed") {
26 include_bytes!(concat!(env!("OUT_DIR"), "/stopwords-constructed.json"))
27 } else {
28 include_bytes!("iso/stopwords-iso.json")
29 };
30
31 let mut json: serde_json::Value = serde_json::from_slice(json_as_bytes)
33 .expect("Could not read JSON file from Stopwords ISO.");
34
35 json.get_mut(&language_name_as_string)
37 .take()
38 .unwrap_or_else(|| panic!("The '{language_name_as_string}' language is not recognized. Please check the documentation for a supported list of languages."))
39 .as_array_mut()
40 .expect("The referenced value is not a mutable array.")
41 .iter_mut()
42 .map(|x| {
43 let x = x.take();
44 if let serde_json::Value::String(s) = x {
45 s
46 } else {
47 panic!("The referenced value is not a string.")
48 }
49 })
50 .collect()
51}