示例#1
0
        //Load unknown recognition dictionary
        //Load context
        //type: Unknown words type (including person,place,transliterion and so on)
        public bool Configure(string sConfigFile, TAG_TYPE type)
        {
            //Load the unknown recognition dictionary
            m_dict.Load(sConfigFile + ".dct");

            //Load the unknown recognition context
            m_roleTag.LoadContext(sConfigFile + ".ctx");

            //Set the tagging type
            m_roleTag.SetTagType(type);
            switch (type)
            {
            case TAG_TYPE.TT_PERSON:
            case TAG_TYPE.TT_TRANS_PERSON:
                //Set the special flag for transliterations
                m_nPOS          = -28274; //-'n'*256-'r';
                m_sUnknownFlags = "未##人";
                break;

            case TAG_TYPE.TT_PLACE:
                m_nPOS          = -28275; //-'n'*256-'s';
                m_sUnknownFlags = "未##地";
                break;

            default:
                m_nPOS = 0;
                break;
            }
            return(true);
        }
示例#2
0
        public bool InitWordSegment(string pPath)
        {
            string filename;

            filename = pPath + "coreDict.dct";
            if (!m_dictCore.Load(filename))
            {
                return(false);
            }

            filename = pPath + "lexical.ctx";
            if (!m_POSTagger.LoadContext(filename))
            {
                return(false);
            }
            m_POSTagger.SetTagType();

            filename = pPath + "nr";
            if (!m_uPerson.Configure(filename, TAG_TYPE.TT_PERSON))
            {
                return(false);
            }

            filename = pPath + "ns";
            if (!m_uPlace.Configure(filename, TAG_TYPE.TT_PLACE))
            {
                return(false);
            }

            filename = pPath + "tr";
            if (!m_uTransPerson.Configure(filename, TAG_TYPE.TT_TRANS_PERSON))
            {
                return(false);
            }

            filename = pPath + "BigramDict.dct";
            if (!m_dictBigram.Load(filename))
            {
                return(false);
            }

            return(true);
        }