diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-12-17 16:11:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-17 16:11:19 -0500 |
commit | 19ab9df6e4110ef7d5927c95993141a1f8960c53 (patch) | |
tree | 31849bf1e1c9622cd1aa3aeb0709ad95ffc744b1 /ext/js/language/translator.js | |
parent | 70fa701c906fa4319e0d62818fe5737e983b49ef (diff) |
Replace 'wildcard' parameter with 'matchType' (#2038)
Diffstat (limited to 'ext/js/language/translator.js')
-rw-r--r-- | ext/js/language/translator.js | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js index 28e1cfcc..5db781dd 100644 --- a/ext/js/language/translator.js +++ b/ext/js/language/translator.js @@ -63,7 +63,7 @@ class Translator { * @param options An object using the following structure: * ``` * { - * wildcard: (enum: null, 'prefix', 'suffix'), + * matchType: (enum: 'exact', 'prefix', 'suffix'), * mainDictionary: (string), * sortFrequencyDictionary: (null or string), * sortFrequencyDictionaryOrder: (enum: 'ascending', 'descending'), @@ -227,7 +227,6 @@ class Translator { // Find terms internal implementation async _findTermsInternal(text, enabledDictionaryMap, options) { - const {wildcard} = options; if (options.removeNonJapaneseCharacters) { text = this._getJapaneseOnlyText(text); } @@ -235,9 +234,10 @@ class Translator { return {dictionaryEntries: [], originalTextLength: 0}; } + const {matchType} = options; const deinflections = await ( - wildcard ? - this._findTermsWildcard(text, enabledDictionaryMap, wildcard) : + matchType && matchType !== 'exact' ? + this._findTermsWildcard(text, enabledDictionaryMap, matchType) : this._findTermDeinflections(text, enabledDictionaryMap, options) ); @@ -259,8 +259,8 @@ class Translator { return {dictionaryEntries, originalTextLength}; } - async _findTermsWildcard(text, enabledDictionaryMap, wildcard) { - const databaseEntries = await this._database.findTermsBulk([text], enabledDictionaryMap, wildcard); + async _findTermsWildcard(text, enabledDictionaryMap, matchType) { + const databaseEntries = await this._database.findTermsBulk([text], enabledDictionaryMap, matchType); return databaseEntries.length > 0 ? [this._createDeinflection(text, text, text, 0, [], databaseEntries)] : []; } |