From 18de12a21c8e3c9d00157262992e7935561f01db Mon Sep 17 00:00:00 2001 From: wyy Date: Sat, 7 Dec 2013 17:32:11 +0800 Subject: [PATCH] add NO_FILTER macro --- CMakeLists.txt | 1 + src/SegmentBase.hpp | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a6d5f9..00bb843 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,7 @@ ADD_DEFINITIONS(-std=c++0x -O3) IF (DEFINED ENC) ADD_DEFINITIONS(-DCPPJIEBA_${ENC}) ENDIF() +#ADD_DEFINITIONS(-DNO_FILTER) ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(dicts) ADD_SUBDIRECTORY(scripts) diff --git a/src/SegmentBase.hpp b/src/SegmentBase.hpp index 1e6168e..4fe73b2 100644 --- a/src/SegmentBase.hpp +++ b/src/SegmentBase.hpp @@ -31,13 +31,22 @@ namespace CppJieba LogError("not inited."); return false; } + Unicode unico; +#ifdef NO_FILTER + unico.clear(); + if(!TransCode::decode(str, unico)) + { + LogFatal("str[%s] decode failed.", str.c_str()); + return false; + } + return cut(unico.begin(), unico.end(), res); +#else const char * const cstr = str.c_str(); uint size = str.size(); uint offset = 0; string subs; int ret; uint len; - Unicode unico; while(offset < size) { const char * const nstr = cstr + offset; @@ -65,6 +74,7 @@ namespace CppJieba offset += len; } return true; +#endif } };