예제 #1
0
        /// <summary>
        /// Check is Takai Akhar sap paoh deng likuk
        /// </summary>
        /// <param name="sabaoh">akhar</param>
        protected bool Check_TakaiSapPaohLikuk(Model.AKhar sabaoh)
        {
            //MCMC
            Model.AKhar[] arr_TakaiAkharLikuk = new Model.AKhar[]
            { Model.AKhar.TakaiKik, Model.AKhar.TakaiKikTutTakaiMâkDalem, Model.AKhar.TakaiThek,
              Model.AKhar.TakaiKuk, Model.AKhar.TakaiKâk, Model.AKhar.TraohAw, Model.AKhar.BalauTapong };

            return(Array.IndexOf(arr_TakaiAkharLikuk, sabaoh) != -1);
        }
예제 #2
0
        protected bool CheckEndCharacter(Model.AKhar sabaoh)
        {
            Model.AKhar[] endCharacters = new Model.AKhar[]
            { Model.AKhar.PaohNgâk, Model.AKhar.TakaiKikTutTakaiMâkDalem,
              Model.AKhar.TakaiKikTutTakaiMâkLingiw, Model.AKhar.TakaiKikTutTakaiYak, Model.AKhar.TakaiThekTutTakaiMâk,
              Model.AKhar.TakaiThekPaohNgâk, Model.AKhar.TraohAwPaohNgâk, Model.AKhar.TraohAwTutTakaiMâk };

            return((sabaoh >= Model.AKhar.KakMatai && sabaoh <= Model.AKhar.PaohDaNih) ||
                   Array.IndexOf(endCharacters, sabaoh) != -1);
        }
예제 #3
0
        /// <summary>
        /// Check is Lang likuk
        /// </summary>
        /// <param name="sabaoh">akhar</param>
        protected bool Check_LangLiKuk(Model.AKhar sabaoh)
        {
            //MCMC
            Model.AKhar[] arr_langlikuk = new Model.AKhar[]
            { Model.AKhar.Kak, Model.AKhar.Khak, Model.AKhar.Gak, Model.AKhar.Cak, Model.AKhar.Jak, Model.AKhar.Tak, Model.AKhar.Dak, Model.AKhar.Nâk, Model.AKhar.Nak,
              Model.AKhar.Pak, Model.AKhar.Bak, Model.AKhar.Mâk, Model.AKhar.Mak, Model.AKhar.Yak, Model.AKhar.Rak, Model.AKhar.Lak,
              Model.AKhar.Xak, Model.AKhar.Hak, Model.AKhar.PakPraong, Model.AKhar.SakPraong, Model.AKhar.Ak, Model.AKhar.Ik, Model.AKhar.Uk };

            return(Array.IndexOf(arr_langlikuk, sabaoh) != -1);
        }
예제 #4
0
 /// <summary>
 /// Check is Takai Akhar deng likuk
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_TakaiAkharLikuk(Model.AKhar sabaoh)
 {
     //MCMC
     Model.AKhar[] arr_TakaiAkharLikuk = new Model.AKhar[]
     {
         Model.AKhar.TakaiKiak, Model.AKhar.TakaiKuak,
         Model.AKhar.TakaiKlak, Model.AKhar.TakaiKlakTakaiKuak, Model.AKhar.TakaiKlakTakaiKuk
     };
     return(Array.IndexOf(arr_TakaiAkharLikuk, sabaoh) != -1);
 }
        /// <summary>
        /// Get next akhar
        /// </summary>
        /// <param name="word">word by rumi</param>
        /// <returns>akhar cam</returns>
        private Model.AKhar GetNextChar(String word)
        {
            Model.AKhar        ret           = Model.AKhar.Square;
            List <Model.AKhar> nextAkharList = this.ToKeyCodeByChar(ref word);

            if (nextAkharList.Count != 0)
            {
                ret = nextAkharList[0];
            }

            return(ret);
        }
예제 #6
0
        /// <summary>
        /// Check is Takai Akhar sap paoh deng luic di abih
        /// </summary>
        /// <returns></returns>
        protected bool Check_TakaiSapPaohDiLuic(Model.AKhar sabaoh)
        {
            //MCMC
            Model.AKhar[] arr_TakaiAkharLikuk = new Model.AKhar[]
            {
                Model.AKhar.TakaiThekPaohNgâk, Model.AKhar.TakaiThekTutTakaiMâk,
                Model.AKhar.TakaiKikTutTakaiMâkLingiw, Model.AKhar.TakaiKikTutTakaiYak,
                Model.AKhar.TraohAwTutTakaiMâk, Model.AKhar.TraohAwPaohNgâk
            };

            return(Array.IndexOf(arr_TakaiAkharLikuk, sabaoh) != -1);
        }
예제 #7
0
        /// <summary>
        /// Get index of akhar diip
        /// </summary>
        /// <param name="list">akhar list</param>
        /// <returns>index of akhar diip</returns>
        protected int GetIndexAkharDiip(List <Model.AKhar> list)
        {
            for (int i = list.Count - 1; i >= 0; i--)
            {
                Model.AKhar akhar = list[i];
                if (this.Check_InaAkhar_NguyenAm(akhar) || this.Check_InaAkhar_PhuAm(akhar))
                {
                    return(i);
                }
            }

            return(list.Count);
        }
예제 #8
0
        /// <summary>
        /// Get index of last char
        /// </summary>
        /// <param name="list">akhar list</param>
        /// <returns>index of last char</returns>
        protected int GetIndexLastChar(List <Model.AKhar> list)
        {
            int ret = list.Count - 1;

            for (int i = ret; i >= 0; i--)
            {
                Model.AKhar akhar = list[i];
                if (!this.Check_DauCau(akhar))
                {
                    ret = i;
                    break;
                }
            }

            return(ret);
        }
예제 #9
0
        /// <summary>
        /// Cut kanaing at last of akhar list
        /// </summary>
        /// <param name="list">akhar list</param>
        /// <returns>Stack of akhar</returns>
        protected Stack <Model.AKhar> CutKanaingAtLast(ref List <Model.AKhar> list)
        {
            Stack <Model.AKhar> ret = new Stack <Model.AKhar>();

            while (list.Count != 0)
            {
                Model.AKhar akhar = list[list.Count - 1];
                if (this.Check_DauCau(akhar))
                {
                    ret.Push(akhar);
                    list.RemoveAt(list.Count - 1);
                    continue;
                }

                break;
            }

            return(ret);
        }
예제 #10
0
        /// <summary>
        /// Set Rumi chars from XML file into hastable
        /// </summary>
        /// <param name="keyCodeTrans">keyCodeRumi</param>
        public static void SetTransFromXML(ref Hashtable keyCodeTrans, Model.Enum desType)
        {
            Model.XMLRumiCol colNo = Model.XMLRumiCol.Rumi;
            if (desType == Model.Enum.TransCamEFEO)
            {
                colNo = Model.XMLRumiCol.Rumi;
            }
            else if (desType == Model.Enum.TransInrasara)
            {
                colNo = Model.XMLRumiCol.InraSara;
            }
            else if (desType == Model.Enum.TransKawomTT)
            {
                colNo = Model.XMLRumiCol.KawomTT;
            }

            keyCodeTrans = new Hashtable();

            Stream  strm = ReadXMLFile(Model.Constant.KEY_TO_TRANS_FILE);
            DataSet dts  = new DataSet();

            dts.ReadXml(strm);

            DataTable dtt = dts.Tables[0];

            foreach (DataRow dtr in dtt.Rows)
            {
                Model.AKhar keyCode = (Model.AKhar)Convert.ToInt32(dtr[Convert.ToInt32(Model.XMLRumiCol.KeyCode)]);
                String      trans   = dtr[Convert.ToInt32(colNo)].ToString();

                //Keycode - Trans
                if (!keyCodeTrans.ContainsKey(keyCode))
                {
                    keyCodeTrans.Add(keyCode, trans);
                }
            }
        }
예제 #11
0
 /// <summary>
 /// Check is Takai likuk
 /// </summary>
 /// <param name="akhar">akhar</param>
 protected bool IsTakaiLikuk(Model.AKhar akhar)
 {
     return(this._takaiLikuk.ContainsKey(akhar));
 }
예제 #12
0
 /// <summary>
 /// Check is consonant
 /// </summary>
 /// <param name="akhar">akhar</param>
 protected bool IsConsonant(Model.AKhar akhar)
 {
     return(akhar <= Model.AKhar.SakPraong);
 }
예제 #13
0
 /// <summary>
 /// Check is vowels
 /// </summary>
 /// <param name="akhar">akhar</param>
 protected bool IsVowels(Model.AKhar akhar)
 {
     return(akhar >= Model.AKhar.Ak && akhar <= Model.AKhar.Ok);
 }
예제 #14
0
 /// <summary>
 /// Check is akhar diip
 /// </summary>
 /// <param name="akhar">akhar</param>
 protected bool IsAkharDiip(Model.AKhar akhar)
 {
     return(akhar <= Model.AKhar.Ok);
 }
예제 #15
0
 /// <summary>
 /// Check Is Sap Paoh
 /// </summary>
 /// <param name="akhar">akhar</param>
 protected bool IsSapPaoh(Model.AKhar akhar)
 {
     return(this._sappaoh.ContainsKey(akhar));
 }
예제 #16
0
 /// <summary>
 /// Check is sap paoh
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_DauCau(Model.AKhar sabaoh)
 {
     return(sabaoh >= Model.AKhar.KanaingSa && sabaoh <= Model.AKhar.Square);
 }
예제 #17
0
 /// <summary>
 /// Check is Consonant
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 /// <returns>TRUE: Consonant; FALSE: Not Consonant</returns>
 protected bool Check_InaAkhar_PhuAm(Model.AKhar sabaoh)
 {
     return(sabaoh <= Model.AKhar.Ak);
 }
        /// <summary>
        /// To keycode From KTT
        /// </summary>
        /// <param name="word">KTT word</param>
        /// <param name="ret">result</param>
        /// <param name="retForCode">result for coding</param>
        /// <param name="preChar">the prev char</param>
        private void ToKeycodeFromKTT(ref String word, ref List <Model.AKhar> ret, ref List <Model.AKhar> retForCode, ref Model.AKhar preChar)
        {
            List <Model.AKhar> akharList = this.ToKeyCodeByChar(ref word, retForCode);

            for (int i = 0; i < akharList.Count; i++)
            {
                Model.AKhar akhar = akharList[i];

                //Sap Atah Process
                if (retForCode.Count != 0 && this._sapAtah.ContainsKey(akhar) && akhar == preChar)
                {
                    Model.AKhar akharAtah = (Model.AKhar) this._sapAtah[akhar];
                    if (akharAtah == Model.AKhar.BalauTapong)
                    {
                        ret.RemoveAt(ret.Count - 1);
                        retForCode.RemoveAt(retForCode.Count - 1);
                    }

                    ret.Add(akharAtah);
                    retForCode.Add(akharAtah);
                    continue;
                }

                //Set prev char
                preChar = akhar;
                if (akhar == Model.AKhar.Ak && !this.HuLanglikuk(retForCode) && ret.Count != 0)
                {
                    retForCode.Add(akhar);
                    continue;
                }

                //Get the next akhar
                Model.AKhar nextAkhar = Model.AKhar.Square;
                if (!String.IsNullOrEmpty(word))
                {
                    nextAkhar = this.GetNextChar(word);
                }

                //curent char is "i" or "é" and the next char is akhar matai
                if (!String.IsNullOrEmpty(word))
                {
                    //Convert akhar diip to takai akhar
                    if (this._diipToTaKai.ContainsKey(akhar) && !this._diipToMaTai.ContainsKey(nextAkhar) &&
                        !this.HuLanglikuk(retForCode) && ret.Count != 0 && !this.Check_AkharMatai(ret[ret.Count - 1]))
                    {
                        if (!((akhar == Model.AKhar.Rak && ret.Count != 0 && this.IsVowels(ret[ret.Count - 1])) ||
                              ((akhar == Model.AKhar.Ik || akhar == Model.AKhar.Uk) && this.IsConsonant(nextAkhar) && !this._diipToMaTai.ContainsKey(nextAkhar))))
                        {
                            akhar = (Model.AKhar) this._diipToTaKai[akhar];
                        }
                    }

                    //"u","o"
                    if ((akhar == Model.AKhar.Ok || akhar == Model.AKhar.Uk) &&
                        !this.HuLanglikuk(retForCode) && ret.Count != 0)
                    {
                        if (akhar == Model.AKhar.Ok)
                        {
                            akhar = Model.AKhar.DarSa;
                        }
                        else
                        {
                            akhar = Model.AKhar.TakaiKuk;
                        }
                    }

                    //Convert akhar diip to sap paoh
                    if ((this._diipToMaTai.ContainsKey(nextAkhar) && !this.HuLanglikuk(retForCode) && ret.Count != 0) ||
                        (this.IsConsonant(nextAkhar) && !this._diipToMaTai.ContainsKey(nextAkhar)))
                    {
                        if (akhar == Model.AKhar.Ik)
                        {
                            akhar = Model.AKhar.TakaiKik;
                        }
                        else if (akhar == Model.AKhar.É)
                        {
                            akhar = Model.AKhar.DarSa;
                            akharList.Add(Model.AKhar.TakaiThek);
                        }
                    }

                    //TaikaiKlakTaikaiKuak & TaikaiKlakTaikaiKuk
                    if (akhar == Model.AKhar.TakaiKlakTakaiKuak)
                    {
                        if (!this.IsSapPaoh(nextAkhar))
                        {
                            akhar = Model.AKhar.TakaiKlakTakaiKuk;
                        }
                    }

                    //Mâk, Nâk, Nyâk, Ngâk
                    if (this._consonantKareiCrih.ContainsKey(akhar) && nextAkhar == Model.AKhar.Ak)
                    {
                        akhar = (Model.AKhar) this._consonantKareiCrih[akhar];
                    }
                }

                //Convert akhar ai to DarDua
                if (akhar == Model.AKhar.Ai && ret.Count != 0 && this.IsConsonant(ret[ret.Count - 1]))
                {
                    akhar = Model.AKhar.DarDua;
                }

                //Sap paoh deng anak akhar
                int index        = ret.Count;
                int indexForCode = retForCode.Count;
                if (akhar == Model.AKhar.DarSa || akhar == Model.AKhar.DarDua || akhar == Model.AKhar.TakaiKrak)
                {
                    index = this.GetIndexAkharDiip(ret);
                    //fix have taikai Krak
                    if (index > 0 && ret[index - 1] == Model.AKhar.TakaiKrak)
                    {
                        index--;
                    }

                    indexForCode = this.GetIndexAkharDiip(retForCode);
                    //fix have taikai Krak
                    if (indexForCode > 0 && retForCode[indexForCode - 1] == Model.AKhar.TakaiKrak)
                    {
                        indexForCode--;
                    }
                }

                //end the word
                if ((String.IsNullOrEmpty(word) || this._kanaingChars.ContainsKey(word.Substring(0, 1))) && ret.Count != 0)
                {
                    //Convert akhar diip to akhar matai
                    if (this._diipToMaTai.ContainsKey(akhar))
                    {
                        akhar = (Model.AKhar) this._diipToMaTai[akhar];
                        if (akhar == Model.AKhar.NgâkMatai)
                        {
                            if (!this._sappaohAngaok.ContainsKey(ret[ret.Count - 1]))
                            {
                                akhar = Model.AKhar.PaohNgâk;
                            }

                            int indexAkharDiip = this.GetIndexAkharDiip(ret);
                            if (indexAkharDiip - 1 >= 0)
                            {
                                Model.AKhar akharDengAnak = ret[indexAkharDiip - 1];
                                if (akharDengAnak == Model.AKhar.DarSa || akharDengAnak == Model.AKhar.DarDua)
                                {
                                    akhar = Model.AKhar.NgâkMatai;
                                }
                            }
                        }
                    }

                    //"i"
                    if (akhar == Model.AKhar.Ik)
                    {
                        akhar = Model.AKhar.TakaiKikTutTakaiMâkDalem;
                    }

                    //"é"
                    if (akhar == Model.AKhar.É)
                    {
                        akharList.Add(Model.AKhar.DarSa);
                        akharList.Add(Model.AKhar.BalauTapong);
                        continue;
                    }

                    //"o"
                    if (akhar == Model.AKhar.Ok)
                    {
                        akharList.Add(Model.AKhar.DarSa);
                        continue;
                    }

                    //"u"
                    if (akhar == Model.AKhar.Uk)
                    {
                        akharList.Add(Model.AKhar.TakaiKuk);
                        continue;
                    }

                    //"e"
                    if (akhar == Model.AKhar.TakaiThek && !(akharList.Count > 1 && akharList[akharList.Count - 2] == Model.AKhar.TakaiKuk))
                    {
                        akharList.Add(Model.AKhar.BalauTapong);
                        continue;
                    }
                }

                //Remove takai kâkk when have consonant KareiCrih
                if (akhar == Model.AKhar.TakaiKâk && ret.Count != 0 &&
                    this._consonantKareiCrih.ContainsKey(ret[this.GetIndexAkharDiip(ret)]))
                {
                    retForCode.Insert(indexForCode, akhar);
                    continue;
                }

                ret.Insert(index, akhar);
                retForCode.Insert(indexForCode, akhar);
            }
        }
예제 #19
0
        /// <summary>
        /// Set Rumi chars key code from XML file into hastable
        /// </summary>
        /// <param name="transKeycode">rumiKeycode</param>
        public static void SetTransToKeyCode(ref Hashtable transKeycode, Model.Enum desType)
        {
            transKeycode = new Hashtable();

            Model.XMLTransToKeyCol columnNo = Model.XMLTransToKeyCol.Rumi;
            String sapPaohAO   = String.Empty;
            String sapPaohAOM  = String.Empty;
            String sapPaohAONG = String.Empty;
            String sapPaohEM   = String.Empty;
            String akharIÉNG   = String.Empty;
            String akharIENG   = String.Empty;
            String sapPaohAU   = String.Empty;

            if (desType == Model.Enum.TransCamEFEO)
            {
                columnNo    = Model.XMLTransToKeyCol.Rumi;
                sapPaohAO   = Model.Constant.AO_EFEO;
                sapPaohAOM  = Model.Constant.AOM_EFEO;
                sapPaohAONG = Model.Constant.AONG_EFEO;
                sapPaohEM   = Model.Constant.EM_EFEO;
                akharIÉNG   = Model.Constant.IÉNG_EFEO;
                akharIENG   = Model.Constant.IENG_EFEO;
                sapPaohAU   = Model.Constant.AU_EFEO;
            }

            else if (desType == Model.Enum.TransInrasara)
            {
                columnNo    = Model.XMLTransToKeyCol.InraSara;
                sapPaohAO   = Model.Constant.AO_SARA;
                sapPaohAOM  = Model.Constant.AOM_SARA;
                sapPaohAONG = Model.Constant.AONG_SARA;
                sapPaohEM   = Model.Constant.EM_SARA;
                akharIÉNG   = Model.Constant.IÉNG_SARA;
                akharIENG   = Model.Constant.IENG_SARA;
                sapPaohAU   = Model.Constant.AU_SARA;
            }
            else if (desType == Model.Enum.TransKawomTT)
            {
                columnNo    = Model.XMLTransToKeyCol.KawomTuekTuah;
                sapPaohAO   = Model.Constant.AO_KawomTT;
                sapPaohAOM  = Model.Constant.AOM_KawomTT;
                sapPaohAONG = Model.Constant.AONG_KawomTT;
                sapPaohEM   = Model.Constant.EM_KawomTT;
                akharIÉNG   = Model.Constant.IÉNG_KawomTT;
                akharIENG   = Model.Constant.IENG_KawomTT;
                sapPaohAU   = Model.Constant.AU_KawomTT;

                List <Model.AKhar> sappaohE = new List <Model.AKhar>();
                sappaohE.Add(Model.AKhar.DarDua);
                transKeycode.Add("E", sappaohE);
            }

            //Add au
            List <Model.AKhar> sappaohAu = new List <Model.AKhar>();

            sappaohAu.Add(Model.AKhar.TakaiKuk);
            sappaohAu.Add(Model.AKhar.TakaiThek);
            transKeycode.Add(sapPaohAU, sappaohAu);

            //Add iéng
            List <Model.AKhar> lstTemp = new List <Model.AKhar>();

            lstTemp.Add(Model.AKhar.DarSa);
            lstTemp.Add(Model.AKhar.TakaiKiak);
            lstTemp.Add(Model.AKhar.TakaiThekPaohNgâk);
            transKeycode.Add(akharIÉNG, lstTemp);

            //Add ieng
            lstTemp = new List <Model.AKhar>();
            lstTemp.Add(Model.AKhar.TakaiKiak);
            lstTemp.Add(Model.AKhar.TakaiThekPaohNgâk);
            transKeycode.Add(akharIENG, lstTemp);

            Stream  strm = ReadXMLFile(Model.Constant.TRANS_TO_KEY_FILE);
            DataSet dts  = new DataSet();

            dts.ReadXml(strm);

            DataTable dtt = dts.Tables[0];

            foreach (DataRow dtr in dtt.Rows)
            {
                Model.AKhar        akhar     = (Model.AKhar)Convert.ToInt32(dtr[Convert.ToInt32(Model.XMLTransToKeyCol.KeyCode)]);
                String             transChar = dtr[Convert.ToInt32(columnNo)].ToString().ToUpper();
                List <Model.AKhar> listAkhar = new List <Model.AKhar>();

                //Keycode - Rumi
                bool isIrregular = false;
                if (!transKeycode.ContainsKey(transChar))
                {
                    if (transChar == sapPaohAO)
                    {
                        listAkhar.Add(Model.AKhar.DarSa);
                        listAkhar.Add(Model.AKhar.TraohAw);
                        isIrregular = true;
                    }

                    if (transChar == sapPaohAOM)
                    {
                        listAkhar.Add(Model.AKhar.DarSa);
                        listAkhar.Add(Model.AKhar.TraohAwTutTakaiMâk);
                        isIrregular = true;
                    }

                    if (transChar == sapPaohAONG)
                    {
                        listAkhar.Add(Model.AKhar.DarSa);
                        listAkhar.Add(Model.AKhar.TraohAwPaohNgâk);
                        isIrregular = true;
                    }

                    if (transChar == sapPaohEM)
                    {
                        listAkhar.Add(Model.AKhar.DarSa);
                        //listAkhar.Add(Model.AKhar.TakaiThek);
                        listAkhar.Add(Model.AKhar.TakaiThekTutTakaiMâk);
                        isIrregular = true;
                    }

                    if (!isIrregular)
                    {
                        listAkhar.Add(akhar);
                    }

                    transKeycode.Add(transChar, listAkhar);
                }
            }

            //add au, am dai
            if (desType == Model.Enum.TransKawomTT)
            {
                List <Model.AKhar> listAkhar = new List <Model.AKhar>();
                listAkhar.Add(Model.AKhar.DarSa);
                listAkhar.Add(Model.AKhar.TraohAw);

                transKeycode.Add(sapPaohAO, listAkhar);

                //OO
                transKeycode["OO"] = listAkhar;

                //AA
                listAkhar = new List <Model.AKhar>();
                listAkhar.Add(Model.AKhar.Balau);
                transKeycode.Add("AA", listAkhar);

                //UU
                listAkhar = new List <Model.AKhar>();
                listAkhar.Add(Model.AKhar.Balau);
                listAkhar.Add(Model.AKhar.TakaiKuk);
                transKeycode.Add("UU", listAkhar);

                //EE
                listAkhar = new List <Model.AKhar>();
                listAkhar.Add(Model.AKhar.DarDua);
                listAkhar.Add(Model.AKhar.Balau);
                transKeycode.Add("EE", listAkhar);

                //ƯƯ
                listAkhar = new List <Model.AKhar>();
                listAkhar.Add(Model.AKhar.TakaiKâk);
                listAkhar.Add(Model.AKhar.Balau);
                transKeycode.Add("ƯƯ", listAkhar);

                //ƠƠ
                listAkhar = new List <Model.AKhar>();
                listAkhar.Add(Model.AKhar.BalauTapong);
                transKeycode.Add("ƠƠ", listAkhar);

                //II
                listAkhar = new List <Model.AKhar>();
                listAkhar.Add(Model.AKhar.TakaiKikTutTakaiMâkDalem);
                transKeycode.Add("II", listAkhar);
            }
        }
예제 #20
0
 /// <summary>
 /// Check is Takai Akhar deng anak
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_TakaiAkharAnak(Model.AKhar sabaoh)
 {
     return(sabaoh == Model.AKhar.TakaiKrak);
 }
예제 #21
0
 /// <summary>
 /// Check is wak matai
 /// </summary>
 /// <param name="sabaoh">sabaoh</param>
 /// <param name="index">index</param>
 /// <param name="count">count</param>
 protected bool IsAkharWakMaTai(Model.AKhar sabaoh, int index, int count)
 {
     return(sabaoh == Model.AKhar.Wak && index == count - 1);
 }
예제 #22
0
 /// <summary>
 /// Check is Takai Akhar sap paoh deng anak
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_TakaiSapPaohAnak(Model.AKhar sabaoh)
 {
     return(sabaoh == Model.AKhar.DarSa || sabaoh == Model.AKhar.DarDua);
 }
예제 #23
0
 /// <summary>
 /// Check is takai akhar
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_TakaiAkhar(Model.AKhar sabaoh)
 {
     return(sabaoh > Model.AKhar.Balau && sabaoh <= Model.AKhar.PaohNgâk);
 }
예제 #24
0
 /// <summary>
 /// Check is Vowel of Lang likuk
 /// </summary>
 /// <param name="akhar">khar</param>
 protected bool IsVowelLanglikuk(Model.AKhar akhar)
 {
     return(this._vowelLangLikuk.ContainsKey(akhar));
 }
예제 #25
0
 /// <summary>
 /// Check Is Vowel
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_InaAkhar_NguyenAm(Model.AKhar sabaoh)
 {
     return(sabaoh >= Model.AKhar.Ik && sabaoh <= Model.AKhar.Ok);
 }
예제 #26
0
 /// <summary>
 /// Check is Akhar Mâtai
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_AkharMatai(Model.AKhar sabaoh)
 {
     return(sabaoh >= Model.AKhar.KakMatai && sabaoh <= Model.AKhar.PaohDaNih || sabaoh == Model.AKhar.PaohNgâk);
 }
        /// <summary>
        /// Covert to keycode by word
        /// </summary>
        /// <param name="word">word</param>
        private List <Model.AKhar> ToKeyCodeByWord(String word, Model.Enum sourceType)
        {
            try
            {
                List <Model.AKhar>  ret            = new List <Model.AKhar>();
                Stack <Model.AKhar> kanaingAtFirst = new Stack <Model.AKhar>();
                Stack <Model.AKhar> kanaingAtLast  = new Stack <Model.AKhar>();

                bool     addLastCharProcess = true;
                string[] wordArr            = word.Split(_DASH);
                foreach (string item in wordArr)
                {
                    List <Model.AKhar> wordAkhar = new List <Model.AKhar>();
                    string             wordStr   = item;

                    //Cut kanaing at first and last word
                    kanaingAtFirst = this.CutKanaingAtFirst(ref wordStr);
                    kanaingAtLast  = this.CutKanaingAtLast(ref wordStr);

                    //Specail word
                    if (this._kareiCrih.ContainsKey(wordStr))
                    {
                        wordAkhar = Utility.CopyListAkhar((List <Model.AKhar>) this._kareiCrih[wordStr]);

                        // add kanaing at first and last word
                        Utility.PopStackToList(wordAkhar, kanaingAtFirst, true);
                        Utility.PopStackToList(wordAkhar, kanaingAtLast, false);

                        ret.AddRange(wordAkhar);
                        addLastCharProcess = false;
                        continue;
                    }

                    addLastCharProcess = true;
                    List <Model.AKhar> retForCode = new List <Model.AKhar>();
                    Model.AKhar        prevChar   = Model.AKhar.Square;

                    int roundCount = 0;
                    while (!String.IsNullOrEmpty(wordStr))
                    {
                        if (roundCount == Model.Constant.MAX_ROUND)
                        {
                            break;
                        }

                        //convert to keycode
                        switch (sourceType)
                        {
                        case Model.Enum.TransCamEFEO:
                            this.ToKeycodeFromCamEFEO(ref wordStr, ref wordAkhar, ref retForCode);
                            break;

                        case Model.Enum.TransInrasara:
                            this.ToKeycodeFromInrasara(ref wordStr, ref wordAkhar, ref retForCode);
                            break;

                        default:
                            this.ToKeycodeFromKTT(ref wordStr, ref wordAkhar, ref retForCode, ref prevChar);
                            break;
                        }
                    }

                    ret.AddRange(wordAkhar);
                    roundCount++;
                }

                //add balau on the last char
                if (ret.Count != 0 && addLastCharProcess)
                {
                    int         indexLastChar = this.GetIndexLastChar(ret);
                    Model.AKhar lastAkhar     = ret[indexLastChar];
                    if ((this.IsAkharDiip(lastAkhar) || this.IsTakaiLikuk(lastAkhar)) && !ret.Contains(Model.AKhar.DarDua) &&
                        !(lastAkhar == Model.AKhar.TakaiThek && indexLastChar > 0 && ret[indexLastChar - 1] == Model.AKhar.TakaiKuk))
                    {
                        ret.Insert(indexLastChar + 1, Model.AKhar.Balau);
                    }

                    if (ret.Count != 0 && this._takaiDaokLikuk.ContainsKey(ret[0]))
                    {
                        ret.Insert(0, Model.AKhar.Ak);
                    }
                }

                // add kanaing at first and last word
                Utility.PopStackToList(ret, kanaingAtFirst, true);
                Utility.PopStackToList(ret, kanaingAtLast, false);

                return(ret);
            }
            catch (Exception ex)
            {
                Service.Log.WriteLog(ex);
                return(new List <Model.AKhar>());
            }
        }
예제 #28
0
 /// <summary>
 /// Check is balau
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_Balau(Model.AKhar sabaoh)
 {
     return(sabaoh == Model.AKhar.Balau);
 }
예제 #29
0
 /// <summary>
 /// Check is angka
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_Angka(Model.AKhar sabaoh)
 {
     return(sabaoh >= Model.AKhar.Sa && sabaoh <= Model.AKhar.Saoh);
 }
예제 #30
0
 /// <summary>
 /// Check is Special Consonant
 /// (Mâk Nâk Nyâk Ngâk)
 /// </summary>
 /// <param name="sabaoh">akhar</param>
 protected bool Check_InaAkhar_PhuAm_Special(Model.AKhar sabaoh)
 {
     //MCMC
     Model.AKhar[] phu_am_dac_biet = new Model.AKhar[] { Model.AKhar.Mâk, Model.AKhar.Nâk, Model.AKhar.Nyâk, Model.AKhar.Ngâk };
     return(Array.IndexOf(phu_am_dac_biet, sabaoh) != -1);
 }