示例#1
0
        public override Rule Check(string word)
        {
            int    position           = this.index;
            string currentSingleVowel = word[position] + "";

            if (singleVowel.Contains(currentSingleVowel)) //nếu nó là nguyên âm
            {
                // Bắt buộc thêm nguyên âm cuối, hoặc phụ âm cuối: â
                currentSingleVowel = Rule.removeSign(currentSingleVowel);
                if (currentSingleVowel.Equals("â") && (position + 1 == word.Length))
                {
                    return(new Wrong());
                }

                // Bắt buộc thêm phụ âm cuối: ă
                if (currentSingleVowel.Equals("ă") && ((position + 1 == word.Length) || (singleVowel.Contains(word[position + 1] + ""))))
                {
                    return(new Wrong());
                }

                // Nếu nguyên âm ở cuối thì
                if ((position + 1 == word.Length))
                {
                    return(new Right());
                }

                Rule4 rule4 = new Rule4();
                rule4.index = position + 1; //tăng con trỏ lên 1
                return(rule4);
            }
            else //không phải nguyên âm
            {
                return(new Wrong());
            }
        }
示例#2
0
        public static string[] tripleVowel2 = { "iêu", "yêu", "oai", "oao", "oay", "oeo", "uai", "uây", "uôi", "ươi", "ươu", "uya", "uyu", "uay" }; // nguyên âm tam không thêm được phần âm cuối
        public override Rule Check(string word)
        {
            string temp     = Rule.removeSign(word);
            int    position = this.index;

            if (Rule1.singleConsonants.Contains(word[position] + "")) // nếu chữ cái tiếp theo là phụ âm - kiem tra phu am cuoi - khong tang con tro
            {
                if (!Rule4.checkSign(word, temp, position - 1))
                {
                    return(new Wrong());
                }

                Rule6 rule6 = new Rule6();
                rule6.index = position;
                return(rule6);
            }

            string currentTripleVowel = temp.Substring(position - 2, 3);

            if (tripleVowel.Contains(currentTripleVowel)) // nếu là nguyên âm tam
            {
                // Kiểm tra nếu xâu là tripleVowel1 và vị trí ở cuối từ hoặc sau nó là một nguyên âm
                if (tripleVowel1.Contains(currentTripleVowel))
                {
                    if (position + 1 == word.Length)
                    {
                        return(new Wrong());
                    }

                    if (Rule3.singleVowel.Contains(word[position + 1] + ""))
                    {
                        return(new Wrong());
                    }

                    if (!Rule4.checkSign(word, temp, position))
                    {
                        return(new Wrong());
                    }
                }


                // Kiểm tra nếu xâu là tripleVowel2 và vị trí ở cuối từ
                if (tripleVowel2.Contains(currentTripleVowel))
                {
                    if ((position + 1 == word.Length)) //nếu là ở cuối từ
                    {
                        if (!Rule4.checkSign(word, temp, position - 1))
                        {
                            return(new Wrong());
                        }
                        return(new Right());
                    }
                    else
                    {
                        return(new Wrong());
                    }
                }


                //Kiêm tra phu am cuối - tang con tro len 1
                Rule6 rule6 = new Rule6();
                rule6.index = position + 1;
                return(rule6);
            } // khong la nguyen am tam
            else
            {
                return(new Wrong());
            }
        }