예제 #1
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);
        }
예제 #2
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);
 }
예제 #3
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);
        }