Example #1
0
 public override bool LoadDictionary(Stream instr, Uyghur.YEZIQ yeziq)
 {
     using (StreamReader sr = new StreamReader(instr, System.Text.Encoding.UTF8))
     {
         String line;
         while ((line = sr.ReadLine()) != null)
         {
             string[] lineParts = line.Split(null);
             if (lineParts.Length >= 2)
             {
                 string key = lineParts[0];
                 if (yeziq == Uyghur.YEZIQ.ULY)
                 {
                     key = Uyghur.UEY2ULY(key).ToLower();
                 }
                 else if (yeziq == Uyghur.YEZIQ.USY)
                 {
                     key = Uyghur.UEY2USY(key).ToLower();
                 }
                 Int64 count;
                 if (Int64.TryParse(lineParts[1], out count))
                 {
                     Add(key, count);
                 }
             }
         }
     }
     return(true);
 }
        private void InputText(TextBox curBox, string newtxt)
        {
            int    oldpos = curBox.CaretIndex;
            string txt    = curBox.Text;

            if (curBox.SelectionLength > 0)
            {
                oldpos = curBox.SelectionStart;
                txt    = txt.Remove(oldpos, curBox.SelectionLength);
                curBox.SelectionLength = 0;
            }

            if (Uyghur.IsUSozuq(newtxt[0]))
            {
                if ((oldpos == 0) || (oldpos > 0 && (Uyghur.IsUSozuq(txt[oldpos - 1]) || !Uyghur.IsUyghurcheHerp(txt[oldpos - 1])))
                    )
                {
                    //txt = txt.Insert(txtFind.CaretIndex,Uyghur.UYG_UN_HM_6+"");
                    newtxt = Uyghur.UYG_UN_HM_6 + newtxt;
                }
            }
            newtxt            = Uyghur.Tirnaqlar(newtxt, curEditor.RightToLeft);
            txt               = txt.Insert(oldpos, newtxt);
            curBox.Text       = txt;
            curBox.CaretIndex = oldpos + newtxt.Length;
        }
Example #3
0
        public bool Load(Stream instr, Uyghur.YEZIQ yeziq)
        {
            gYeziq = yeziq;
            bool ret = LoadDictionary(instr, yeziq);

            if (IshletkuchiDic.Count == 0)
            {
                ReadIshletkuchiDic();
            }
            string newsoz;

            foreach (string soz in IshletkuchiDic)
            {
                if (yeziq == Uyghur.YEZIQ.ULY)
                {
                    newsoz = Uyghur.UEY2ULY(soz).ToLower();
                }
                else if (yeziq == Uyghur.YEZIQ.USY)
                {
                    newsoz = Uyghur.UEY2USY(soz).ToLower();
                }
                else
                {
                    newsoz = soz;
                }
                Add(newsoz);
            }


            if (XataToghraBuf.Count == 0)
            {
                ReadXataToghra();
            }

            foreach (string qur in XataToghraBuf)
            {
                if (yeziq == Uyghur.YEZIQ.ULY)
                {
                    newsoz = Uyghur.UEY2ULY(qur).ToLower();
                }
                else if (yeziq == Uyghur.YEZIQ.USY)
                {
                    newsoz = Uyghur.UEY2USY(qur).ToLower();
                }
                else
                {
                    newsoz = qur;
                }
                string[] tx = newsoz.Split('=');
                if (tx.Length == 2)
                {
                    XataToghra[tx[0].Trim()] = tx[1].Trim();
                }
                if (!IsListed(tx[1].Trim()))
                {
                    Add(tx[1].Trim());
                }
            }
            return(ret);
        }
Example #4
0
        private void UserControl_TextInput(object sender, TextCompositionEventArgs e)
        {
            string  newtxt = "";
            TextBox curBox = sender as TextBox;

            if (InputLanguageManager.Current.CurrentInputLanguage.ThreeLetterISOLanguageName.Equals("uig"))
            {
            }
            else if (gKunupka == KUNUPKA.Uyghur)
            {
                newtxt = Uyghur.KeyToUEY(e.Text);
                if (newtxt.Length > 0)
                {
                    e.Handled = true;
                    InputText(curBox, newtxt);
                }
            }
            else if (gKunupka == KUNUPKA.UyghurLY)
            {
                newtxt = Uyghur.KeyToULY(e.Text);
                if (newtxt.Length > 0)
                {
                    e.Handled = true;
                    InputText(curBox, newtxt);
                }
            }
            else if (curEditor.RightToLeft)
            {
                e.Handled = true;
                InputText(curBox, e.Text);
            }
        }
Example #5
0
        public void SaveToIshletkuchi(string soz)
        {
            string filenm = Path.Combine(Application.StartupPath, gImlaIshletkuchi);

            soz = soz.ToLower().Replace(Uyghur.Sozghuch, "");
            soz = Uyghur.ToUEY(soz) ?? soz;
            IshletkuchiDic.Add(soz);
            try{
                File.AppendAllText(filenm, soz + " 1" + System.Environment.NewLine, System.Text.Encoding.UTF8);
            }catch {
            }
        }
        private void UserControl_TextInput(object sender, TextCompositionEventArgs e)
        {
            string  newtxt = "";
            TextBox curBox = sender as TextBox;

            if (gKunupka == KUNUPKA.Uyghur)
            {
                newtxt = Uyghur.KeyToUEY(e.Text);
                if (newtxt.Length > 0)
                {
                    e.Handled = true;
                    InputText(curBox, newtxt);
                }
            }
        }
Example #7
0
 public void SaveToXataToghra(string xata, string toghra)
 {
     if (!XataToghra.ContainsKey(xata))
     {
         string filenm = Path.Combine(Application.StartupPath, gImlaXataToghra);
         string xt     = xata.Trim().Replace(Uyghur.Sozghuch, "").ToLower();
         string togh   = toghra.Trim().Replace(Uyghur.Sozghuch, "").ToLower();
         string bk     = xt + "=" + togh;
         bk = Uyghur.ToUEY(bk) ?? bk;
         XataToghraBuf.Add(bk);
         try{
             File.AppendAllText(filenm, bk + System.Environment.NewLine, System.Text.Encoding.UTF8);
         }catch {
         }
     }
 }
        private void InputText(TextBox curBox, string newtxt)
        {
            int    oldpos = curBox.CaretIndex;
            string txt    = curBox.Text;
            int    inc    = 0;

            if (Uyghur.IsUSozuq(newtxt[0]))
            {
                if ((oldpos == 0) || (oldpos > 0 && (Uyghur.IsUSozuq(txt[oldpos - 1]) || !Uyghur.IsUyghurcheHerp(txt[oldpos - 1])))
                    )
                {
                    txt = txt.Insert(txtFind.CaretIndex, Uyghur.UYG_UN_HM_6 + "");
                    inc++;
                }
            }
            txt = txt.Insert(oldpos + inc, newtxt);
            inc++;
            curBox.Text       = txt;
            curBox.CaretIndex = oldpos + inc;
        }
Example #9
0
        public override bool LoadDictionary(Stream instr, Uyghur.YEZIQ yeziq)
        {
            gYeziq = yeziq;
            var staging = new SuggestionStage(16384);

            using (StreamReader sr = new StreamReader(instr, System.Text.Encoding.UTF8))
            {
                String line;

                //process a single line at a time only for memory efficiency
                while ((line = sr.ReadLine()) != null)
                {
                    string[] lineParts = line.Split(null);
                    if (lineParts.Length >= 2)
                    {
                        string key = lineParts[0];
                        if (yeziq == Uyghur.YEZIQ.ULY)
                        {
                            key = Uyghur.UEY2ULY(key).ToLower();
                        }
                        else if (yeziq == Uyghur.YEZIQ.USY)
                        {
                            key = Uyghur.UEY2USY(key).ToLower();
                        }
                        //Int64 count;
                        Int64 count;
                        if (Int64.TryParse(lineParts[1], out count))
                        {
                            Add(key, count);
                        }
                    }
                }
            }
            if (this.deletes == null)
            {
                this.deletes = new Dictionary <int, string[]>(staging.DeleteCount);
            }
            CommitStaged(staging);
            return(true);
        }
Example #10
0
        public String GetText(String key)
        {
            String ret = key;

            if (gLangJson != null && (LanguaID.Equals("jpn") || LanguaID.Equals("eng")))
            {
                if (gLangJson.IsDefined(key))
                {
                    ret = gLangJson[key][LanguaID];
                    if (string.IsNullOrEmpty(ret))
                    {
                        ret = key;
                    }
                }
                else
                {
                    if (gTmp.Contains(key) == false)
                    {
                        gTmp.Add(key);
                        string str = String.Format("\"{0}\":{{\"jpn\":\"\",\"eng\":\"\"}},", key);
                        gBuf.AppendLine(str);
                    }
                }
            }
            else
            {
                if (LanguaID.Equals("uey"))
                {
                    ret = Uyghur.ULY2UEY(key);
                }
                else if (LanguaID.Equals("usy"))
                {
                    ret = Uyghur.ULY2USY(key);
                }
            }
            return(ret);
        }
Example #11
0
        //Namzat Sozlerni tepip chiqidu
        public override List <string> Lookup(string Soz)
        {
            tmpNam.Clear();
            _namzatlar.Clear();
            List <string> Namzatlar = new List <string>();

            if (m_RootNode == null)
            {
                return(Namzatlar);
            }
            char[] herpler;
            String yasSoz;

            Soz = Soz.Trim().Replace(Uyghur.Sozghuch, "").ToLower();
            int lenSoz = Soz.Length;
            int i;

            //Barliq sozuq tashuwshlarni xatalashqan dep perez qilsaq
            herpler = Soz.ToCharArray();
            for (i = 0; i < herpler.Length; i++)
            {
                if (Uyghur.IsSozuq(herpler[i]))
                {
                    herpler[i] = '?';
                }
            }
            yasSoz = new String(herpler);
            _GetSuggestions(yasSoz);

            //Yuqiridiki barliq sozuq tawushlar xata dep qarap, andin bir bir herpning arqisidin birdin soz chushup qalghan dep qarisaq
            //Herp Bir Herpning aldida birdin herp chushup qalghan dep perez qilsaq
            string tmp;

            for (i = lenSoz; i >= 0; i--)
            {
                tmp = yasSoz.Insert(i, "?");
                _GetSuggestions(tmp);
                if (i < yasSoz.Length)
                {
                    tmp = yasSoz.Remove(i, 1);
                    _GetSuggestions(tmp);
                    tmp = yasSoz.Remove(i, 1).Insert(i, "?");
                    _GetSuggestions(tmp);
                }
            }


            for (i = lenSoz - 1; i >= 0; i--)
            {
                yasSoz = Soz.Insert(i, "?");                // Bir herp chsuhup qalghan
                _GetSuggestions(yasSoz);

                herpler    = Soz.ToCharArray();
                herpler[i] = '?';                  //Birdin herp hata
                yasSoz     = new String(herpler);
                _GetSuggestions(yasSoz);

                yasSoz = yasSoz.Insert(i, "?");
                _GetSuggestions(yasSoz);


                if ((i - 1) >= 0)
                {
                    herpler[i - 1] = '?';                  //xoshana ikki herp xata
                    yasSoz         = new String(herpler);
                    _GetSuggestions(yasSoz);
                }

                if ((i - 2) >= 0)
                {
                    herpler        = Soz.ToCharArray();
                    herpler[i]     = '?';                  //Birdin herp hata
                    herpler[i - 2] = '?';                  //birin herpni atalap xatamu qaraydu
                    yasSoz         = new String(herpler);
                    _GetSuggestions(yasSoz);
                }

                if ((i - 3) >= 0)
                {
                    herpler        = Soz.ToCharArray();
                    herpler[i]     = '?';                  //Birdin herp hata
                    herpler[i - 3] = '?';                  //birin herpni atalap xatamu qaraydu
                    yasSoz         = new String(herpler);
                    _GetSuggestions(yasSoz);
                }
            }

            foreach (NamzatQelip qlp in _namzatlar)
            {
                short dist = (short)GetDistance(Soz, qlp.soz);
                qlp.ariliq = dist;
            }
            _namzatlar.Sort(this);

            foreach (NamzatQelip qlp in _namzatlar)
            {
                if (Namzatlar.Count >= 10)
                {
                    break;
                }
                Namzatlar.Add(qlp.soz);
            }

            i = 1;
            while (i < lenSoz && lenSoz - i >= 3)
            {
                yasSoz = Soz.Substring(0, lenSoz - i);
                if (IsListed(yasSoz))
                {
                    if (!Namzatlar.Contains(yasSoz))
                    {
                        Namzatlar.Add(yasSoz);
                    }
                    break;
                }
                i++;
            }
            return(Namzatlar);
        }