Create function for body of findTermsMerged's sequencedDefinitions loop
This commit is contained in:
parent
a08cbebeb3
commit
96f37fd9dc
@ -69,15 +69,7 @@ class Translator {
|
|||||||
return {sequencedDefinitions, defaultDefinitions};
|
return {sequencedDefinitions, defaultDefinitions};
|
||||||
}
|
}
|
||||||
|
|
||||||
async findTermsMerged(text, dictionaries, alphanumeric, options) {
|
async getMergedDefinition(text, dictionaries, sequencedDefinition, defaultDefinitions, secondarySearchTitles, mergedByTermIndices) {
|
||||||
const secondarySearchTitles = Object.keys(options.dictionaries).filter(dict => options.dictionaries[dict].allowSecondarySearches);
|
|
||||||
const titles = Object.keys(dictionaries);
|
|
||||||
const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric);
|
|
||||||
const {sequencedDefinitions, defaultDefinitions} = await this.getSequencedDefinitions(definitions, options.general.mainDictionary);
|
|
||||||
const definitionsMerged = [];
|
|
||||||
const mergedByTermIndices = new Set();
|
|
||||||
|
|
||||||
for (const sequencedDefinition of sequencedDefinitions) {
|
|
||||||
const result = sequencedDefinition.definitions;
|
const result = sequencedDefinition.definitions;
|
||||||
const rawDefinitionsBySequence = sequencedDefinition.rawDefinitions;
|
const rawDefinitionsBySequence = sequencedDefinition.rawDefinitions;
|
||||||
|
|
||||||
@ -143,10 +135,29 @@ class Translator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result.expressions = expressions;
|
result.expressions = expressions;
|
||||||
|
|
||||||
result.expression = Array.from(result.expression);
|
result.expression = Array.from(result.expression);
|
||||||
result.reading = Array.from(result.reading);
|
result.reading = Array.from(result.reading);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async findTermsMerged(text, dictionaries, alphanumeric, options) {
|
||||||
|
const secondarySearchTitles = Object.keys(options.dictionaries).filter(dict => options.dictionaries[dict].allowSecondarySearches);
|
||||||
|
const titles = Object.keys(dictionaries);
|
||||||
|
const {length, definitions} = await this.findTerms(text, dictionaries, alphanumeric);
|
||||||
|
const {sequencedDefinitions, defaultDefinitions} = await this.getSequencedDefinitions(definitions, options.general.mainDictionary);
|
||||||
|
const definitionsMerged = [];
|
||||||
|
const mergedByTermIndices = new Set();
|
||||||
|
|
||||||
|
for (const sequencedDefinition of sequencedDefinitions) {
|
||||||
|
const result = await this.getMergedDefinition(
|
||||||
|
text,
|
||||||
|
dictionaries,
|
||||||
|
sequencedDefinition,
|
||||||
|
defaultDefinitions,
|
||||||
|
secondarySearchTitles,
|
||||||
|
mergedByTermIndices
|
||||||
|
);
|
||||||
definitionsMerged.push(result);
|
definitionsMerged.push(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user