diff --git a/demo/Makefile b/demo/Makefile index e7694f6..379abba 100644 --- a/demo/Makefile +++ b/demo/Makefile @@ -24,7 +24,6 @@ SRCDIR = ../src SRCLIB = $(SRCDIR)/libcppjieba.a # remove the objs after compilation -.INTERMEDIATE: $(OBJS) .PHONY: clean $(SRCLIB) # Main Targets diff --git a/demo/segment_demo.cpp b/demo/segment_demo.cpp index dd3b99c..6fb9df1 100644 --- a/demo/segment_demo.cpp +++ b/demo/segment_demo.cpp @@ -5,7 +5,8 @@ using namespace CppJieba; Segment seg; -bool init(const char * const filePath) +HMMSegment hmmseg; +bool init(const char * const dictPath, const char * const modelPath) { if(!seg.init()) { @@ -13,11 +14,16 @@ bool init(const char * const filePath) return false; } - if(!seg.loadSegDict(filePath)) + if(!seg.loadSegDict(dictPath)) { cout<<"seg loadDict failed."< res; + string line; + while(getline(ifile, line)) + { + res.clear(); + if(!line.empty()) + { + hmmseg.cut(line, res); + cout< mpss; - getArgvMap(argc, argv, mpss); - string enc = getMap(mpss, "--encoding", ""); - string dictPath = getMap(mpss, "--dictpath", "../dicts/jieba.dict.gbk"); - */ if(argc < 2) { cout<<"usage: \n\t"<\n" <<"options:\n" - <<"\t--dictpath\tIf is not specified, the default is ../dicts/jieba.dict.utf8\n" + <<"\t--algorithm\tSupported encoding methods are [cutDAG, cutHMM] for now. \n\t\t\tIf is not specified, the default is cutDAG\n" + <<"\t--dictpath\tIf is not specified, the default is "< tmp; @@ -98,6 +99,8 @@ namespace CppJieba return false; } + LogInfo(string_format("loadModel [%s] end.", filePath)); + return true; } @@ -117,6 +120,7 @@ namespace CppJieba return false; } + cout<<__FILE__<<__LINE__<= 0; x--) { status[x] = stat; + cout<<__FILE__<<__LINE__< res; - hmm.cut("小明硕士毕业于北邮网络研究院", res); + hmm.cut("小明硕士毕业于北邮网络研究院,然", res); cout<