mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
add NO_FILTER macro
This commit is contained in:
parent
45a5df5856
commit
18de12a21c
@ -4,6 +4,7 @@ ADD_DEFINITIONS(-std=c++0x -O3)
|
|||||||
IF (DEFINED ENC)
|
IF (DEFINED ENC)
|
||||||
ADD_DEFINITIONS(-DCPPJIEBA_${ENC})
|
ADD_DEFINITIONS(-DCPPJIEBA_${ENC})
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
#ADD_DEFINITIONS(-DNO_FILTER)
|
||||||
ADD_SUBDIRECTORY(src)
|
ADD_SUBDIRECTORY(src)
|
||||||
ADD_SUBDIRECTORY(dicts)
|
ADD_SUBDIRECTORY(dicts)
|
||||||
ADD_SUBDIRECTORY(scripts)
|
ADD_SUBDIRECTORY(scripts)
|
||||||
|
@ -31,13 +31,22 @@ namespace CppJieba
|
|||||||
LogError("not inited.");
|
LogError("not inited.");
|
||||||
return false;
|
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();
|
const char * const cstr = str.c_str();
|
||||||
uint size = str.size();
|
uint size = str.size();
|
||||||
uint offset = 0;
|
uint offset = 0;
|
||||||
string subs;
|
string subs;
|
||||||
int ret;
|
int ret;
|
||||||
uint len;
|
uint len;
|
||||||
Unicode unico;
|
|
||||||
while(offset < size)
|
while(offset < size)
|
||||||
{
|
{
|
||||||
const char * const nstr = cstr + offset;
|
const char * const nstr = cstr + offset;
|
||||||
@ -65,6 +74,7 @@ namespace CppJieba
|
|||||||
offset += len;
|
offset += len;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user