mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
remove bugs
This commit is contained in:
parent
86d8fc3130
commit
1df57488f5
@ -66,7 +66,6 @@ namespace CppJieba
|
||||
|
||||
string Segment::_utf8ToUni(const string& utfStr)
|
||||
{
|
||||
char logBuf[bufSize];
|
||||
string uniStr = utf8ToUnicode(utfStr);
|
||||
|
||||
if(uniStr.empty())
|
||||
|
16
Trie.cpp
16
Trie.cpp
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user