aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/dictionary.js
diff options
context:
space:
mode:
authorsiikamiika <siikamiika@users.noreply.github.com>2017-10-11 09:18:55 +0300
committersiikamiika <siikamiika@users.noreply.github.com>2017-10-11 09:18:55 +0300
commit4fb983a70cd02c0c0126a26e70d40261d5b2a51d (patch)
tree5811191bc6974b8c2813abd5d944e0b1661df4f4 /ext/bg/js/dictionary.js
parente1c5d7a401f1f974da1bedd8600524d982c2c7de (diff)
add termTags
The dictionary tags field can now have a '\t' in it, and it is used to separate tags associated with definitions and terms.
Diffstat (limited to 'ext/bg/js/dictionary.js')
-rw-r--r--ext/bg/js/dictionary.js31
1 files changed, 6 insertions, 25 deletions
diff --git a/ext/bg/js/dictionary.js b/ext/bg/js/dictionary.js
index b6ca6fd5..ee4f5946 100644
--- a/ext/bg/js/dictionary.js
+++ b/ext/bg/js/dictionary.js
@@ -136,6 +136,7 @@ function dictTermsGroup(definitions, dictionaries) {
expression: firstDef.expression,
reading: firstDef.reading,
reasons: firstDef.reasons,
+ termTags: groupDefs[0].termTags,
score: groupDefs.reduce((p, v) => v.score > p ? v.score : p, Number.MIN_SAFE_INTEGER),
source: firstDef.source
});
@@ -226,14 +227,16 @@ function dictTermsMergeByGloss(result, definitions, appendTo, mergedIndices) {
}
for (const tag of definition.tags) {
- if (dictIsJmdictTermTag(tag)) {
- result.expressions.get(definition.expression).get(definition.reading).add(tag);
- } else if (typeof tag === 'string') {
+ if (typeof tag === 'string') {
definitionsByGloss[gloss].tags.add(tag);
} else if (tag.category && tag.category !== 'dictionary') {
definitionsByGloss[gloss].tags.add(tag.name);
}
}
+
+ for (const tag of definition.termTags) {
+ result.expressions.get(definition.expression).get(definition.reading).add(tag);
+ }
}
for (const gloss in definitionsByGloss) {
@@ -288,34 +291,12 @@ function dictTagsSort(tags) {
});
}
-function dictIsJmdictTermTag(tag) {
- return [
- 'P',
- 'news',
- 'ichi',
- 'spec',
- 'gai',
- 'ik',
- 'iK',
- 'ok',
- 'oK',
- 'ek',
- 'eK',
- 'io',
- 'oik',
- 'ateji',
- 'gikun'
- ].includes(tag);
-}
-
function dictJmdictTermTagsRare(tags) {
const rareTags = [
'ik',
'iK',
'ok',
'oK',
- 'ek',
- 'eK',
'io',
'oik'
];