diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4abe00d..21f49f9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,6 +1,6 @@ SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}) -ADD_EXECUTABLE(segment.demo segment.cpp) +ADD_EXECUTABLE(segment.demo segment_demo.cpp) ADD_EXECUTABLE(keyword.demo keyword_demo.cpp) ADD_EXECUTABLE(tagging.demo tagging_demo.cpp) ADD_EXECUTABLE(load_test load_test.cpp) diff --git a/test/segment.cpp b/test/segment.cpp deleted file mode 100644 index 3ab250f..0000000 --- a/test/segment.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include -#include -#include "../src/MPSegment.hpp" -#include "../src/HMMSegment.hpp" -#include "../src/MixSegment.hpp" - -using namespace CppJieba; - -void cut(const ISegment * seg, const char * const filePath) -{ - ifstream ifile(filePath); - vector res; - string line; - while(getline(ifile, line)) - { - if(!line.empty()) - { - res.clear(); - seg->cut(line, res); - cout< +#include + +#define LOGGER_LEVEL LL_WARN + +#include "../src/MPSegment.hpp" +#include "../src/HMMSegment.hpp" +#include "../src/MixSegment.hpp" + +using namespace CppJieba; + +const char * const TEST_FILE = "../test/testdata/testlines.utf8"; +const char * const JIEBA_DICT_FILE = "../dict/jieba.dict.utf8"; +const char * const HMM_DICT_FILE = "../dict/hmm_model.utf8"; +const char * const USER_DICT_FILE = "../test/testdata/userdict.utf8"; + +void cut(const ISegment& seg, const char * const filePath) +{ + ifstream ifile(filePath); + vector words; + string line; + string res; + while(getline(ifile, line)) + { + if(!line.empty()) + { + words.clear(); + seg.cut(line, words); + join(words.begin(), words.end(), res, "/"); + cout<< res <