mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
fix bugs in segment
This commit is contained in:
parent
a9abe6eccb
commit
0fd8c4bd56
@ -158,6 +158,7 @@ namespace CppJieba
|
|||||||
//cout<<(i/2)<<","<<dag[i/2].size()<<","<<j<<endl;
|
//cout<<(i/2)<<","<<dag[i/2].size()<<","<<j<<endl;
|
||||||
int pos = dag[i][j];
|
int pos = dag[i][j];
|
||||||
double val = _trie.getWeight(iterBegin + i, iterBegin + pos + 1) + res[pos + 1].second;
|
double val = _trie.getWeight(iterBegin + i, iterBegin + pos + 1) + res[pos + 1].second;
|
||||||
|
//cout<<i<<","<<pos<<","<<val<<endl;
|
||||||
//double val = _trie.getWeight(uniStr.substr(i, pos * 2 - i + 2)) + res[pos + 1].second;
|
//double val = _trie.getWeight(uniStr.substr(i, pos * 2 - i + 2)) + res[pos + 1].second;
|
||||||
//cout<<pos<<","<<pos * 2 - i + 2<<","<<val<<endl;
|
//cout<<pos<<","<<pos * 2 - i + 2<<","<<val<<endl;
|
||||||
if(val > res[i].second)
|
if(val > res[i].second)
|
||||||
@ -167,6 +168,10 @@ namespace CppJieba
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//FOR_VECTOR(res, i)
|
||||||
|
//{
|
||||||
|
// cout<<i<<","<<res[i].first<<","<<res[i].second<<endl;
|
||||||
|
//}
|
||||||
res.pop_back();
|
res.pop_back();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -180,17 +185,21 @@ namespace CppJieba
|
|||||||
|
|
||||||
res.clear();
|
res.clear();
|
||||||
|
|
||||||
uint begin = 0;
|
uint begin = 0, end = 0;
|
||||||
VUINT16_CONST_ITER iterBegin = unicode.begin();
|
VUINT16_CONST_ITER iterBegin = unicode.begin();
|
||||||
for(uint i = 0; i < dp.size(); i++)
|
//for(uint i = 0; i < dp.size(); i++)
|
||||||
|
while(begin < dp.size() && end <= dp.size())
|
||||||
{
|
{
|
||||||
//cout<<dp[i].first<<","
|
//cout<<begin<<","
|
||||||
|
// <<dp[i].first<<","
|
||||||
// <<dp[i].second<<endl;
|
// <<dp[i].second<<endl;
|
||||||
uint end = dp[i].first + 1;
|
end = dp[begin].first + 1;
|
||||||
if(end <= begin)
|
//cout<<begin<<","<<end<<endl;
|
||||||
{
|
//if(end <= begin)
|
||||||
continue;
|
//{
|
||||||
}
|
// continue;
|
||||||
|
// }
|
||||||
|
//cout<<begin<<","<<end<<endl;
|
||||||
//string tmp = TransCode::vecToStr(uniStr.substr(begin, end - begin));
|
//string tmp = TransCode::vecToStr(uniStr.substr(begin, end - begin));
|
||||||
string tmp = TransCode::vecToStr(iterBegin + begin, iterBegin + end);
|
string tmp = TransCode::vecToStr(iterBegin + begin, iterBegin + end);
|
||||||
if(tmp.empty())
|
if(tmp.empty())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user