diff --git a/Segment.cpp b/Segment.cpp index b19cffb..365e067 100644 --- a/Segment.cpp +++ b/Segment.cpp @@ -32,19 +32,7 @@ namespace CppJieba //calc DAG vector > dag; - for(uint i = 0; i < uniStr.size(); i+=2) - { - vector vec; - vec.push_back(i/2); - for(uint j = i + 4; j <= uniStr.size(); j+=2) - { - if(NULL != _trie.find(uniStr.substr(i, j - i))) - { - vec.push_back((j - 2)/2); - } - } - dag.push_back(vec); - } + _calcDAG(uniStr, dag); cout<<__FILE__<<__LINE__< >& dag) + { + for(uint i = 0; i < uniStr.size(); i+=2) + { + vector vec; + vec.push_back(i/2); + for(uint j = i + 4; j <= uniStr.size(); j+=2) + { + if(NULL != _trie.find(uniStr.substr(i, j - i))) + { + vec.push_back((j - 2)/2); + } + } + dag.push_back(vec); + } + return true; + } + bool Segment::_calcDP(const string& uniStr, const vector >& dag, vector >& res) { if(uniStr.size() / 2 != dag.size()) diff --git a/Segment.h b/Segment.h index 1ebceb1..992cd81 100644 --- a/Segment.h +++ b/Segment.h @@ -22,6 +22,7 @@ namespace CppJieba private: string _utf8ToUni(const string& chStr); + bool _calcDAG(const string& uniStr, vector >& dag); bool _calcDP(const string& uniStr, const vector >& dag, vector >& res); private: