aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/language')
-rw-r--r--ext/js/language/dictionary-database.js12
-rw-r--r--ext/js/language/translator.js12
2 files changed, 12 insertions, 12 deletions
diff --git a/ext/js/language/dictionary-database.js b/ext/js/language/dictionary-database.js
index 25adb571..c20921b5 100644
--- a/ext/js/language/dictionary-database.js
+++ b/ext/js/language/dictionary-database.js
@@ -196,7 +196,7 @@ class DictionaryDatabase {
}
}
- findTermsBulk(termList, dictionaries, wildcard) {
+ findTermsBulk(termList, dictionaries, matchType) {
const visited = new Set();
const predicate = (row) => {
if (!dictionaries.has(row.dictionary)) { return false; }
@@ -206,17 +206,17 @@ class DictionaryDatabase {
return true;
};
- const indexNames = (wildcard === 'prefix') ? ['expressionReverse', 'readingReverse'] : ['expression', 'reading'];
+ const indexNames = (matchType === 'suffix') ? ['expressionReverse', 'readingReverse'] : ['expression', 'reading'];
let createQuery;
- switch (wildcard) {
- case 'suffix':
+ switch (matchType) {
+ case 'prefix':
createQuery = this._createBoundQuery1;
break;
- case 'prefix':
+ case 'suffix':
createQuery = this._createBoundQuery2;
break;
- default:
+ default: // 'exact'
createQuery = this._createOnlyQuery1;
break;
}
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)] : [];
}