Use stable sort in the engine.
So that unigram nodes with the same log probability are sorted according to the order in which they were added to the language model.
This commit is contained in:
parent
7b4568e152
commit
71921b848a
|
@ -90,7 +90,7 @@ namespace Formosa {
|
|||
, m_selectedUnigramIndex(0)
|
||||
, m_score(0.0)
|
||||
{
|
||||
sort(m_unigrams.begin(), m_unigrams.end(), Unigram::ScoreCompare);
|
||||
stable_sort(m_unigrams.begin(), m_unigrams.end(), Unigram::ScoreCompare);
|
||||
|
||||
if (m_unigrams.size()) {
|
||||
m_score = m_unigrams[0].score;
|
||||
|
|
|
@ -1043,7 +1043,7 @@ public:
|
|||
vector<NodeAnchor> nodes = _builder->grid().nodesCrossingOrEndingAt(cursorIndex);
|
||||
|
||||
// sort the nodes, so that longer nodes (representing longer phrases) are placed at the top of the candidate list
|
||||
sort(nodes.begin(), nodes.end(), NodeAnchorDescendingSorter());
|
||||
stable_sort(nodes.begin(), nodes.end(), NodeAnchorDescendingSorter());
|
||||
|
||||
// then use the C++ trick to retrieve the candidates for each node at/crossing the cursor
|
||||
for (vector<NodeAnchor>::iterator ni = nodes.begin(), ne = nodes.end(); ni != ne; ++ni) {
|
||||
|
|
Loading…
Reference in New Issue