⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 postraffic.cs

📁 KTDictSeg 简介: KTDictSeg 是由KaiToo搜索开发的一款基于字典的简单中英文分词算法 * 主要功能: 中英文分词
💻 CS
字号:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace KTDictSeg
{
    public class PosTraffic
    {
        Hashtable m_PosBinTbl = new Hashtable();
        ArrayList m_PosBinList = new ArrayList();

        CPOS m_POS;

        public CPOS POS
        {
            get
            {
                return m_POS;
            }

            set
            {
                m_POS = value;
            }
        }

        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++;
            }
        }

        public ArrayList GetPosBinGroup()
        {
            m_PosBinList.Sort();
            return m_PosBinList;
        }

        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);
            }
        }

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -