diff options
Diffstat (limited to 'ext/js')
-rw-r--r-- | ext/js/data/anki-note-data-creator.js | 4 | ||||
-rw-r--r-- | ext/js/language/translator.js | 18 |
2 files changed, 11 insertions, 11 deletions
diff --git a/ext/js/data/anki-note-data-creator.js b/ext/js/data/anki-note-data-creator.js index 4cf62788..c76369c3 100644 --- a/ext/js/data/anki-note-data-creator.js +++ b/ext/js/data/anki-note-data-creator.js @@ -274,7 +274,7 @@ class AnkiNoteDataCreator { case 'merge': type = 'termMerged'; break; } - const {id, inflections, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount} = dictionaryEntry; + const {ids, inflections, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount} = dictionaryEntry; const { screenshotFileName=null, @@ -301,7 +301,7 @@ class AnkiNoteDataCreator { return { type, - id: (type === 'term' ? id : void 0), + id: (type === 'term' ? ids[0] : void 0), source: (primarySource !== null ? primarySource.transformedText : null), rawSource: (primarySource !== null ? primarySource.originalText : null), sourceTerm: (type !== 'termMerged' ? (primarySource !== null ? primarySource.deinflectedText : null) : void 0), diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index bf2c7322..a36ef48c 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -358,7 +358,7 @@ class Translator { const groupedDictionaryEntriesMap = new Map(); const ungroupedDictionaryEntriesMap = new Map(); for (const dictionaryEntry of dictionaryEntries) { - const {id, definitions: [{dictionary, sequences: [sequence]}]} = dictionaryEntry; + const {ids: [id], definitions: [{dictionary, sequences: [sequence]}]} = dictionaryEntry; if (mainDictionary === dictionary && sequence >= 0) { let group = groupedDictionaryEntriesMap.get(sequence); if (typeof group === 'undefined') { @@ -448,12 +448,10 @@ class Translator { for (const {ids, dictionaryEntries} of target.groups) { if (ids.has(id)) { continue; } - dictionaryEntries.push(dictionaryEntry); ids.add(id); - ungroupedDictionaryEntriesMap.delete(id); - break; } + ungroupedDictionaryEntriesMap.delete(id); } // Search database for additional secondary terms @@ -1039,10 +1037,10 @@ class Translator { return {index, headwordIndex, dictionary, dictionaryIndex, dictionaryPriority, hasReading, frequency}; } - _createTermDictionaryEntry(id, isPrimary, inflections, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { + _createTermDictionaryEntry(ids, isPrimary, inflections, score, dictionaryIndex, dictionaryPriority, sourceTermExactMatchCount, maxTransformedTextLength, headwords, definitions) { return { type: 'term', - id, + ids, isPrimary, inflections, score, @@ -1073,7 +1071,7 @@ class Translator { if (definitionTags.length > 0) { definitionTagGroups.push(this._createTagGroup(dictionary, definitionTags)); } return this._createTermDictionaryEntry( - id, + [id], isPrimary, reasons, score, @@ -1111,6 +1109,7 @@ class Translator { const definitions = []; const definitionsMap = checkDuplicateDefinitions ? new Map() : null; let inflections = null; + const ids = new Set(); for (const {dictionaryEntry, headwordIndexMap} of definitionEntries) { score = Math.max(score, dictionaryEntry.score); @@ -1124,6 +1123,7 @@ class Translator { inflections = dictionaryEntryInflections; } } + for (const id of dictionaryEntry.ids) { ids.add(id); } if (checkDuplicateDefinitions) { this._addTermDefinitions(definitions, definitionsMap, dictionaryEntry.definitions, headwordIndexMap); } else { @@ -1144,7 +1144,7 @@ class Translator { } return this._createTermDictionaryEntry( - -1, + [...ids], isPrimary, inflections !== null ? inflections : [], score, @@ -1380,7 +1380,7 @@ class Translator { _sortTermDictionaryEntriesById(dictionaryEntries) { if (dictionaryEntries.length <= 1) { return; } - dictionaryEntries.sort((a, b) => a.id - b.id); + dictionaryEntries.sort((a, b) => a.ids[0] - b.ids[0]); } _sortTermDictionaryEntryData(dictionaryEntries) { |