//public static ParseResultCollection Parse(string text)
        //{
        //    return ParseResultCollection.InternalParse(text,new PlaceNameParser(text));
        //}

        public PlaceNameParser(ParserContext context)
        {
            this.context = context;
            if (placeNamesTrie == null)
            {
                placeNamesTrie = context.GetServerInstance();
            }

            placeNamesTrie.Connect(context.ServerEndPoint);
        }
Example #2
0
        public NameParser(ParserContext context)
        {
            this.context = context;
            client       = context.GetServerInstance();
            client.Connect(context.ServerEndPoint);

            prefixAndstandard.AddRange(prefixTitleList);
            prefixAndstandard.AddRange(titleList);
            suffixAndstandard.AddRange(suffixTitleList);
            suffixAndstandard.AddRange(titleList);
        }
Example #3
0
 public override void Load()
 {
     using (var service = new DictionaryServiceClient())
     {
         try
         {
             this.ViewModel.SoftSkill = service.GetSoftSkillById(this.CurrentId);
         }
         catch (Exception e)
         {
         }
     }
 }
Example #4
0
 public override void Delete()
 {
     using (var service = new DictionaryServiceClient())
     {
         try
         {
             service.DeleteSoftSkill(this.ViewModel.SoftSkill);
         }
         catch (Exception e)
         {
         }
     }
 }
Example #5
0
 public override void Save()
 {
     using (var service = new DictionaryServiceClient())
     {
         try
         {
             this.CurrentId = service.SaveSoftSkill(this.ViewModel.SoftSkill);
         }
         catch (Exception e)
         {
         }
     }
 }
Example #6
0
 public override void Add()
 {
     using (var service = new DictionaryServiceClient())
     {
         try
         {
             this.CurrentId = service.SaveStage(this.ViewModel.Stage);
         }
         catch (Exception e)
         {
         }
     }
 }
Example #7
0
        public void TestServerCommand_MMFetch()
        {
            EndPoint serverAddress = new IPEndPoint(IPAddress.Parse(ip), port);

            using (DictionaryServiceClient dsc = new DictionaryServiceClient())
            {
                dsc.Connect(serverAddress);
                string responseText = dsc.SendCommand("MMFetch 测试" + Environment.NewLine);
                AssertServerResponse(responseText, true, "测试");

                responseText = dsc.SendCommand("MMFetch 我们一起去吧" + Environment.NewLine);
                AssertServerResponse(responseText, true, "我们");
            }
        }
Example #8
0
        public void TestRMMFetchWrapper()
        {
            EndPoint serverAddress = new IPEndPoint(IPAddress.Parse(ip), port);

            using (DictionaryServiceClient dsc = new DictionaryServiceClient())
            {
                dsc.Connect(serverAddress);
                string responseText = dsc.ReverseMaximumMatch("测试").Word;
                Assert.AreEqual("测试", responseText);

                responseText = dsc.ReverseMaximumMatch("请你相信我们").Word;
                Assert.AreEqual("我们", responseText);
            }
        }
Example #9
0
        public ChineseAddressParser(ParserContext context)
        {
            if (context.Pattern != ParserPattern.China)
            {
                throw new ArgumentOutOfRangeException("中文地址仅对ParserPattern.China有效");
            }
            this.context = context;
            client       = context.GetServerInstance();

            client.Connect(context.ServerEndPoint);
            //MongoDatabase db = server.GetDatabase("nameResearch");
            //_cityNames = db.GetCollection<CityEntity>("cityNames");
            //_placeNames = db.GetCollection<NameEntity>("placeNames");
        }
Example #10
0
        public override int GetAmountOfRecords()
        {
            int amount = 0;

            try
            {
                using (var service = new DictionaryServiceClient())
                {
                    amount = service.GetAmountOfSkills();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(amount);
        }
Example #11
0
        public override List <object> LoadData(int pageNumber)
        {
            List <object> returnList = new List <object>();

            try
            {
                using (var service = new DictionaryServiceClient())
                {
                    returnList = service.GetSkillsByPage(pageNumber).Cast <object>().ToList();
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return(returnList);
        }
Example #12
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            Regex    regex         = new Regex("dict://([\\d\\.]+):(\\d{3,5})", RegexOptions.Compiled);
            string   addr          = tbDictAddress.Text.Trim();
            var      matches       = regex.Matches(addr);
            string   serverAddr    = matches[0].Groups[1].Value;
            int      port          = Int32.Parse(matches[0].Groups[2].Value);
            EndPoint serverAddress = new IPEndPoint(IPAddress.Parse(serverAddr), port);


            int posValue = 0;

            foreach (var selectedObject in checkedListBox1.CheckedItems)
            {
                string value  = (string)selectedObject;
                var    values = Enum.GetValues(typeof(POSType));
                foreach (var v in values)
                {
                    if (((System.Enum)v).Description() == value)
                    {
                        POSType pos = (POSType)v;
                        posValue |= ((int)pos);
                        break;
                    }
                }
            }
            using (DictionaryServiceClient dsc = new DictionaryServiceClient())
            {
                dsc.Connect(serverAddress);
                TrieTreeResult result = null;
                if (radioButton1.Checked)
                {
                    result = dsc.MaximumMatch(tbWord.Text.Trim(), posValue);
                }
                else if (radioButton2.Checked)
                {
                    result = dsc.ReverseMaximumMatch(tbWord.Text.Trim(), posValue);
                }
                else
                {
                    result = dsc.ExactMatch(tbWord.Text.Trim(), posValue);
                }

                if (result != null)
                {
                    string resultText = result.Word;
                    int    originalLength1 = 0, originalLength2 = 0;

                    if (result.Frequency != 0)
                    {
                        originalLength1 = resultText.Length;
                        resultText     += ", 频率:" + result.Frequency;
                    }
                    if (result.POS > 0)
                    {
                        originalLength2 = resultText.Length;
                        resultText     += ", 类型:" + ConvertPOSTypesToString(ConvertValueToPOS(result.POS));
                    }
                    richTextBox1.Text      = resultText;
                    richTextBox1.ForeColor = System.Drawing.Color.Black;
                    if (originalLength1 > 0)
                    {
                        richTextBox1.Select(originalLength1 + 1, 4);
                        richTextBox1.SelectionColor = System.Drawing.Color.Blue;
                    }
                    if (originalLength2 > 0)
                    {
                        richTextBox1.Select(originalLength2 + 1, 4);
                        richTextBox1.SelectionColor = System.Drawing.Color.Blue;
                    }
                }
                else
                {
                    richTextBox1.ForeColor = System.Drawing.Color.Red;
                    richTextBox1.Text      = "未找到合适词";
                }
            }
        }
Example #13
0
 public OrgNameParser(ParserContext context)
 {
     this.context = context;
     orgNamesTrie = context.GetServerInstance();
     orgNamesTrie.Connect(context.ServerEndPoint);
 }