diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2021-09-26 11:08:16 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-26 11:08:16 -0400 |
commit | 9899727d7d53caed4c5b5e68176f7ed7f90a9438 (patch) | |
tree | 3d764007cf8e86cee23be969a2065a644b27f73d /ext/js/background/backend.js | |
parent | 88e71f82232781a1bc16701ce4719d770222ec4c (diff) |
Frequency dictionary sort (#1938)
* Add sortDictionary/sortDictionaryOrder options
* Update options
* Add API.getTermFrequencies
* Add settings
* Implement frequency dictionary sorting
* Update test
* Update test data
* Fix handling of undefined rank-based frequencies
Diffstat (limited to 'ext/js/background/backend.js')
-rw-r--r-- | ext/js/background/backend.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js index b9e1f51b..e76f4cfe 100644 --- a/ext/js/background/backend.js +++ b/ext/js/background/backend.js @@ -125,7 +125,8 @@ class Backend { ['triggerDatabaseUpdated', {async: false, contentScript: true, handler: this._onApiTriggerDatabaseUpdated.bind(this)}], ['testMecab', {async: true, contentScript: true, handler: this._onApiTestMecab.bind(this)}], ['textHasJapaneseCharacters', {async: false, contentScript: true, handler: this._onApiTextHasJapaneseCharacters.bind(this)}], - ['documentStart', {async: false, contentScript: true, handler: this._onApiDocumentStart.bind(this)}] + ['documentStart', {async: false, contentScript: true, handler: this._onApiDocumentStart.bind(this)}], + ['getTermFrequencies', {async: true, contentScript: true, handler: this._onApiGetTermFrequencies.bind(this)}] ]); this._messageHandlersWithProgress = new Map([ ]); @@ -748,6 +749,10 @@ class Backend { this._updateTabAccessibility(url, tab, frameId); } + async _onApiGetTermFrequencies({termReadingList, dictionaries}) { + return await this._translator.getTermFrequencies(termReadingList, dictionaries); + } + // Command handlers async _onCommandOpenSearchPage(params) { @@ -1953,7 +1958,7 @@ class Backend { const {wildcard} = details; const enabledDictionaryMap = this._getTranslatorEnabledDictionaryMap(options); const { - general: {mainDictionary}, + general: {mainDictionary, sortFrequencyDictionary, sortFrequencyDictionaryOrder}, scanning: {alphanumeric}, translation: { convertHalfWidthCharacters, @@ -1979,6 +1984,8 @@ class Backend { return { wildcard, mainDictionary, + sortFrequencyDictionary, + sortFrequencyDictionaryOrder, removeNonJapaneseCharacters: !alphanumeric, convertHalfWidthCharacters, convertNumericCharacters, |