Ejemplo n.º 1
0
        public void Traffic(List <string> words)
        {
            foreach (string word in words)
            {
                bool       isReg;
                InnerPos[] curPos  = this.POS.GetPos(word, out isReg);
                InnerPos[] nextPos = this.POS.GetPos(word, out isReg);

                if (curPos.Length != 1)
                {
                    continue;
                }

                InnerPos pos1 = curPos[0];
                if (pos1 == InnerPos.POS_UNK)
                {
                    continue;
                }

                if (nextPos.Length != 1)
                {
                    continue;
                }

                InnerPos pos2 = (InnerPos)nextPos[0];
                if (pos2 == InnerPos.POS_UNK)
                {
                    continue;
                }

                DualityWordBin bin = new DualityWordBin(pos1, pos2);
                Hit(bin);
            }
        }
Ejemplo n.º 2
0
        static public PosEnum InnertPosToPos(InnerPos inPos)
        {
            if (inPos == InnerPos.POS_UNK)
            {
                return(PosEnum.POS_UNK);
            }

            return((PosEnum)(0x01 << (int)inPos));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 增加单词的词性
        /// </summary>
        /// <param name="word">单词</param>
        /// <param name="pos">词性</param>
        public void AddWordPos(String word, int pos)
        {
            if (word == null)
            {
                return;
            }

            if (word.Length == 1)
            {
                _OneCharTable[word] = true;
            }

            List <PosEnum> list = GetPosList(pos);

            InnerPos[] inPosList = new InnerPos[list.Count];

            for (int i = 0; i < inPosList.Length; i++)
            {
                inPosList[i] = GetInnerPos((PosEnum)list[i]);
            }

            _PosTable[word] = inPosList;
        }
Ejemplo n.º 4
0
 public DualityWordBin(InnerPos pos1, InnerPos pos2)
 {
     _Pos1    = pos1;
     _Pos2    = pos2;
     HashCode = (int)pos1 * 64 + (int)pos2;
 }