diff options
Diffstat (limited to 'ext/bg/js/translator.js')
-rw-r--r-- | ext/bg/js/translator.js | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/bg/js/translator.js b/ext/bg/js/translator.js index 67430aef..b3b90641 100644 --- a/ext/bg/js/translator.js +++ b/ext/bg/js/translator.js @@ -41,10 +41,17 @@ class Translator { }); } - findTerms(text, dictionaries, softKatakana) { + findTerms(text, dictionaries, softKatakana, alphanumeric) { const titles = Object.keys(dictionaries); const cache = {}; + if (!alphanumeric && text.length > 0) { + const c = text[0]; + if (!jpIsKana(c) && !jpIsKanji(c)) { + return Promise.resolve({length: 0, definitions: []}); + } + } + return this.findTermsDeinflected(text, titles, cache).then(deinfLiteral => { const textHiragana = wanakana._katakanaToHiragana(text); if (text !== textHiragana && softKatakana) { @@ -84,8 +91,8 @@ class Translator { }); } - findTermsGrouped(text, dictionaries, softKatakana) { - return this.findTerms(text, dictionaries, softKatakana).then(({length, definitions}) => { + findTermsGrouped(text, dictionaries, softKatakana, alphanumeric) { + return this.findTerms(text, dictionaries, softKatakana, alphanumeric).then(({length, definitions}) => { return {length, definitions: dictTermsGroup(definitions, dictionaries)}; }); } |