Example #1
0
 public Extractor(string dictPath, string hmmPath, string userDict, string idfPath, string stopWordPath)
 {
     _extractor = JiebaImports.jieba_extractor_create_context(dictPath, hmmPath, userDict, idfPath, stopWordPath);
     if (_extractor == IntPtr.Zero)
     {
         throw new ArgumentException();
     }
 }
Example #2
0
 internal Extractor(Jieba jieba)
 {
     _jieba     = jieba;
     _extractor = JiebaImports.jieba_extractor_create_context_from_jieba_context(jieba.JiebaContext);
     if (_extractor == IntPtr.Zero)
     {
         throw new ArgumentException();
     }
 }
Example #3
0
        public List <(string, double)> Extract(string sentence, uint topN)
        {
            var weights = new JiebaImports.JiebaWeights();

            JiebaImports.jieba_extract(_extractor, sentence, topN, ref weights);
            var result = JiebaImports.JiebaWeights2StringList(ref weights);

            JiebaImports.jieba_weights_free(ref weights);
            return(result);
        }
Example #4
0
        public List <(string word, string tag)> Tag(string sentence)
        {
            var tags = new JiebaImports.JiebaTags();

            JiebaImports.jieba_cut_with_tag(JiebaContext, sentence, ref tags);
            var ret = JiebaImports.JiebaTags2StringList(ref tags);

            JiebaImports.jieba_tags_free(ref tags);
            return(ret);
        }
Example #5
0
        public List <string> CutForSearch(string sentence, bool hmm = true)
        {
            var words = new JiebaImports.JiebaWords();

            JiebaImports.jieba_cut_for_search(JiebaContext, sentence, ref words, hmm);
            var ret = JiebaImports.JiebaWords2StringList(ref words);

            JiebaImports.jieba_words_free(ref words);
            return(ret);
        }
Example #6
0
        public List <string> CutAll(string sentence)
        {
            var words = new JiebaImports.JiebaWords();

            JiebaImports.jieba_cut_all(JiebaContext, sentence, ref words);
            var ret = JiebaImports.JiebaWords2StringList(ref words);

            JiebaImports.jieba_words_free(ref words);
            return(ret);
        }
Example #7
0
        public Jieba(string dictPath, string hmmPath, string userDict, string idfPath, string stopWordPath)
        {
            JiebaContext = JiebaImports.jieba_create_context(dictPath, hmmPath, userDict, idfPath, stopWordPath);

            if (JiebaContext == IntPtr.Zero)
            {
                throw new ArgumentException();
            }

            _extractor = new Lazy <Extractor>(() => new Extractor(this));
        }