Don't add duplicate definitions (#889)
This commit is contained in:
parent
0cfaa1a5a8
commit
7ce87c51b4
@ -597,7 +597,7 @@ class Translator {
|
|||||||
|
|
||||||
_mergeByGlossary(definitions, glossaryDefinitionGroupMap) {
|
_mergeByGlossary(definitions, glossaryDefinitionGroupMap) {
|
||||||
for (const definition of definitions) {
|
for (const definition of definitions) {
|
||||||
const {expression, reading, dictionary, glossary} = definition;
|
const {expression, reading, dictionary, glossary, id} = definition;
|
||||||
|
|
||||||
const key = this._createMapKey([dictionary, ...glossary]);
|
const key = this._createMapKey([dictionary, ...glossary]);
|
||||||
let group = glossaryDefinitionGroupMap.get(key);
|
let group = glossaryDefinitionGroupMap.get(key);
|
||||||
@ -605,11 +605,15 @@ class Translator {
|
|||||||
group = {
|
group = {
|
||||||
expressions: new Set(),
|
expressions: new Set(),
|
||||||
readings: new Set(),
|
readings: new Set(),
|
||||||
definitions: []
|
definitions: [],
|
||||||
|
definitionIds: new Set()
|
||||||
};
|
};
|
||||||
glossaryDefinitionGroupMap.set(key, group);
|
glossaryDefinitionGroupMap.set(key, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const {definitionIds} = group;
|
||||||
|
if (definitionIds.has(id)) { continue; }
|
||||||
|
definitionIds.add(id);
|
||||||
group.expressions.add(expression);
|
group.expressions.add(expression);
|
||||||
group.readings.add(reading);
|
group.readings.add(reading);
|
||||||
group.definitions.push(definition);
|
group.definitions.push(definition);
|
||||||
|
Loading…
Reference in New Issue
Block a user