예제 #1
0
        public SegDecoderTagger CreateTagger(int nbest, int this_crf_max_word_num = BaseUtils.DEFAULT_CRF_MAX_WORD_NUM)
        {
            if (_modelReader == null)
            {
                return(null);
            }

            var tagger = new SegDecoderTagger(nbest, this_crf_max_word_num);

            tagger.init_by_model(_modelReader);

            return(tagger);
        }
예제 #2
0
        //Segment given text
        public int Segment(CRFSegOut[] pout,           //segment result
                           SegDecoderTagger tagger,    //Tagger per thread
                           List <List <string> > inbuf //feature set for segment
                           )
        {
            var ret = 0;

            if (inbuf.Count == 0)
            {
                //Empty input string
                return(BaseUtils.RETURN_SUCCESS);
            }

            ret = tagger.reset();
            if (ret < 0)
            {
                return(ret);
            }

            ret = tagger.add(inbuf);
            if (ret < 0)
            {
                return(ret);
            }

            //parse
            ret = tagger.parse();
            if (ret < 0)
            {
                return(ret);
            }

            //wrap result
            ret = tagger.output(pout);
            if (ret < 0)
            {
                return(ret);
            }

            return(BaseUtils.RETURN_SUCCESS);
        }