コード例 #1
0
        private void BuildPatterns()
        {
            /// Phonemes must be ordered by string length, else there will be false
            /// positive results which ends as wrong recognition

            var vowels_for_pattern     = Vowels.OrderByDescending(n => n.Length).ToList();
            var consonants_for_pattern = Consonants.OrderByDescending(n => n.Length).ToList();
            var rests_for_pattern      = Rests.OrderByDescending(n => n.Length).ToList();


            VowelPattern     = $"{String.Join("|", vowels_for_pattern)}";
            ConsonantPattern = $"{String.Join("|", consonants_for_pattern)}";
            RestPattern      = $"{String.Join("|", rests_for_pattern)}";
            foreach (var shit in ". ? ( ) [ ] * \\".Split(' '))
            {
                VowelPattern     = VowelPattern.Replace(shit, "\\" + shit);
                ConsonantPattern = ConsonantPattern.Replace(shit, "\\" + shit);
                RestPattern      = RestPattern.Replace(shit, "\\" + shit);
            }
            VowelPattern     = $"({VowelPattern})";
            ConsonantPattern = $"({ConsonantPattern})";
            RestPattern      = $"({RestPattern})";
        }