save canonical name of templates, use for multiple sources

This commit is contained in:
Andrea Vos 2020-09-05 21:45:30 +02:00
parent cad1ec4c61
commit 513720f214
3 changed files with 7 additions and 4 deletions

View File

@ -47,6 +47,7 @@ export const parseTemplates = (templatesRaw) => {
yield [
aliases[0],
new Template(
aliases[0],
t.description,
buildDict(function* () {
for (let morpheme of MORPHEMES) {

View File

@ -126,7 +126,8 @@ const escape = s => {
}
export class Template {
constructor (description, morphemes, plural, pluralHonorific, sources = [], aliases = [], history = null) {
constructor (canonicalName, description, morphemes, plural, pluralHonorific, sources = [], aliases = [], history = null) {
this.canonicalName = canonicalName;
this.description = description;
this.morphemes = morphemes
this.plural = plural;
@ -156,7 +157,7 @@ export class Template {
}
clone() {
return new Template(this.description, clone(this.morphemes), this.plural, this.pluralHonorific);
return new Template(this.canonicalName, this.description, clone(this.morphemes), this.plural, this.pluralHonorific);
}
equals(other) {
@ -170,6 +171,7 @@ export class Template {
}
return new Template(
this.canonicalName + '&' + other.canonicalName,
Array.isArray(this.description) ? [...this.description, other.description] : [this.description, other.description],
buildDict(function* (that, other) {
for (let morpheme of MORPHEMES) {
@ -224,7 +226,7 @@ export class Template {
m[MORPHEMES[parseInt(i)]] = data[parseInt(i)];
}
return new Template(data[data.length - 1], m, parseInt(data[MORPHEMES.length]) === 1, parseInt(data[MORPHEMES.length + 1]) === 1)
return new Template(m.pronoun_n, data[data.length - 1], m, parseInt(data[MORPHEMES.length]) === 1, parseInt(data[MORPHEMES.length + 1]) === 1)
}
}

View File

@ -49,7 +49,7 @@ export const getSources = (selectedTemplate) => {
let sources = {};
for (let multiple in sourcesForMultipleForms) {
if (sourcesForMultipleForms.hasOwnProperty(multiple)) {
if (multiple === selectedTemplate.morphemes.pronoun_n) {
if (multiple === selectedTemplate.canonicalName) {
sources[multiple] = sourcesForMultipleForms[multiple];
}
}