Sort using frequency dictionary before using dictionary priority (#2165)

This commit is contained in:
toasted-nutbread 2022-05-29 13:32:22 -04:00 committed by GitHub
parent 46fda6e653
commit 5d0c22e76d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1376,14 +1376,14 @@ class Translator {
i = v2.sourceTermExactMatchCount - v1.sourceTermExactMatchCount; i = v2.sourceTermExactMatchCount - v1.sourceTermExactMatchCount;
if (i !== 0) { return i; } if (i !== 0) { return i; }
// Sort by dictionary priority
i = v2.dictionaryPriority - v1.dictionaryPriority;
if (i !== 0) { return i; }
// Sort by frequency order // Sort by frequency order
i = v1.frequencyOrder - v2.frequencyOrder; i = v1.frequencyOrder - v2.frequencyOrder;
if (i !== 0) { return i; } if (i !== 0) { return i; }
// Sort by dictionary priority
i = v2.dictionaryPriority - v1.dictionaryPriority;
if (i !== 0) { return i; }
// Sort by term score // Sort by term score
i = v2.score - v1.score; i = v2.score - v1.score;
if (i !== 0) { return i; } if (i !== 0) { return i; }
@ -1411,12 +1411,12 @@ class Translator {
_sortTermDictionaryEntryDefinitions(definitions) { _sortTermDictionaryEntryDefinitions(definitions) {
const compareFunction = (v1, v2) => { const compareFunction = (v1, v2) => {
// Sort by dictionary priority // Sort by frequency order
let i = v2.dictionaryPriority - v1.dictionaryPriority; let i = v1.frequencyOrder - v2.frequencyOrder;
if (i !== 0) { return i; } if (i !== 0) { return i; }
// Sort by frequency order // Sort by dictionary priority
i = v1.frequencyOrder - v2.frequencyOrder; i = v2.dictionaryPriority - v1.dictionaryPriority;
if (i !== 0) { return i; } if (i !== 0) { return i; }
// Sort by term score // Sort by term score