pub fn split_romaji(input: &str) -> Vec<String> {
let mut result = Vec::new();
let chars: Vec<char> = input.chars().collect();
let mut i = 0;
let two_syllables = [
"a", "i", "u", "e", "o",
"ka", "ki", "ku", "ke", "ko",
"sa", "shi", "su", "se", "so",
"ta", "chi", "tsu", "te", "to",
"na", "ni", "nu", "ne", "no",
"ha", "hi", "fu", "he", "ho",
"ma", "mi", "mu", "me", "mo",
"ya", "yu", "yo",
"ra", "ri", "ru", "re", "ro",
"wa",
"ga", "gi", "gu", "ge", "go",
"za", "ji", "zu", "ze", "zo",
"da", "de", "do",
"ba", "bi", "bu", "be", "bo",
"pa", "pi", "pu", "pe", "po",
"fa", "fi", "fe", "fo",
"va", "vi", "vu", "ve", "vo",
];
let three_syllables = [
"kya", "kyu", "kyo",
"sha", "shi", "shu",
"she", "sho", "sha", "cha", "chu", "cho",
"nya", "nyu", "nyo",
"hya", "hyu", "hyo",
"mya", "myu", "myo",
"rya", "ryu", "ryo",
"gya", "gyu", "gyo",
"bya", "byu", "byo",
"pya", "pyu", "pyo",
"ja", "ju", "jo",
"tya", "tyu", "tyo", "chi", "cho", "cha",
"dya", "dyu", "dyo", "sya", "syu", "syo", ];
while i < chars.len() {
let rest = &chars[i..];
if rest.len() >= 3 {
let tri = rest[0..3].iter().collect::<String>();
if three_syllables.contains(&tri.as_str()) {
result.push(tri);
i += 3;
continue;
}
}
if rest.len() >= 2 {
let bi = rest[0..2].iter().collect::<String>();
if two_syllables.contains(&bi.as_str()) {
result.push(bi);
i += 2;
continue;
}
}
result.push(chars[i].to_string());
i += 1;
}
result
}