diff options
author | Alex Yatskov <alex@foosoft.net> | 2016-12-23 15:44:16 -0800 |
---|---|---|
committer | Alex Yatskov <alex@foosoft.net> | 2016-12-23 15:44:16 -0800 |
commit | 3047f8c4fce60fb392051572928bac04dfe10c08 (patch) | |
tree | 8e2c29b3deb9f2463890c1a07cff42d23d8327b8 /ext/bg/js/util.js | |
parent | 39fa11f72bae62985ee5b27103e5959dab30316c (diff) |
fixing various deinflection issues
Diffstat (limited to 'ext/bg/js/util.js')
-rw-r--r-- | ext/bg/js/util.js | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/ext/bg/js/util.js b/ext/bg/js/util.js index a0fca270..a37e223c 100644 --- a/ext/bg/js/util.js +++ b/ext/bg/js/util.js @@ -96,6 +96,23 @@ function sortTermDefs(definitions) { }); } +function undupeTermDefs(definitions) { + const definitionGroups = {}; + for (const definition of definitions) { + const definitionExisting = definitionGroups[definition.id]; + if (!definitionGroups.hasOwnProperty(definition.id) || definition.expression.length > definitionExisting.expression.length) { + definitionGroups[definition.id] = definition; + } + } + + const definitionsUnique = []; + for (const key in definitionGroups) { + definitionsUnique.push(definitionGroups[key]); + } + + return definitionsUnique; +} + function buildTag(name, meta) { const tag = {name}; const symbol = name.split(':')[0]; |