bool init(const string &dictPath, const string &hmmFilePath, const string &idfPath, const string &stopWordPath) { _loadIdfDict(idfPath); _loadStopWordDict(stopWordPath); LIMONP_CHECK(_segment.init(dictPath, hmmFilePath)); return true; };
bool init(const string& dictPath, const string& hmmFilePath, const string& charStatus, const string& startProb, const string& emitProb, const string& endProb, const string& transProb) { assert(!_getInitFlag()); _dictTrie.init(dictPath); assert(_dictTrie); return _setInitFlag(_segment.init(dictPath, hmmFilePath)); };
int main(int argc, char ** argv) { if(argc < 2) { cout<<"usage: \n\t"<<argv[0]<<" [options] <filename>\n" <<"options:\n" <<"\t--algorithm\tSupported methods are [cutDAG, cutHMM, cutMix] for now. \n\t\t\tIf not specified, the default is cutDAG\n" <<"\t--dictpath\tsee example\n" <<"\t--modelpath\tsee example\n" <<"example:\n" <<"\t"<<argv[0]<<" testlines.utf8 --dictpath dicts/jieba.dict.utf8\n" <<"\t"<<argv[0]<<" testlines.utf8 --modelpath dicts/hmm_model.utf8 --algorithm cutHMM\n" <<"\t"<<argv[0]<<" testlines.utf8 --dictpath dicts/jieba.dict.utf8 --modelpath dicts/hmm_model.utf8 --algorithm cutMix\n" <<endl; return EXIT_FAILURE; } ArgvContext arg(argc, argv); string dictPath = arg["--dictpath"]; string modelPath = arg["--modelpath"]; string algorithm = arg["--algorithm"]; if("cutHMM" == algorithm) { HMMSegment seg; if(!seg.init(modelPath.c_str())) { cout<<"seg init failed."<<endl; return EXIT_FAILURE; } cut(&seg, arg[1].c_str()); seg.dispose(); } else if("cutMix" == algorithm) { MixSegment seg; if(!seg.init(dictPath.c_str(), modelPath.c_str())) { cout<<"seg init failed."<<endl; return EXIT_FAILURE; } cut(&seg, arg[1].c_str()); seg.dispose(); } else { MPSegment seg; if(!seg.init(dictPath.c_str())) { cout<<"seg init failed."<<endl; return false; } cut(&seg, arg[1].c_str()); seg.dispose(); } return EXIT_SUCCESS; }
void init( const string& dictPath, const string& hmmFilePath, const string& userDictPath = "" ) { LIMONP_CHECK(_segment.init(dictPath, hmmFilePath, userDictPath)); _dictTrie = _segment.getDictTrie(); LIMONP_CHECK(_dictTrie); };
bool init(const string& dict, const string& model, size_t maxWordLen) { if (_getInitFlag()) { LogError("inited already."); return false; } if (!_mixSeg.init(dict, model)) { LogError("_mixSeg init"); return false; } if (!_fullSeg.init(dict)) { LogError("_fullSeg init"); return false; } _maxWordLen = maxWordLen; return _setInitFlag(true); }
int main(int argc, char ** argv) { //demo { HMMSegment seg; if(!seg.init("../dicts/hmm_model.utf8")) { cout<<"seg init failed."<<endl; return EXIT_FAILURE; } cut(&seg, "testlines.utf8"); seg.dispose(); } { MixSegment seg; if(!seg.init("../dicts/jieba.dict.utf8", "../dicts/hmm_model.utf8")) { cout<<"seg init failed."<<endl; return EXIT_FAILURE; } cut(&seg, "testlines.utf8"); cout<<"Cut type"<<endl; cut_type(&seg, "testlines.utf8"); cout<<endl; seg.dispose(); } { MPSegment seg; if(!seg.init("../dicts/jieba.dict.utf8")) { cout<<"seg init failed."<<endl; return false; } cut(&seg, "testlines.utf8"); seg.dispose(); } return EXIT_SUCCESS; }
bool init_c(const char * dict_path, const char * model_path) { return segment.init(dict_path, model_path); }
bool init(const string& dictPath, const string& hmmFilePath, const string& idfPath, const string& stopWordPath) { _loadIdfDict(idfPath); _loadStopWordDict(stopWordPath); return _setInitFlag(_segment.init(dictPath, hmmFilePath)); };