fix bug: cmp function pair<string, uint> -> pair<string, double>

This commit is contained in:
wyy 2014-02-10 11:08:26 +08:00
parent 5cf310f445
commit 31bcaeb11e

View File

@ -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;
}