Ejemplo n.º 1
0
        /// <summary>
        /// 人名和前面的词词性匹配
        /// </summary>
        /// <param name="nextStr"></param>
        /// <returns></returns>
        public bool MatchNameInTail(String preStr)
        {
            bool isReg;

            InnerPos[] preList = _POS.GetPos(preStr, out isReg);

            if (preList.Length == 0)
            {
                return(false);
            }

            foreach (InnerPos pre in preList)
            {
                if (pre == InnerPos.POS_UNK)
                {
                    continue;
                }

                DualityWordBin posBin = new DualityWordBin(pre, InnerPos.POS_D_N);
                if (_PosBinTbl[posBin.HashCode] != null)
                {
                    return(true);
                }

                posBin = new DualityWordBin(pre, InnerPos.POS_A_NR);
                if (_PosBinTbl[posBin.HashCode] != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 人名和后面的词词性匹配
        /// </summary>
        /// <param name="str1"></param>
        /// <param name="str2"></param>
        /// <returns></returns>
        public bool MatchNameInHead(String nextStr)
        {
            bool isReg;

            InnerPos[] nextList = _POS.GetPos(nextStr, out isReg);

            if (nextList.Length == 0)
            {
                return(false);
            }

            foreach (InnerPos next in nextList)
            {
                if (next == InnerPos.POS_UNK)
                {
                    continue;
                }

                DualityWordBin posBin = new DualityWordBin(InnerPos.POS_D_N, next);
                if (_PosBinTbl[posBin.HashCode] != null)
                {
                    return(true);
                }

                posBin = new DualityWordBin(InnerPos.POS_A_NR, next);
                if (_PosBinTbl[posBin.HashCode] != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
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.º 4
0
        private void Hit(DualityWordBin posBin)
        {
            DualityWordBin bin = (DualityWordBin)_PosBinTbl[posBin.HashCode];

            if (bin == null)
            {
                bin        = new DualityWordBin(posBin._Pos1, posBin._Pos2);
                bin._Count = 1;
                _PosBinTbl[bin.HashCode] = bin;
                _PosBinList.Add(bin);
            }
            else
            {
                bin._Count++;
            }
        }
Ejemplo n.º 5
0
        public int CompareTo(object obj)
        {
            DualityWordBin dest = (DualityWordBin)obj;

            if (dest._Count == _Count)
            {
                return(0);
            }
            else if (dest._Count > _Count)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Ejemplo n.º 6
0
        public bool Match(String str1, String str2)
        {
            bool isReg;

            InnerPos[] posList1 = _POS.GetPos(str1, out isReg);
            if (!isReg)
            {
                return(false);
            }

            InnerPos[] posList2 = _POS.GetPos(str2, out isReg);
            if (!isReg)
            {
                return(false);
            }

            if (posList1.Length == 0 || posList2.Length == 0)
            {
                return(false);
            }

            foreach (InnerPos pos1 in posList1)
            {
                if (pos1 == InnerPos.POS_UNK)
                {
                    continue;
                }

                foreach (InnerPos pos2 in posList2)
                {
                    if (pos2 == InnerPos.POS_UNK)
                    {
                        continue;
                    }

                    DualityWordBin posBin = new DualityWordBin(pos1, pos2);
                    if (_PosBinTbl[posBin.HashCode] != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }