mirror of
https://github.com/yanyiwu/cppjieba.git
synced 2025-07-18 00:00:12 +08:00
fix bug: cmp function pair<string, uint> -> pair<string, double>
This commit is contained in:
parent
5cf310f445
commit
31bcaeb11e
@ -138,8 +138,10 @@ namespace CppJieba
|
||||
itr ++;
|
||||
}
|
||||
|
||||
keywords.resize(MIN(topN, wordmap.size()));
|
||||
partial_sort_copy(wordmap.begin(), wordmap.end(), keywords.begin(), keywords.end(), _cmp);
|
||||
keywords.clear();
|
||||
std::copy(wordmap.begin(), wordmap.end(), std::inserter(keywords, keywords.begin()));
|
||||
topN = MIN(topN, keywords.size());
|
||||
partial_sort(keywords.begin(), keywords.begin() + topN, keywords.end(), _cmp);
|
||||
return true;
|
||||
}
|
||||
private:
|
||||
@ -153,7 +155,7 @@ namespace CppJieba
|
||||
}
|
||||
|
||||
private:
|
||||
static bool _cmp(const pair<string, uint>& lhs, const pair<string, uint>& rhs)
|
||||
static bool _cmp(const pair<string, double>& lhs, const pair<string, double>& rhs)
|
||||
{
|
||||
return lhs.second > rhs.second;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user