Esempio n. 1
0
        public void WORK(string ImportFileName, string JsonFileName)
        {
            string Content = string.Empty;

            if (JsonFileName == string.Empty)
            {
                MessageBox.Show("先创建一个字典吧");
                return;
            }

            //if(ChkFileForImport(ImportFileName) != true)
            //{
            //    MessageBox.Show("文件格式不对啊");
            //    return;
            //}

            JsonFile.ReadStringFrJsonFile(ImportFileName, ref Content);
            Content = Content.Replace("$#", "|");
            Content = Content.Replace("\r", "");
            Content = Content.Replace("\n", "");
            string[]    Sub      = Content.Split('|');
            List <ITEM> ItemList = new List <ITEM>();

            MessageBox.Show("即将导入" + Sub.Length.ToString());
            foreach (string Segment in Sub)
            {
                if (Segment != "")
                {
                    ITEM     Item = new ITEM();
                    string[] Line = Segment.Split(new string[] { "#" }, StringSplitOptions.None);
                    foreach (string Element in Line)
                    {
                        if (Element == "")
                        {
                            continue;
                        }
                        string [] E    = Element.Split('$');
                        string    Key  = E[1];
                        string    Val  = E[2];
                        string    Temp = string.Empty;
                        if (Item.MainBody.TryGetValue(Key, out Temp))
                        {
                            Item.MainBody[Key] = Val;
                        }
                        else
                        {
                            Item.MainBody.Add(Key, Val);
                        }
                    }
                    ItemList.Add(Item);
                }
            }
            if (ItemList.Count != 0)
            {
                Items.Add(ItemList);
                Items.Writ();
            }
        }
Esempio n. 2
0
        public string GetValOfKey(string Key, ITEM Item)
        {
            string Temp = "";

            if (Item.MainBody.TryGetValue(Key, out Temp))
            {
                return(Temp);
            }
            else
            {
                return("");
            }
        }
Esempio n. 3
0
        private int SortByErrorCount(ITEM A, ITEM B)
        {
            int AE = int.Parse(A.MainBody["ErrorCount"]);
            int BE = int.Parse(B.MainBody["ErrorCount"]);

            if (AE > BE)
            {
                return(-1);
            }
            if (AE < BE)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 4
0
        private int SortByLearnCount(ITEM A, ITEM B)
        {
            int AC = int.Parse(A.MainBody["LearnCount"]);
            int BC = int.Parse(B.MainBody["LearnCount"]);

            if (AC > BC)
            {
                return(-1);
            }
            if (AC < BC)
            {
                return(1);
            }
            return(0);
        }
Esempio n. 5
0
        public bool CanPassByErrorRatex(ITEM Item, double Min, double Max)
        {
            double CurCnt = double.Parse(Item.MainBody["ErrorRate"]);
            double MinCnt = (double)Min;
            double MaxCnt = (double)Max;

            if ((MinCnt <= CurCnt) && (CurCnt <= MaxCnt))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 6
0
        public bool CanPassByErrorCount(ITEM Item, double Min, double Max)
        {
            int CurCnt = int.Parse(Item.MainBody["ErrorCount"]);
            int MinCnt = (int)Min;
            int MaxCnt = (int)Max;

            if ((MinCnt <= CurCnt) && (CurCnt <= MaxCnt))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 7
0
        public bool CanPassByLearnedTim(ITEM Item, double Min, double Max)
        {
            DateTime Cur = DateTime.Parse(Item.MainBody["LearnxTime"]);
            DateTime End = DateTime.Now.AddDays(-1 * Min);
            DateTime Sta = DateTime.Now.AddDays(-1 * Max);

            if (DateTime.Compare(Cur, Sta) > 0 && DateTime.Compare(Cur, End) < 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 8
0
        private bool ShouldRemoveThisItem(ITEM Item)
        {
            if (Keyword == "")
            {
                return(false);
            }
            List <string> Keys = new List <string>();

            foreach (string str in Item.MainBody.Keys)
            {
                Keys.Add(str);
            }
            foreach (string str in Keys)
            {
                if (Text.Sim(Item.MainBody[str], Keyword) >= 0.9)
                {
                    return(false);
                }
            }
            return(true);
        }
Esempio n. 9
0
        public double Sim(ITEM Item, List <string> Keys, List <string> Vals)
        {
            if (Keys.Count == 0 || Keys.Count != Vals.Count)
            {
                return(0.0);
            }
            double Sum        = 0;
            string Temp       = string.Empty;
            int    EmptyCount = 0;

            for (int i = 0; i < Keys.Count; i++)
            {
                if (Item.MainBody.TryGetValue(Keys[i], out Temp))
                {
                    Sum += Sim(Item.MainBody[Keys[i]], Vals[i]);
                }
                else
                {
                    EmptyCount++;
                }
            }
            Sum = Sum / (Keys.Count - EmptyCount);
            return(Sum);
        }
Esempio n. 10
0
 public void Add(ITEM NewItem)
 {
     Internal.Add(NewItem);
 }
Esempio n. 11
0
 public bool CanPassDefault(ITEM Item, double Min, double Max)
 {
     return(true);
 }