Esempio n. 1
0
        /// <summary>
        /// 加载字典数据
        /// </summary>
        private void initia()
        {
            _parser = new DicParser();

            /****************
             * 正向词典
             * **********************/
            var b = File.ReadAllText(_config.DicPath);

            _parser.Parse(b, PositiveDic);

            /****************
             * 反向词典
             * *************/
            _parser.Parse(b, NegtiveDic, true);

            /*************************************
             * 单字词典
             * *********************/
            foreach (var item in StringHelper.Splite(File.ReadAllText(_config.SingleDicDicPath), "\r\n"))
            {
                var w = _WordInnfo.Parse(item);
                if (w != null)
                {
                    if (w.Name.Length != 0)
                    {
                        if (!SingleDic.ContainsKey(w.Name[0]))
                        {
                            SingleDic.Add(w.Name[0], w);
                        }
                    }
                }
            }

            /****************
             * 新词词典
             * *****************/
            if (_config.IsDetectNewWord)
            {
                b = File.ReadAllText(_config.NewDicPath);
                _parser.Parse(b, NewWordDic);
            }
        }
Esempio n. 2
0
 public _WordInnfo GetWordInfoFromSingleDic(char ch) => SingleDic.ContainsKey(ch) ? SingleDic[ch] : null;