merged mode: merge other results with main dict
This commit is contained in:
parent
cfad3b3099
commit
72fe83d353
@ -89,7 +89,7 @@ function dictTermsSort(definitions, dictionaries=null) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return v2.expression.localeCompare(v1.expression);
|
return v2.expression.toString().localeCompare(v1.expression.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,8 @@ class Translator {
|
|||||||
|
|
||||||
const definitionsBySequence = dictTermsMergeBySequence(definitions, options.dictionary.main);
|
const definitionsBySequence = dictTermsMergeBySequence(definitions, options.dictionary.main);
|
||||||
|
|
||||||
const definitionsMerged = dictTermsGroup(definitionsBySequence['-1'], dictionaries);
|
// const definitionsMerged = dictTermsGroup(definitionsBySequence['-1'], dictionaries);
|
||||||
|
const definitionsMerged = [];
|
||||||
for (const sequence in definitionsBySequence) {
|
for (const sequence in definitionsBySequence) {
|
||||||
if (!(sequence > 0)) {
|
if (!(sequence > 0)) {
|
||||||
continue;
|
continue;
|
||||||
@ -114,11 +115,43 @@ class Translator {
|
|||||||
|
|
||||||
result.expressions = expressions;
|
result.expressions = expressions;
|
||||||
|
|
||||||
result.expression = Array.from(result.expression).join(', ');
|
// result.expression = Array.from(result.expression).join(', ');
|
||||||
result.reading = Array.from(result.reading).join(', ');
|
// result.reading = Array.from(result.reading).join(', ');
|
||||||
definitionsMerged.push(result);
|
definitionsMerged.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const postMergedIndices = new Set();
|
||||||
|
const mergeeIndicesByGloss = {};
|
||||||
|
for (const [i, definition] of definitionsBySequence['-1'].entries()) {
|
||||||
|
for (const [j, mergedDefinition] of definitionsMerged.entries()) {
|
||||||
|
if (mergedDefinition.expression.has(definition.expression)) {
|
||||||
|
if (mergedDefinition.reading.has(definition.reading) || (definition.reading === '' && mergedDefinition.reading.size === 0)) {
|
||||||
|
if (!mergeeIndicesByGloss[definition.glossary]) {
|
||||||
|
mergeeIndicesByGloss[definition.glossary] = new Set();
|
||||||
|
}
|
||||||
|
if (mergeeIndicesByGloss[definition.glossary].has(j)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
mergedDefinition.definitions.push(definition);
|
||||||
|
mergeeIndicesByGloss[definition.glossary].add(j);
|
||||||
|
postMergedIndices.add(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const strayDefinitions = [];
|
||||||
|
for (const [i, definition] of definitionsBySequence['-1'].entries()) {
|
||||||
|
if (postMergedIndices.has(i)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
strayDefinitions.push(definition);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const groupedDefinition of dictTermsGroup(strayDefinitions, dictionaries)) {
|
||||||
|
definitionsMerged.push(groupedDefinition);
|
||||||
|
}
|
||||||
|
|
||||||
for (const definition of definitionsMerged) {
|
for (const definition of definitionsMerged) {
|
||||||
await this.buildTermFrequencies(definition, titles);
|
await this.buildTermFrequencies(definition, titles);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user