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(); } }
internal Extractor(Jieba jieba) { _jieba = jieba; _extractor = JiebaImports.jieba_extractor_create_context_from_jieba_context(jieba.JiebaContext); if (_extractor == IntPtr.Zero) { throw new ArgumentException(); } }
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); }
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); }
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); }
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); }
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)); }