aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language/translator.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-03-26 19:50:54 -0400
committerGitHub <noreply@github.com>2021-03-26 19:50:54 -0400
commit90f7d5ba07340413aa7e43c3a0cc038690b32db3 (patch)
treeb3c57f9240de2e3a86cbc8dba5fe93d71e4067ae /ext/js/language/translator.js
parent482dd8c8d8339d29c9e7a202cbf4c54bf7cf291d (diff)
Add part of speech info (#1561)
* Add part of speech info to headwords * Expose parts of speech to Anki template rendering * Expose parts of speech * Update pitch accent categories * Update docs * Add part-of-speech * Update options and tests * Update markers * Update test data
Diffstat (limited to 'ext/js/language/translator.js')
-rw-r--r--ext/js/language/translator.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index ad9689ee..e99ac8db 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -917,8 +917,8 @@ class Translator {
return {originalText, transformedText, deinflectedText, isPrimary};
}
- _createTermHeadword(index, term, reading, sources, tags) {
- return {index, term, reading, sources, tags};
+ _createTermHeadword(index, term, reading, sources, tags, wordClasses) {
+ return {index, term, reading, sources, tags, wordClasses};
}
_createTermDefinition(index, headwordIndices, dictionary, tags, entries) {
@@ -953,7 +953,7 @@ class Translator {
}
_createTermDictionaryEntryFromDatabaseEntry(databaseEntry, originalText, transformedText, deinflectedText, reasons, isPrimary, enabledDictionaryMap) {
- const {expression, reading: rawReading, definitionTags, termTags, glossary, score, dictionary, id, sequence} = databaseEntry;
+ const {expression, reading: rawReading, definitionTags, termTags, glossary, score, dictionary, id, sequence, rules} = databaseEntry;
const reading = (rawReading.length > 0 ? rawReading : expression);
const {index: dictionaryIndex, priority: dictionaryPriority} = this._getDictionaryOrder(dictionary, enabledDictionaryMap);
const sourceTermExactMatchCount = (isPrimary && deinflectedText === expression ? 1 : 0);
@@ -975,7 +975,7 @@ class Translator {
dictionaryPriority,
sourceTermExactMatchCount,
maxTransformedTextLength,
- [this._createTermHeadword(0, expression, reading, [source], headwordTagGroups)],
+ [this._createTermHeadword(0, expression, reading, [source], headwordTagGroups, rules)],
[this._createTermDefinition(0, [0], dictionary, definitionTagGroups, glossary)]
);
}
@@ -1100,15 +1100,16 @@ class Translator {
_addTermHeadwords(headwordsMap, headwords) {
const headwordIndexMap = [];
- for (const {term, reading, sources, tags} of headwords) {
+ for (const {term, reading, sources, tags, wordClasses} of headwords) {
const key = this._createMapKey([term, reading]);
let headword = headwordsMap.get(key);
if (typeof headword === 'undefined') {
- headword = this._createTermHeadword(headwordsMap.size, term, reading, [], []);
+ headword = this._createTermHeadword(headwordsMap.size, term, reading, [], [], []);
headwordsMap.set(key, headword);
}
this._addUniqueSources(headword.sources, sources);
this._addUniqueTagGroups(headword.tags, tags);
+ this._addUniqueStrings(headword.wordClasses, wordClasses);
headwordIndexMap.push(headword.index);
}
return headwordIndexMap;