summaryrefslogtreecommitdiff
path: root/ext/js/language/dictionary-importer.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/language/dictionary-importer.js')
-rw-r--r--ext/js/language/dictionary-importer.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/js/language/dictionary-importer.js b/ext/js/language/dictionary-importer.js
index 4144de66..0a10900d 100644
--- a/ext/js/language/dictionary-importer.js
+++ b/ext/js/language/dictionary-importer.js
@@ -476,12 +476,16 @@ class DictionaryImporter {
}
_convertTermBankEntryV1(entry, dictionary) {
- const [expression, reading, definitionTags, rules, score, ...glossary] = entry;
+ let [expression, reading, definitionTags, rules, score, ...glossary] = entry;
+ expression = this._normalizeTermOrReading(expression);
+ reading = this._normalizeTermOrReading(reading.length > 0 ? reading : expression);
return {expression, reading, definitionTags, rules, score, glossary, dictionary};
}
_convertTermBankEntryV3(entry, dictionary) {
- const [expression, reading, definitionTags, rules, score, glossary, sequence, termTags] = entry;
+ let [expression, reading, definitionTags, rules, score, glossary, sequence, termTags] = entry;
+ expression = this._normalizeTermOrReading(expression);
+ reading = this._normalizeTermOrReading(reading.length > 0 ? reading : expression);
return {expression, reading, definitionTags, rules, score, glossary, sequence, termTags, dictionary};
}
@@ -580,4 +584,12 @@ class DictionaryImporter {
}
return counts;
}
+
+ _normalizeTermOrReading(text) {
+ try {
+ return text.normalize('NFC');
+ } catch (e) {
+ return text;
+ }
+ }
}