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

            T_INNER_POS[] preList = m_POS.GetPos(preStr, out isReg);

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

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

                T_POSBin posBin = new T_POSBin(pre, T_INNER_POS.POS_D_N);
                if (m_PosBinTbl[posBin.HashCode] != null)
                {
                    return(true);
                }

                posBin = new T_POSBin(pre, T_INNER_POS.POS_A_NR);
                if (m_PosBinTbl[posBin.HashCode] != null)
                {
                    return(true);
                }
            }

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

            T_INNER_POS[] nextList = m_POS.GetPos(nextStr, out isReg);

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

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

                T_POSBin posBin = new T_POSBin(T_INNER_POS.POS_D_N, next);
                if (m_PosBinTbl[posBin.HashCode] != null)
                {
                    return(true);
                }

                posBin = new T_POSBin(T_INNER_POS.POS_A_NR, next);
                if (m_PosBinTbl[posBin.HashCode] != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #3
0
        private void Hit(T_POSBin posBin)
        {
            T_POSBin bin = (T_POSBin)m_PosBinTbl[posBin.HashCode];

            if (bin == null)
            {
                bin         = new T_POSBin(posBin.m_Pos1, posBin.m_Pos2);
                bin.m_Count = 1;
                m_PosBinTbl[bin.HashCode] = bin;
                m_PosBinList.Add(bin);
            }
            else
            {
                bin.m_Count++;
            }
        }
Exemple #4
0
        public int CompareTo(object obj)
        {
            T_POSBin dest = (T_POSBin)obj;

            if (dest.m_Count == m_Count)
            {
                return(0);
            }
            else if (dest.m_Count > m_Count)
            {
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Exemple #5
0
        public bool Match(String str1, String str2)
        {
            bool isReg;

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

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

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

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

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

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

            return(false);
        }
Exemple #6
0
        public void Traffic(List <String> words)
        {
            for (int i = 0; i < words.Count - 1; i++)
            {
                bool          isReg;
                T_INNER_POS[] curPos  = m_POS.GetPos((String)words[i], out isReg);
                T_INNER_POS[] nextPos = m_POS.GetPos((String)words[i + 1], out isReg);


                //ArrayList curList = m_POS.GetPosList(curPos);

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

                T_INNER_POS pos1 = curPos[0];

                if (pos1 == T_INNER_POS.POS_UNK)
                {
                    continue;
                }


                //ArrayList nextList = m_POS.GetPosList(nextPos);

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

                T_INNER_POS pos2 = (T_INNER_POS)nextPos[0];

                if (pos2 == T_INNER_POS.POS_UNK)
                {
                    continue;
                }

                T_POSBin bin = new T_POSBin(pos1, pos2);

                Hit(bin);
            }
        }