summaryrefslogtreecommitdiff
path: root/ext/js/language
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-06 15:53:45 -0500
committerGitHub <noreply@github.com>2021-03-06 15:53:45 -0500
commit16217728afe0f9ff7dcbb7c7b7ead454ccc8705f (patch)
tree126bc188bd675343ee4e796826177e14f6664094 /ext/js/language
parenta65742a884223451324fcab5cfaeb6ebdfe32ec1 (diff)
Improve empty reading handling (#1497)
* Handle empty readings earlier in the definition creation process * Remove empty reading check * Remove special handling of empty readings
Diffstat (limited to 'ext/js/language')
-rw-r--r--ext/js/language/dictionary-data-util.js3
-rw-r--r--ext/js/language/japanese-util.js2
-rw-r--r--ext/js/language/translator.js6
3 files changed, 5 insertions, 6 deletions
diff --git a/ext/js/language/dictionary-data-util.js b/ext/js/language/dictionary-data-util.js
index 70a51e89..b3a354a7 100644
--- a/ext/js/language/dictionary-data-util.js
+++ b/ext/js/language/dictionary-data-util.js
@@ -96,8 +96,7 @@ class DictionaryDataUtil {
const allExpressions = new Set();
const allReadings = new Set();
- for (let {expression, reading, pitches: expressionPitches} of definition.expressions) {
- if (reading.length === 0) { reading = expression; }
+ for (const {expression, reading, pitches: expressionPitches} of definition.expressions) {
allExpressions.add(expression);
allReadings.add(reading);
diff --git a/ext/js/language/japanese-util.js b/ext/js/language/japanese-util.js
index 861d66e8..b363ed5c 100644
--- a/ext/js/language/japanese-util.js
+++ b/ext/js/language/japanese-util.js
@@ -430,7 +430,7 @@ const JapaneseUtil = (() => {
// Furigana distribution
distributeFurigana(expression, reading) {
- if (!reading || reading === expression) {
+ if (reading === expression) {
// Same
return [this._createFuriganaSegment(expression, '')];
}
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index 28cc1f3c..0533f70b 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -648,8 +648,7 @@ class Translator {
for (const {expressions, frequencies: frequencies1, pitches: pitches1} of allDefinitions) {
for (let i = 0, ii = expressions.length; i < ii; ++i) {
- let {expression, reading, frequencies: frequencies2, pitches: pitches2} = expressions[i];
- if (reading.length === 0) { reading = expression; }
+ const {expression, reading, frequencies: frequencies2, pitches: pitches2} = expressions[i];
let readingMap = expressionMap.get(expression);
if (typeof readingMap === 'undefined') {
readingMap = new Map();
@@ -1079,7 +1078,8 @@ class Translator {
}
async _createTermDefinitionFromDatabaseDefinition(databaseDefinition, source, rawSource, sourceTerm, reasons, isPrimary, enabledDictionaryMap) {
- const {expression, reading, definitionTags, termTags, glossary, score, dictionary, id, sequence} = databaseDefinition;
+ const {expression, reading: rawReading, definitionTags, termTags, glossary, score, dictionary, id, sequence} = databaseDefinition;
+ const reading = (rawReading.length > 0 ? rawReading : expression);
const dictionaryOrder = this._getDictionaryOrder(dictionary, enabledDictionaryMap);
const termTagsExpanded = await this._expandTags(termTags, dictionary);
const definitionTagsExpanded = await this._expandTags(definitionTags, dictionary);