/// <summary> /// Check if the syllable has vowel or has a sonorant phoneme. /// </summary> /// <param name="entry">Script entry.</param> /// <param name="phoneme">Phoneme.</param> /// <param name="phones">Phones of the syllable.</param> /// <returns>Bool.</returns> private static bool IsGoodSyllableWithSonorant(ScriptItem entry, Phoneme phoneme, string[] phones) { bool goodSyllable = IsSyllableWithLessVowel(entry, phoneme, phones); if (goodSyllable) { if (!IsSyllableWithEnoughVowel(entry, phoneme, phones)) { if (phoneme.GetVowelIndexes(phones).Length == 0) { // no vowel, should have one sonorant and more than one consonants int[] sonorantIndexes = phoneme.GetSonorantIndexes(phones); if (sonorantIndexes.Length == 0 || phones.Length == 1) { goodSyllable = false; } } else { goodSyllable = false; } } } return goodSyllable; }
/// <summary> /// Check if the syllable has too many vowels. /// </summary> /// <param name="entry">Script entry.</param> /// <param name="phoneme">Phoneme.</param> /// <param name="phones">Phones of the syllable.</param> /// <returns>True if not having too many.</returns> private static bool IsSyllableWithLessVowel(ScriptItem entry, Phoneme phoneme, string[] phones) { int[] vowelIndexes = phoneme.GetVowelIndexes(phones); return vowelIndexes.Length <= entry.MaxVowelCountInSyllable; }