summaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-07 12:18:44 -0500
committerGitHub <noreply@github.com>2021-03-07 12:18:44 -0500
commit92fe1571aeee0717b85c6b47ed203852faf42d80 (patch)
tree4b7df4759be0d27569d762bb20bebf70ca824176 /ext/js
parent49bf56269032b568772d8446b039d85309de98f5 (diff)
Translator data format improvements (#1500)
* Update _createTermDetailsList usage and docs * Update source of expression/reading/furiganaSegments
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/language/translator.js16
1 files changed, 13 insertions, 3 deletions
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index 0533f70b..e20cc50f 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -190,8 +190,8 @@ class Translator {
}
for (const groupedDefinition of this._groupTerms(unsequencedDefinitions, enabledDictionaryMap)) {
- const {reasons, score, expression, reading, source, rawSource, sourceTerm, furiganaSegments, termTags, definitions: definitions2} = groupedDefinition;
- const termDetailsList = [this._createTermDetails(sourceTerm, expression, reading, furiganaSegments, termTags)];
+ const {reasons, score, expression, reading, source, rawSource, definitions: definitions2} = groupedDefinition;
+ const termDetailsList = this._createTermDetailsList(definitions2);
const compatibilityDefinition = this._createMergedTermDefinition(
source,
rawSource,
@@ -1119,8 +1119,13 @@ class Translator {
};
}
+ /**
+ * Creates a grouped definition from an array of 'term' definitions.
+ * @param definitions An array of 'term' definitions.
+ * @returns A single 'termGrouped' definition.
+ */
_createGroupedTermDefinition(definitions) {
- const {expression, reading, furiganaSegments, reasons, source, rawSource, sourceTerm} = definitions[0];
+ const {reasons, source, rawSource, sourceTerm, expressions: [{expression, reading, furiganaSegments}]} = definitions[0];
const score = this._getMaxDefinitionScore(definitions);
const dictionaryOrder = this._getBestDictionaryOrder(definitions);
const dictionaryNames = this._getUniqueDictionaryNames(definitions);
@@ -1235,6 +1240,11 @@ class Translator {
};
}
+ /**
+ * Creates a list of term details from an array of 'term' definitions.
+ * @param definitions An array of 'term' definitions.
+ * @returns An array of term details.
+ */
_createTermDetailsList(definitions) {
const termInfoMap = new Map();
for (const {expression, reading, sourceTerm, furiganaSegments, termTags} of definitions) {