Use findTerms instead of findTermsInternal
This commit is contained in:
parent
1c828d205c
commit
b6718dc4a4
@ -319,7 +319,8 @@ class Backend {
|
|||||||
|
|
||||||
async _onApiTermsFind({text, details, optionsContext}) {
|
async _onApiTermsFind({text, details, optionsContext}) {
|
||||||
const options = await this.getOptions(optionsContext);
|
const options = await this.getOptions(optionsContext);
|
||||||
const [definitions, length] = await this.translator.findTerms(text, details, options);
|
const mode = options.general.resultOutputMode;
|
||||||
|
const [definitions, length] = await this.translator.findTerms(mode, text, details, options);
|
||||||
definitions.splice(options.general.maxResults);
|
definitions.splice(options.general.maxResults);
|
||||||
return {length, definitions};
|
return {length, definitions};
|
||||||
}
|
}
|
||||||
@ -329,9 +330,9 @@ class Backend {
|
|||||||
const results = [];
|
const results = [];
|
||||||
while (text.length > 0) {
|
while (text.length > 0) {
|
||||||
const term = [];
|
const term = [];
|
||||||
const [definitions, sourceLength] = await this.translator.findTermsInternal(
|
const [definitions, sourceLength] = await this.translator.findTerms(
|
||||||
|
'simple',
|
||||||
text.substring(0, options.scanning.length),
|
text.substring(0, options.scanning.length),
|
||||||
dictEnabledSet(options),
|
|
||||||
{},
|
{},
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
@ -141,14 +141,16 @@ class Translator {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async findTerms(text, details, options) {
|
async findTerms(mode, text, details, options) {
|
||||||
switch (options.general.resultOutputMode) {
|
switch (mode) {
|
||||||
case 'group':
|
case 'group':
|
||||||
return await this.findTermsGrouped(text, details, options);
|
return await this.findTermsGrouped(text, details, options);
|
||||||
case 'merge':
|
case 'merge':
|
||||||
return await this.findTermsMerged(text, details, options);
|
return await this.findTermsMerged(text, details, options);
|
||||||
case 'split':
|
case 'split':
|
||||||
return await this.findTermsSplit(text, details, options);
|
return await this.findTermsSplit(text, details, options);
|
||||||
|
case 'simple':
|
||||||
|
return await this.findTermsSimple(text, details, options);
|
||||||
default:
|
default:
|
||||||
return [[], 0];
|
return [[], 0];
|
||||||
}
|
}
|
||||||
@ -216,6 +218,11 @@ class Translator {
|
|||||||
return [definitions, length];
|
return [definitions, length];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async findTermsSimple(text, details, options) {
|
||||||
|
const dictionaries = dictEnabledSet(options);
|
||||||
|
return await this.findTermsInternal(text, dictionaries, details, options);
|
||||||
|
}
|
||||||
|
|
||||||
async findTermsInternal(text, dictionaries, details, options) {
|
async findTermsInternal(text, dictionaries, details, options) {
|
||||||
text = Translator.getSearchableText(text, options);
|
text = Translator.getSearchableText(text, options);
|
||||||
if (text.length === 0) {
|
if (text.length === 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user