remove bugs

This commit is contained in:
gwdwyy 2013-07-10 18:11:00 +08:00
parent 86d8fc3130
commit 1df57488f5
2 changed files with 12 additions and 5 deletions

View File

@ -66,7 +66,6 @@ namespace CppJieba
string Segment::_utf8ToUni(const string& utfStr)
{
char logBuf[bufSize];
string uniStr = utf8ToUnicode(utfStr);
if(uniStr.empty())

View File

@ -368,21 +368,29 @@ namespace CppJieba
for(size_t i = 0; i < _nodeInfoVec.size(); i++)
{
_totalCount += _nodeInfoVec[i].count;
//cout<<_nodeInfoVec[i].word<<_nodeInfoVec[i].count<<endl;
}
if(0 == _totalCount)
{
LogError("_totalCount == 0 .");
return false;
}
//normalize
for(size_t i = 0; i < _nodeInfoVec.size(); i++)
for(uint i = 0; i < _nodeInfoVec.size(); i++)
{
TrieNodeInfo& nodeInfo = _nodeInfoVec[i];
if(0 == nodeInfo.count)
{
LogFatal("nodeInfo.count == 0!");
return false;
}
nodeInfo.weight = log(double(nodeInfo.count)/double(_totalCount));
//cout<<_nodeInfoVec[i].weight<<endl;
if(_minWeight > nodeInfo.weight)
{
_minWeight = nodeInfo.weight;
}
}
//cout<<_minWeight<<endl;
return true;
}