Update getMergedSecondarySearchResults to use findTermsExactBulk
This commit is contained in:
parent
4446cbeabb
commit
97de7883a3
@ -70,29 +70,34 @@ class Translator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getMergedSecondarySearchResults(text, expressionsMap, secondarySearchTitles) {
|
async getMergedSecondarySearchResults(text, expressionsMap, secondarySearchTitles) {
|
||||||
const secondarySearchResults = [];
|
|
||||||
if (secondarySearchTitles.length === 0) {
|
if (secondarySearchTitles.length === 0) {
|
||||||
return secondarySearchResults;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const expressionList = [];
|
||||||
|
const readingList = [];
|
||||||
for (const expression of expressionsMap.keys()) {
|
for (const expression of expressionsMap.keys()) {
|
||||||
if (expression === text) {
|
if (expression === text) { continue; }
|
||||||
continue;
|
for (const reading of expressionsMap.get(expression).keys()) {
|
||||||
|
expressionList.push(expression);
|
||||||
|
readingList.push(reading);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const reading of expressionsMap.get(expression).keys()) {
|
const definitions = await this.database.findTermsExactBulk(expressionList, readingList, secondarySearchTitles);
|
||||||
for (const definition of await this.database.findTermsExact(expression, reading, secondarySearchTitles)) {
|
for (const definition of definitions) {
|
||||||
const definitionTags = await this.expandTags(definition.definitionTags, definition.dictionary);
|
const definitionTags = await this.expandTags(definition.definitionTags, definition.dictionary);
|
||||||
definitionTags.push(dictTagBuildSource(definition.dictionary));
|
definitionTags.push(dictTagBuildSource(definition.dictionary));
|
||||||
definition.definitionTags = definitionTags;
|
definition.definitionTags = definitionTags;
|
||||||
const termTags = await this.expandTags(definition.termTags, definition.dictionary);
|
const termTags = await this.expandTags(definition.termTags, definition.dictionary);
|
||||||
definition.termTags = termTags;
|
definition.termTags = termTags;
|
||||||
secondarySearchResults.push(definition);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return secondarySearchResults;
|
if (definitions.length > 1) {
|
||||||
|
definitions.sort((a, b) => a.index - b.index);
|
||||||
|
}
|
||||||
|
|
||||||
|
return definitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMergedDefinition(text, dictionaries, sequencedDefinition, defaultDefinitions, secondarySearchTitles, mergedByTermIndices) {
|
async getMergedDefinition(text, dictionaries, sequencedDefinition, defaultDefinitions, secondarySearchTitles, mergedByTermIndices) {
|
||||||
|
Loading…
Reference in New Issue
Block a user