UNPKG

taipa

Version:

Taiwanese morphological parsing library

634 lines 29.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FinalConsonantUnmutationInternal = exports.FinalConsonantMutationInternal = exports.FinalConsonantUnmutationExternal = exports.FinalConsonantMutationExternal = exports.UninfectionExternal = exports.InfectionExternal = exports.UninsertionFromEnclitic = exports.InsertionToEnclitic = exports.Conjunctive = exports.Adnominal = exports.ConjugateVppToParticiple = exports.ConjugateToParticiple = exports.ConjugateVppToTransitive = exports.ConjugateVppToProceeding = exports.ConjugateToProceeding = exports.ConsonantUnmutation = exports.ConsonantMutation = exports.Uninfection = exports.Infection = exports.Uninsertion = exports.Epenthesis = exports.TransfixInflection = exports.TonalDesinenceInflection = exports.FirstSeventhCombining = exports.PossesiveExCombining = exports.ConjunctiveLeCombining = exports.PhrasalVerbParticleCombining = exports.AdnominalECombining = exports.EighthToSecondCombining = exports.FourthToFirstCombining = exports.ThirdCombiningForm = exports.TonalCombiningForms = void 0; const tonalres_1 = require("../tonal/tonalres"); const collections_1 = require("../tonal/collections"); const metaplasm_1 = require("../metaplasm"); const unit_1 = require("../unchange/unit"); const unit_2 = require("../unit"); const unit_3 = require("../unchange/unit"); const metaplasm_2 = require("../metaplasm"); /** Returns the combining forms of a syllable. */ class TonalCombiningForms extends metaplasm_1.TonalCombiningMetaplasm { apply(sounds, allomorph) { if (allomorph) { let s = new unit_1.TonalSyllable(sounds.map((x) => new unit_2.AlphabeticLetter(x.characters))); if (allomorph instanceof tonalres_1.FreeAllomorph) { if (allomorph instanceof tonalres_1.ZeroAllomorph) { const tos = collections_1.combiningRules.get(tonalres_1.TonalLetterTags.zero); if (tos) { s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tos[0]).characters)); } return [s]; } else if (allomorph instanceof tonalres_1.AllomorphY) { s.popLetter(); return [s]; } else { s.popLetter(); const tos = collections_1.combiningRules.get(allomorph.tonal.toString()); const rets = []; if (tos) { for (let k = 0; k < tos.length; k++) { s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tos[k]).characters)); rets.push(new unit_1.TonalSyllable(s.letters)); s.popLetter(); } } return rets; } } else if (allomorph instanceof tonalres_1.CheckedAllomorph) { // nothing to pop here if (allomorph.tonal.toString().length > 0) return []; const tos = collections_1.combiningRules.get(allomorph.final.toString()); const rets = []; if (tos) { for (let k = 0; k < tos.length; k++) { if (allomorph.final.toString().length == 2) { // 8th finals are of length 2 s.popLetter(); // pop the 8th final const got = collections_1.eighthToFourthFinalConsonants.get(allomorph.final.toString()); if (got) { s.pushLetter(tonalres_1.lowerLettersTonal.get(got)); // push the 4th final } } s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tos[k]).characters)); rets.push(new unit_1.TonalSyllable(s.letters)); s.popLetter(); } } return rets; } } return []; } } exports.TonalCombiningForms = TonalCombiningForms; /** Changes to 3rd tone. */ class ThirdCombiningForm extends metaplasm_1.TonalCombiningMetaplasm { apply(sounds, allomorph) { if (allomorph) { const s = new unit_1.TonalSyllable(sounds.map((x) => new unit_2.AlphabeticLetter(x.characters))); if (allomorph instanceof tonalres_1.FreeAllomorph) { if (allomorph instanceof tonalres_1.ZeroAllomorph) { s.pushLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.w)); } else { s.popLetter(); s.pushLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.w)); } } else if (allomorph instanceof tonalres_1.CheckedAllomorph) { if (allomorph.tonal.toString()) { s.popLetter(); s.pushLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.w)); } else { s.pushLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.w)); } } return [s]; } return []; } } exports.ThirdCombiningForm = ThirdCombiningForm; /** Changes 4th tone to 1st tone. */ class FourthToFirstCombining extends metaplasm_1.TonalCombiningMetaplasm { apply(sounds, allomorph) { if (allomorph && allomorph instanceof tonalres_1.AllomorphH) { let s = new unit_1.TonalSyllable(sounds.map((x) => new unit_2.AlphabeticLetter(x.characters))); s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.f).characters)); return [s]; } return []; } } exports.FourthToFirstCombining = FourthToFirstCombining; /** Changes 8th tone to 2nd tone. */ class EighthToSecondCombining extends metaplasm_1.TonalCombiningMetaplasm { apply(sounds, allomorph) { if (allomorph && allomorph instanceof tonalres_1.CheckedAllomorph) { let s = new unit_1.TonalSyllable(sounds.map((x) => new unit_2.AlphabeticLetter(x.characters))); s.popLetter(); s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.h).characters)); s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.y).characters)); return [s]; } return []; } } exports.EighthToSecondCombining = EighthToSecondCombining; /** Returns the combining form of enclitic e. */ class AdnominalECombining extends metaplasm_1.TonalCombiningMetaplasm { apply(sounds, allomorph) { // 1->7, 7->7, 3->3 if (allomorph) { let s = new unit_1.TonalSyllable(sounds.map((x) => new unit_2.AlphabeticLetter(x.characters))); if (allomorph instanceof tonalres_1.FreeAllomorph) { if (allomorph instanceof tonalres_1.ZeroAllomorph) { const tos = collections_1.combiningRules.get(tonalres_1.TonalLetterTags.zero); if (tos) { // it should loop only once s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tos[0]).characters)); } return [s]; } } } return []; } } exports.AdnominalECombining = AdnominalECombining; /** Returns the combining form of a phrasal verb particle. */ class PhrasalVerbParticleCombining extends metaplasm_1.TonalCombiningMetaplasm { tone; constructor(tone) { super(); this.tone = tone; } toThird(syllable, final) { let s = new unit_1.TonalSyllable(syllable.letters); s.pushLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.w)); return s; } toFirst(syllable) { let s = new unit_1.TonalSyllable(syllable.letters); s.pushLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.f)); return s; } toSeventh(syllable) { let s = new unit_1.TonalSyllable(syllable.letters); s.popLetter(); s.pushLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.z)); return s; } apply(sounds, allomorph) { if (allomorph) { let s = new unit_1.TonalSyllable(sounds.map((it) => new unit_2.AlphabeticLetter(it.characters))); if (allomorph instanceof tonalres_1.CheckedAllomorph) { const ret = []; let syl = new unit_1.TonalSyllable([]); if (this.tone === tonalres_1.TonalLetterTags.f) { syl = this.toFirst(s); } else if (this.tone === tonalres_1.TonalLetterTags.w) { syl = this.toThird(s, sounds[sounds.length - 1].toString()); } else if (this.tone === tonalres_1.TonalLetterTags.z) { syl = this.toSeventh(s); } ret.push(syl); // TODO: free form of the syllable could be handled outside of this routine by popping out f/w and h/hh return ret; } } return []; } } exports.PhrasalVerbParticleCombining = PhrasalVerbParticleCombining; /** Returns the combining form of enclitic le. */ class ConjunctiveLeCombining extends metaplasm_1.TonalCombiningMetaplasm { apply(sounds, allomorph) { if (allomorph) { let s = new unit_1.TonalSyllable(sounds.map((x) => new unit_2.AlphabeticLetter(x.characters))); if (allomorph instanceof tonalres_1.FreeAllomorph) { if (allomorph.tonal.toString() === tonalres_1.TonalLetterTags.z || allomorph.tonal.toString() === tonalres_1.TonalLetterTags.w) { s.popLetter(); return [s]; } } } return []; } } exports.ConjunctiveLeCombining = ConjunctiveLeCombining; /** Returns the combining form of possesive case marker ex. */ class PossesiveExCombining extends metaplasm_1.TonalCombiningMetaplasm { apply(sounds, allomorph) { if (allomorph) { let s = new unit_1.TonalSyllable(sounds.map((x) => new unit_2.AlphabeticLetter(x.characters))); s.popLetter(); s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.w).characters)); return [s]; } return []; } } exports.PossesiveExCombining = PossesiveExCombining; /** Changes 4th tone to either 1st or 7th tone. */ class FirstSeventhCombining extends metaplasm_1.TonalCombiningMetaplasm { tone; constructor(tone) { super(); this.tone = tone; } apply(sounds, allomorph) { // from -h to 1 or 7 if (allomorph) { let s = new unit_1.TonalSyllable(sounds.map((x) => new unit_2.AlphabeticLetter(x.characters))); if (s.lastLetter.literal === tonalres_1.TonalLetterTags.h) { s.popLetter(); } if (this.tone === tonalres_1.TonalLetterTags.z) { s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.z).characters)); } else if (this.tone === tonalres_1.TonalLetterTags.zero && sounds[sounds.length - 1].toString() === tonalres_1.TonalLetterTags.t) { s.pushLetter(new unit_2.AlphabeticLetter(tonalres_1.lowerLettersTonal.get(tonalres_1.TonalLetterTags.f).characters)); } return [s]; } return []; } } exports.FirstSeventhCombining = FirstSeventhCombining; /** Inflects an inflectional suffix. */ class TonalDesinenceInflection extends metaplasm_1.TonalInflectionMetaplasm { apply(morphemes) { if (morphemes.length > 0 && morphemes[morphemes.length - 1]) { const last = morphemes[morphemes.length - 1]; const syls = last.getForms(); let rets = []; if (syls) { for (let i in syls) { let wd = new unit_3.TonalWord(morphemes.map((x) => new unit_1.TonalSyllable(x.syllable.letters))); wd.popSyllable(); wd.pushSyllable(syls[i]); rets.push(wd); } } return rets; } return []; } } exports.TonalDesinenceInflection = TonalDesinenceInflection; /** Inflects a transfix. */ class TransfixInflection extends metaplasm_1.TonalInflectionMetaplasm { apply(morphemes) { const rets = []; if (morphemes.length > 0) { const tw = new unit_3.TonalWord(morphemes.map((x) => new unit_1.TonalSyllable(x.syllable.letters))); for (let i = 0; i < morphemes.length; i++) { const form = morphemes[i].getForms()[0]; if (form) tw.replaceSyllable(i, form); } rets.push(tw); } return rets; } } exports.TransfixInflection = TransfixInflection; /** Inserts an initial m, n, or ng to syllable ay. */ class Epenthesis extends metaplasm_1.TonalInsertionMetaplasm { // adding of nasal consonants. insertion apply(morphemes) { if (morphemes.length > 1 && morphemes[morphemes.length - 2]) { const ltrs = morphemes[morphemes.length - 2].sounds; const wrd = new unit_3.TonalWord(morphemes.map((x) => new unit_1.TonalSyllable(x.syllable.letters))); if (ltrs[ltrs.length - 2].name == tonalres_1.TonalSpellingTags.nasalFinalConsonant && morphemes[morphemes.length - 1].syllable.letters[0].literal === tonalres_1.TonalLetterTags.a) { // m, n, ng followed by -ay. pass the preceding nasal to get forms wrd.popSyllable(); wrd.pushSyllable(morphemes[morphemes.length - 1].insertNasal(ltrs[ltrs.length - 2])[0]); return [wrd]; } // TODO: insert to syllable e. e.g. lagwex -> lagwgex } return []; } } exports.Epenthesis = Epenthesis; /** Uninsert an initial m, n, or ng from syllable ~ay */ class Uninsertion extends metaplasm_1.TonalUninsertionMetaplasm { // removal of nasal consonants apply(morphemes) { if (morphemes.length > 1 && morphemes[morphemes.length - 2]) { const ltrs = morphemes[morphemes.length - 2].sounds; const wrd = new unit_3.TonalWord(morphemes.map((it) => new unit_1.TonalSyllable(it.syllable.letters))); if (ltrs[ltrs.length - 2].name == tonalres_1.TonalSpellingTags.nasalFinalConsonant && collections_1.nasalInitialConsonants.includes(morphemes[morphemes.length - 1].syllable.letters[0].literal) && morphemes[morphemes.length - 1].syllable.letters[1].literal === tonalres_1.TonalLetterTags.a) { wrd.popSyllable(); wrd.pushSyllable(morphemes[morphemes.length - 1].uninsertNasal()[0]); return [wrd]; } } return []; } } exports.Uninsertion = Uninsertion; /** Infect the following syllable with nasalization. */ class Infection extends metaplasm_1.TonalInfectionMetaplasm { apply(morphemes) { if (morphemes.length > 1 && morphemes[morphemes.length - 2]) { const ltrs = morphemes[morphemes.length - 2].sounds; const wrd = new unit_3.TonalWord(morphemes.map((it) => new unit_1.TonalSyllable(it.syllable.letters))); if (ltrs.filter((it) => it.name === tonalres_1.TonalSpellingTags.nasalization) .length == 1) { // nasalization of vowels wrd.replaceSyllable(wrd.syllables.length - 1, morphemes[morphemes.length - 1].infect()[0]); return [wrd]; } } return []; } } exports.Infection = Infection; /** Uninfect the following syllable which is infected by a nasalization. */ class Uninfection extends metaplasm_1.TonalUninfectionMetaplasm { apply(morphemes) { if (morphemes.length > 1 && morphemes[morphemes.length - 2]) { const ltrs = morphemes[morphemes.length - 2].sounds; const wrd = new unit_3.TonalWord(morphemes.map((it) => new unit_1.TonalSyllable(it.syllable.letters))); if (ltrs.filter((it) => it.name === tonalres_1.TonalSpellingTags.nasalization) .length == 1) { // nasalization of vowels wrd.replaceSyllable(wrd.syllables.length - 1, morphemes[morphemes.length - 1].uninfect()[0]); return [wrd]; } } return []; } } exports.Uninfection = Uninfection; /** Mutate the initial of the following syllable with the initial of the preceding syllable. */ class ConsonantMutation extends metaplasm_1.TonalMutationMetaplasm { apply(morphemes) { if (morphemes.length > 1 && morphemes[morphemes.length - 2]) { const ltrs = morphemes[morphemes.length - 2].sounds; const wrd = new unit_3.TonalWord(morphemes.map((it) => new unit_1.TonalSyllable(it.syllable.letters))); // duplifix. pass the preceding initial to get forms wrd.replaceSyllable(wrd.syllables.length - 1, morphemes[morphemes.length - 1].mutateInitialConsonant(ltrs[0])[0]); return [wrd]; } return []; } } exports.ConsonantMutation = ConsonantMutation; /** Unmutate the initial of the following syllable with the initial of the preceding syllable. */ class ConsonantUnmutation extends metaplasm_1.TonalUnmutationMetaplasm { apply(morphemes) { if (morphemes.length > 1 && morphemes[morphemes.length - 2]) { const ltrs = morphemes[morphemes.length - 2].sounds; const wrd = new unit_3.TonalWord(morphemes.map((it) => new unit_1.TonalSyllable(it.syllable.letters))); // pass the initial of the following word to get forms wrd.replaceSyllable(wrd.syllables.length - 1, morphemes[morphemes.length - 1].unmutateInitialConsonant(ltrs[0])[0]); return [wrd]; } return []; } } exports.ConsonantUnmutation = ConsonantUnmutation; /** Returns the proceeding forms of a phrasal verb of length 2. */ class ConjugateToProceeding extends metaplasm_2.TonalPhrasalInflectionMetaplasm { apply(verb, particle) { if (verb.word.literal === '' || particle.word.literal === '') return []; if (particle.getForms().length > 0) { const forms = particle.getForms(); const ret = []; forms.map((it) => ret.push(new unit_1.TonalPhrase([verb.getForms()[0], it]))); return ret; } else if (verb.getForms().length > 0) { // equivalent to compound in terms of phrasal verb return [new unit_1.TonalPhrase([verb.getForms()[0], particle.word])]; } else { return [new unit_1.TonalPhrase([])]; } } } exports.ConjugateToProceeding = ConjugateToProceeding; /** Returns the proceeding forms of a phrasal verb of length 3. */ class ConjugateVppToProceeding extends metaplasm_1.TonalPhrasalInflectionVppMetaplasm { apply(verb, particle, particleTwo) { if (verb.word.literal === '' || particle.word.literal === '' || particleTwo.word.literal === '') return []; if (particle.getForms().length > 0 || particleTwo.getForms().length > 0) { return [ new unit_1.TonalPhrase([ verb.getForms()[0], particle.getForms()[0], particleTwo.getForms()[0], ]), ]; } return [new unit_1.TonalPhrase([])]; } } exports.ConjugateVppToProceeding = ConjugateVppToProceeding; /** Returns the transitive forms of a phrasal verb of length 3. */ class ConjugateVppToTransitive extends metaplasm_1.TonalPhrasalInflectionVppMetaplasm { apply(verb, particle, particleTwo) { if (verb.word.literal === '' || particle.word.literal === '' || particleTwo.word.literal === '') return []; if (verb.getForms().length > 0) { return [ new unit_1.TonalPhrase([verb.getForms()[0], particle.word, particleTwo.word]), ]; } return [new unit_1.TonalPhrase([])]; } } exports.ConjugateVppToTransitive = ConjugateVppToTransitive; /** Returns the participle forms of a phrasal verb of length 2. */ class ConjugateToParticiple extends metaplasm_2.TonalPhrasalInflectionMetaplasm { apply(verb, particle) { if (verb.word.literal === '' || particle.word.literal === '') return []; if (particle.getForms().length > 0) { const forms = particle.getForms(); const ret = []; if (verb.getForms().length > 0) { forms.map((it) => ret.push(new unit_1.TonalPhrase([verb.getForms()[0], it]))); } else { forms.map((it) => ret.push(new unit_1.TonalPhrase([verb.word, it]))); } return ret; } return [new unit_1.TonalPhrase([])]; } } exports.ConjugateToParticiple = ConjugateToParticiple; /** Returns the participle forms of a phrasal verb of length 3. */ class ConjugateVppToParticiple extends metaplasm_1.TonalPhrasalInflectionVppMetaplasm { apply(verb, particle, particleTwo) { if (verb.word.literal === '' || particle.word.literal === '' || particleTwo.word.literal === '') return []; if (particle.getForms().length > 0 && particleTwo.getForms().length > 0) { const ret = []; if (verb.getForms().length > 0) { ret.push(new unit_1.TonalPhrase([ verb.getForms()[0], particle.getForms()[0], particleTwo.getForms()[0], ])); } return ret; } return [new unit_1.TonalPhrase([])]; } } exports.ConjugateVppToParticiple = ConjugateVppToParticiple; /** Returns the adnominal forms of a possesive or e-adjective. */ class Adnominal extends metaplasm_2.TonalPhrasalInflectionMetaplasm { apply(noun, particle) { if (noun.word.literal === '' || particle.word.literal === '') return []; if (particle.getForms().length > 0) { return [new unit_1.TonalPhrase([noun.word, particle.getForms()[0]])]; } else { return [new unit_1.TonalPhrase([])]; } } } exports.Adnominal = Adnominal; /** Returns the conjunctive form of le form. */ class Conjunctive extends metaplasm_2.TonalPhrasalInflectionMetaplasm { apply(verb, le) { if (verb.word.literal === '' || le.word.literal === '') return []; if (le.getForms().length > 0) { return [new unit_1.TonalPhrase([verb.getForms()[0], le.getForms()[0]])]; } else if (verb.getForms().length > 0) { return [new unit_1.TonalPhrase([verb.getForms()[0], le.word])]; } else { return [new unit_1.TonalPhrase([])]; } } } exports.Conjunctive = Conjunctive; /** Insert an initial to the enclitic. */ class InsertionToEnclitic extends metaplasm_1.TonalPhrasalInsertionMetaplasm { apply(preceding, following) { const wrds = following.insertWith(preceding); if (wrds.length > 0) return [new unit_1.TonalPhrase([preceding.word, wrds[0]])]; return []; } } exports.InsertionToEnclitic = InsertionToEnclitic; /** Uninsert an initial from the enclitic. */ class UninsertionFromEnclitic extends metaplasm_1.TonalPhrasalUninsertionMetaplasm { apply(preceding, following) { const wrds = following.uninsertWith(preceding); if (wrds.length > 0) return [new unit_1.TonalPhrase([preceding.word, wrds[0]])]; return []; } } exports.UninsertionFromEnclitic = UninsertionFromEnclitic; /** Infect the following word with a nasalization. */ class InfectionExternal extends metaplasm_1.TonalPhrasalInfectionMetaplasm { apply(preceding, following) { const wrds = following.infectWith(preceding); if (wrds.length > 0) return [new unit_1.TonalPhrase([preceding.word, wrds[0]])]; return []; } } exports.InfectionExternal = InfectionExternal; /** Uninfect the following word which is infected by a nasalization. */ class UninfectionExternal extends metaplasm_1.TonalPhrasalUninfectionMetaplasm { apply(preceding, following) { const wrds = following.uninfectWith(preceding); if (wrds.length > 0) return [new unit_1.TonalPhrase([preceding.word, wrds[0]])]; return []; } } exports.UninfectionExternal = UninfectionExternal; /** Consonant mutation of the final of the preceding word. */ class FinalConsonantMutationExternal extends metaplasm_1.TonalPhrasalMutationMetaplasm { apply(preceding, following) { const wrds = preceding.mutateWith(following); if (wrds.length > 0) return [new unit_1.TonalPhrase([wrds[0], following.word])]; return []; } } exports.FinalConsonantMutationExternal = FinalConsonantMutationExternal; /** Consonant unmutation of the final of the preceding word. */ class FinalConsonantUnmutationExternal extends metaplasm_1.TonalPhrasalUnmutationMetaplasm { apply(preceding, following) { const wrds = preceding.unmutateWith(following); if (wrds.length > 0) return [new unit_1.TonalPhrase([wrds[0], following.word])]; return []; } } exports.FinalConsonantUnmutationExternal = FinalConsonantUnmutationExternal; /** Consonant mutation of the final of the preceding syllable. */ class FinalConsonantMutationInternal extends metaplasm_1.TonalMutationMetaplasm { apply(morphemes) { let wrd = new unit_3.TonalWord(morphemes.map((it) => new unit_1.TonalSyllable(it.syllable.letters))); if (morphemes.length > 1) { for (let i = 1; i < morphemes.length; i++) { if (morphemes[i].sounds[0].name === tonalres_1.TonalSpellingTags.initialConsonant && (morphemes[i - 1].lastSecondLetter === tonalres_1.TonalLetterTags.t || morphemes[i - 1].lastSecondLetter === tonalres_1.TonalLetterTags.tt)) { const syls = morphemes[i - 1].changeFinalPtkppttkk(morphemes[i].sounds[0]); if (syls && syls.length > 0) { wrd.replaceSyllable(i - 1, syls[0]); } } else if (morphemes[i].sounds[0].toString() === tonalres_1.TonalLetterTags.b && morphemes[i - 1].lastSecondLetter === tonalres_1.TonalLetterTags.n) { const syls = morphemes[i - 1].changeFinalN(morphemes[i].sounds[0]); if (syls && syls.length > 0) { wrd.replaceSyllable(i - 1, syls[0]); } } else { const syls = morphemes[i - 1].changeFinalPtkppttkk(morphemes[i].sounds[0]); if (syls && syls.length > 0) wrd.replaceSyllable(i - 1, syls[0]); } } } return [wrd]; } } exports.FinalConsonantMutationInternal = FinalConsonantMutationInternal; /** Consonant unmutation of the final of the preceding syllable. */ class FinalConsonantUnmutationInternal extends metaplasm_1.TonalUnmutationMetaplasm { apply(morphemes) { let wrd = new unit_3.TonalWord(morphemes.map((it) => new unit_1.TonalSyllable(it.syllable.letters))); if (morphemes.length > 1) { for (let i = 1; i < morphemes.length; i++) { // combine b, g, h, j, l with m, n, ng const initialsBghjlmnng = collections_1.initialConsonantsBghjl.concat(collections_1.nasalInitialConsonants); const finalsBglbbggll = Array.from(collections_1.voicedVoicelessFinalConsonants.keys()); if (morphemes[i].sounds[0].name === tonalres_1.TonalSpellingTags.initialConsonant && finalsBglbbggll.includes(morphemes[i - 1].lastSecondLetter) && initialsBghjlmnng.includes(morphemes[i].sounds[0].toString())) { const syls = morphemes[i - 1].toVoicelessFinal(); wrd.replaceSyllable(i - 1, syls[0]); } } } return [wrd]; } } exports.FinalConsonantUnmutationInternal = FinalConsonantUnmutationInternal; //# sourceMappingURL=metaplasm.js.map