diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-10-02 17:59:14 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-02 17:59:14 -0400 |
commit | ef333b6d72c00879b221e035c853c87298c12496 (patch) | |
tree | c84c871c0f9baf327317e10881669df8e16a336c /ext/bg/js/deinflector.js | |
parent | 50f2385aaffc39507402ad8260cb49501763d7dc (diff) |
Dictionary data structure improvements (#877)
* Simplify object structure of deinflections
* Modify existing array when removing duplicates
* Update _sortDefinitions to not return a value
* Use explicit argument value
* Use a Collator for string comparisons
* Simplify order comparison
* Improve tag creation and sanitization
* Switch .map to a for loop, skip null meta
* Add _createKanjiStat
* Move _sortDefinitions definition
* Fix kanji stat sorting
* Remove return value from _sortTags
* Add _sortKanji
* Add fast exits for sorting
* Add _sortDefinitionsByIndex
* Combine sort function
* Improve creation of kanji definition data
* Use "databaseDefinitions" instead of "definitions" to disambiguate
* Simplify
* Simplify further
* Simplify max length calculation
* More destructuring
* Use databaseDefinitions variable name
* Move _mergeBySequence body into _getSequencedDefinitions
* Use databaseDefinitions field name
* Move maxLength calculation
* Use shared _createTermDefinitionFromDatabaseDefinition
* Simplify map
* Move definition sorts for better consistency and less redundancy
* Move _createExpression function
* Update setup of sequenced definitions
* Simplify for loop
Diffstat (limited to 'ext/bg/js/deinflector.js')
-rw-r--r-- | ext/bg/js/deinflector.js | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/bg/js/deinflector.js b/ext/bg/js/deinflector.js index 6ec6e899..b13079ef 100644 --- a/ext/bg/js/deinflector.js +++ b/ext/bg/js/deinflector.js @@ -21,13 +21,14 @@ class Deinflector { this.reasons = Deinflector.normalizeReasons(reasons); } - deinflect(source) { + deinflect(source, rawSource) { const results = [{ source, + rawSource, term: source, rules: 0, - definitions: [], - reasons: [] + reasons: [], + databaseDefinitions: [] }]; for (let i = 0; i < results.length; ++i) { const {rules, term, reasons} = results[i]; @@ -43,10 +44,11 @@ class Deinflector { results.push({ source, + rawSource, term: term.substring(0, term.length - kanaIn.length) + kanaOut, rules: rulesOut, - definitions: [], - reasons: [reason, ...reasons] + reasons: [reason, ...reasons], + databaseDefinitions: [] }); } } |