ci MPSegment.hpp

This commit is contained in:
wyy 2014-04-07 23:05:09 -07:00
parent 687ebfc19b
commit f254691e53

View File

@ -59,18 +59,22 @@ namespace CppJieba
virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const virtual bool cut(Unicode::const_iterator begin, Unicode::const_iterator end, vector<string>& res)const
{ {
assert(_getInitFlag()); assert(_getInitFlag());
if(begin == end)
{
return false;
}
vector<TrieNodeInfo> segWordInfos; vector<TrieNodeInfo> segWordInfos;
if(!cut(begin, end, segWordInfos)) if(!cut(begin, end, segWordInfos))
{ {
return false; return false;
} }
string tmp; string word;
for(size_t i = 0; i < segWordInfos.size(); i++) for(size_t i = 0; i < segWordInfos.size(); i++)
{ {
if(TransCode::encode(segWordInfos[i].word, tmp)) if(TransCode::encode(segWordInfos[i].word, word))
{ {
res.push_back(tmp); res.push_back(word);
} }
else else
{ {
@ -114,12 +118,6 @@ namespace CppJieba
private: private:
bool _calcDAG(Unicode::const_iterator begin, Unicode::const_iterator end, SegmentContext& segContext) const bool _calcDAG(Unicode::const_iterator begin, Unicode::const_iterator end, SegmentContext& segContext) const
{ {
if(begin >= end)
{
LogError("begin >= end.");
return false;
}
for(Unicode::const_iterator it = begin; it != end; it++) for(Unicode::const_iterator it = begin; it != end; it++)
{ {
SegmentChar schar(*it); SegmentChar schar(*it);