Simplify collapseEmphaticOptions options (#1196)

This commit is contained in:
toasted-nutbread 2021-01-01 23:16:44 -05:00 committed by GitHub
parent a02891e52c
commit 41f6de3e3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -301,22 +301,13 @@ class Translator {
}
_getAllDeinflections(text, options) {
const collapseEmphaticOptions = [[false, false]];
switch (options.collapseEmphaticSequences) {
case 'true':
collapseEmphaticOptions.push([true, false]);
break;
case 'full':
collapseEmphaticOptions.push([true, false], [true, true]);
break;
}
const textOptionVariantArray = [
this._getTextOptionEntryVariants(options.convertHalfWidthCharacters),
this._getTextOptionEntryVariants(options.convertNumericCharacters),
this._getTextOptionEntryVariants(options.convertAlphabeticCharacters),
this._getTextOptionEntryVariants(options.convertHiraganaToKatakana),
this._getTextOptionEntryVariants(options.convertKatakanaToHiragana),
collapseEmphaticOptions
this._getCollapseEmphaticOptions(options)
];
const jp = this._japaneseUtil;
@ -875,6 +866,19 @@ class Translator {
}
}
_getCollapseEmphaticOptions(options) {
const collapseEmphaticOptions = [[false, false]];
switch (options.collapseEmphaticSequences) {
case 'true':
collapseEmphaticOptions.push([true, false]);
break;
case 'full':
collapseEmphaticOptions.push([true, false], [true, true]);
break;
}
return collapseEmphaticOptions;
}
_getSecondarySearchDictionaryMap(enabledDictionaryMap) {
const secondarySearchDictionaryMap = new Map();
for (const [dictionary, details] of enabledDictionaryMap.entries()) {