Example #1
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());
            }
        }
Example #2
0
        public static string[] doubleVowel4 = { "oa", "oe", "uê", "uy" };                                                                                //có thể đứng tự do một mình hoặc thêm âm đầu, cuối, hoặc cả đầu lẫn cuối
        public override Rule Check(string word)
        {
            string temp               = Rule.removeSign(word);
            int    position           = this.index;
            string currentDoubleVowel = temp.Substring(position - 1, 2);

            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
            {
                Rule6 rule6 = new Rule6();
                rule6.index = position;
                return(rule6);
            }

            //new la nguyen am check nguyen am doi
            if (doubleVowel.Contains(currentDoubleVowel)) //Nếu nó là nguyên âm đôi
            {
                // Kiểm tra nếu xâu là doubleVowel1  (sau nó có nguyên âm cuối, hoặc phụ âm cuối)
                if (doubleVowel1.Contains(currentDoubleVowel))
                {
                    if (position + 1 == word.Length) // và vị trí ở cuối từ
                    {
                        return(new Wrong());
                    }
                    if (!checkSign(word, temp, position))
                    {
                        return(new Wrong());
                    }
                }

                // Kiểm tra nếu xâu là doubleVowel2 và vị trí ở cuối từ hoặc sau nó là một nguyên âm
                if (doubleVowel2.Contains(currentDoubleVowel))
                {
                    if (position + 1 == word.Length) // nếu ở cuối từ
                    {
                        return(new Wrong());
                    }
                    if (Rule3.singleVowel.Contains(word[position + 1] + "")) // nếu sau đó là 1 nguyên âm
                    {
                        return(new Wrong());
                    }
                    if (!checkSign(word, temp, position))
                    {
                        return(new Wrong());
                    }
                    //Kiểm tra phụ âm cuối
                    Rule6 rule6 = new Rule6();
                    rule6.index = position + 1;
                    return(rule6);
                }

                // Kiểm tra nếu xâu là doubleVowel3 và vị trí ở cuối từ
                if (doubleVowel3.Contains(currentDoubleVowel))
                {
                    if (position + 1 != word.Length) //nếu ko là ở vị trí cuối từ
                    {
                        return(new Wrong());
                    }
                    if (!checkSign(word, temp, position - 1))//nếu đặt sai dấu
                    {
                        return(new Wrong());
                    }
                    return(new Right());
                }

                // Kiểm tra nếu xâu là doubleVowel4 vị trí ở cuối từ hoặc đứng một mình
                if (doubleVowel4.Contains(currentDoubleVowel))
                {
                    if (position + 1 == word.Length)
                    {
                        if ((!word.Equals(temp)) && (temp[position] != word[position]) && (temp[position - 1] != word[position - 1]))
                        {
                            return(new Wrong());
                        }
                        return(new Right());
                    }
                }
                Rule5 rule5 = new Rule5();
                rule5.index = position + 1;
                return(rule5);
            }
            else
            {
                return(new Wrong());
            }
        }