UNPKG

taipa

Version:

Taiwanese morphological parsing library

222 lines 9.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.inflectSerial = exports.inflectVppToParticiple = exports.inflectToParticiple = exports.inflectPossesive = exports.inflectLeToConjunctive = exports.inflectEToAdnominal = exports.inflectVppToTransitive = exports.inflectVppToProceeding = exports.inflectToProceeding = exports.inflectEighthToSecond = exports.inflectTo = exports.inflectPossesiveEx = exports.inflectEncliticLe = exports.inflectPhrasalVerbParticle = exports.inflectEncliticE = exports.inflectTransfix = exports.inflectDesinence = void 0; const analyzer_1 = require("./analyzer"); const metaplasm_1 = require("./metaplasm"); const phraseme_1 = require("./phraseme"); const creator_1 = require("./creator"); const tonalres_1 = require("../tonal/tonalres"); const metaplasm_2 = require("./metaplasm"); const dictionary_1 = require("../dparser/dictionary"); /** Inflects the inflectional suffix of a word. Lexical inflector. */ function inflectDesinence(word) { const tia = analyzer_1.tonalInflectionAnalyzer; const ms = tia.morphAnalyze(word, new metaplasm_1.TonalCombiningForms()); const lx = tia.lexAnalyze(ms, new metaplasm_2.TonalDesinenceInflection()); return lx; } exports.inflectDesinence = inflectDesinence; /** Inflects the transfix of a word. All tonals other than 3rd tone will be changed to 3rd tone. Lexical inflector. */ function inflectTransfix(word) { const tia = analyzer_1.tonalInflectionAnalyzer; const ms = tia.morphAnalyze(word, new metaplasm_1.ThirdCombiningForm()); const lx = tia.lexAnalyze(ms, new metaplasm_2.TransfixInflection()); return lx; } exports.inflectTransfix = inflectTransfix; /** * Inflects e to ez. Lexical inflector. * @param word E, ew, or ez */ function inflectEncliticE(word) { const tia = analyzer_1.tonalInflectionAnalyzer; const ms = tia.morphAnalyze(word, new metaplasm_1.AdnominalECombining()); const lx = tia.lexAnalyze(ms, new metaplasm_2.TonalDesinenceInflection()); return lx; } exports.inflectEncliticE = inflectEncliticE; /** * Inflects 4th tone to 1st tone or 3rd tone accordingly. Inflects laih to laiz. Lexical inflector. * @param word Particle * @param tone F, w, or z */ function inflectPhrasalVerbParticle(word, tone) { const tia = analyzer_1.tonalInflectionAnalyzer; const ms = tia.morphAnalyze(word, new metaplasm_1.PhrasalVerbParticleCombining(tone)); const lx = tia.lexAnalyze(ms, new metaplasm_2.TonalDesinenceInflection()); return lx; } exports.inflectPhrasalVerbParticle = inflectPhrasalVerbParticle; /** * Inflects lez and lew to le. Lexical inflector. * @param word Lew, lez, or le */ function inflectEncliticLe(word) { const tia = analyzer_1.tonalInflectionAnalyzer; const ms = tia.morphAnalyze(word, new metaplasm_1.ConjunctiveLeCombining()); const lx = tia.lexAnalyze(ms, new metaplasm_2.TonalDesinenceInflection()); return lx; } exports.inflectEncliticLe = inflectEncliticLe; /** * Inflects ex to ew. Lexical inflector. * @param word Ex */ function inflectPossesiveEx(word) { const tia = analyzer_1.tonalInflectionAnalyzer; const ms = tia.morphAnalyze(word, new metaplasm_1.PossesiveExCombining()); const lx = tia.lexAnalyze(ms, new metaplasm_2.TonalDesinenceInflection()); return lx; } exports.inflectPossesiveEx = inflectPossesiveEx; /** * Inflects 4th tone to either 1st free tone or 7th free tone. Lexical inflector. * @param word 4th checked tone * @param tone F or z */ function inflectTo(word, tone) { const tia = analyzer_1.tonalInflectionAnalyzer; const ms = tia.morphAnalyze(word, new metaplasm_1.FirstSeventhCombining(tone)); const lx = tia.lexAnalyze(ms, new metaplasm_2.TonalDesinenceInflection()); return lx; } exports.inflectTo = inflectTo; /** * Inflects 8th tone to 2nd tone. Addon inflector. * @param word 8th neutral tone */ function inflectEighthToSecond(word) { const tia = analyzer_1.tonalInflectionAnalyzer; const ms = tia.morphAnalyze(word, new metaplasm_1.EighthToSecondCombining()); const lx = tia.lexAnalyze(ms, new metaplasm_2.TonalDesinenceInflection()); return lx; } exports.inflectEighthToSecond = inflectEighthToSecond; /** * Inflects a phrasal verb of length 2 to proceeding form. Phrasal inflector. * @param verb Main word * @param particle Particle */ function inflectToProceeding(verb, particle) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lxVerb = inflectDesinence(verb); let lxParticle = (0, creator_1.createTonalInflectionLexeme)(''); if (particle === dictionary_1.ParticlesPhrasalVerb.khih) { lxParticle = inflectPhrasalVerbParticle(particle, tonalres_1.TonalLetterTags.f); } else { lxParticle = inflectPhrasalVerbParticle(particle, tonalres_1.TonalLetterTags.w); } return phm.makePhrasalVerbPhraseme(lxVerb, lxParticle); } exports.inflectToProceeding = inflectToProceeding; /** * Inflects a phrasal verb of length 3 to proceeding form. Phrasal inflector. * @param verb Main word * @param particle Particle one * @param particleTwo Particle two */ function inflectVppToProceeding(verb, particle, particleTwo) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lxVerb = inflectDesinence(verb); let lxParticle = (0, creator_1.createTonalInflectionLexeme)(''); let lxParticleTwo = (0, creator_1.createTonalInflectionLexeme)(''); if (particle === dictionary_1.ParticlesPhrasalVerb.cut && particleTwo === dictionary_1.ParticlesPhrasalVerb.khih) { lxParticle = inflectPhrasalVerbParticle(particle, tonalres_1.TonalLetterTags.f); lxParticleTwo = inflectPhrasalVerbParticle(particleTwo, tonalres_1.TonalLetterTags.f); } else if (particle === dictionary_1.ParticlesPhrasalVerb.khih && particleTwo === dictionary_1.ParticlesPhrasalVerb.laih) { lxParticle = inflectPhrasalVerbParticle(particle, tonalres_1.TonalLetterTags.f); lxParticleTwo = inflectPhrasalVerbParticle(particleTwo, tonalres_1.TonalLetterTags.z); } return phm.makePhrasalVerbVppPhraseme(lxVerb, lxParticle, lxParticleTwo); } exports.inflectVppToProceeding = inflectVppToProceeding; /** * Inflects a phrasal verb of length 3 to transitive form. Phrasal inflector. * @param verb Main word * @param particle Particle one * @param particleTwo Particle two */ function inflectVppToTransitive(verb, particle, particleTwo) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lxVerb = inflectDesinence(verb); const lxParticle = inflectDesinence(particle); const lxParticleTwo = inflectDesinence(particleTwo); return phm.makeTransitiveVppPhraseme(lxVerb, lxParticle, lxParticleTwo); } exports.inflectVppToTransitive = inflectVppToTransitive; /** * Inflects e form to adnominal form. Phrasal inflector. * @param adjectivalNoun Main word * @param e E, ew, or ez */ function inflectEToAdnominal(adjectivalNoun, e) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lxAdjective = (0, creator_1.createTonalInflectionLexeme)(adjectivalNoun); const lxE = inflectEncliticE(e); return phm.makeAdjectivePhraseme(lxAdjective, lxE); } exports.inflectEToAdnominal = inflectEToAdnominal; /** * Inflects le form to conjunctive form. Phrasal inflector. * @param verb Main word * @param le Le, lew, or lez */ function inflectLeToConjunctive(verb, le) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lxVerb = inflectDesinence(verb); const lxLe = inflectEncliticLe(le); return phm.makeConjunctivePhraseme(lxVerb, lxLe); } exports.inflectLeToConjunctive = inflectLeToConjunctive; /** * Inflects possesive case from teriminal form to adnominal form. Phrasal inflector. * @param noun Main word * @param ex Ex */ function inflectPossesive(noun, ex) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lxNoun = (0, creator_1.createTonalInflectionLexeme)(noun); const lxEx = inflectPossesiveEx(ex); return phm.makePossesivePhraseme(lxNoun, lxEx); } exports.inflectPossesive = inflectPossesive; /** * Inflects a phrasal verb of length 2 to participle form. Phrasal inflector. * @param verb Main word * @param particle Particle * @param tone 1st tone or 7th tone * */ function inflectToParticiple(verb, particle, tone) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lxVerb = inflectTo(verb, tone); const lxParticle = inflectTo(particle, tone); return phm.makeParticiplePhraseme(lxVerb, lxParticle); } exports.inflectToParticiple = inflectToParticiple; /** * Inflects a phrasal verb of length 3 to participle form. Phrasal inflector. * @param verb Main word * @param particle Particle one * @param particleTwo Particle two * @param tone 1st tone or 7th tone */ function inflectVppToParticiple(verb, particle, particleTwo, tone) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lxVerb = inflectTo(verb, tone); const lxParticle = inflectTo(particle, tone); const lxParticleTwo = inflectTo(particleTwo, tone); return phm.makeVppParticiplePhraseme(lxVerb, lxParticle, lxParticleTwo); } exports.inflectVppToParticiple = inflectVppToParticiple; /** Inflects a series of words. The forms of the last word indicates the whole phrase is in proceeding form or not. Phrasal inflector. */ function inflectSerial(...words) { const phm = new phraseme_1.TonalInflectionPhrasemeMaker(); const lexemes = words.map((it) => inflectDesinence(it)); return phm.makeSerialPhraseme(lexemes); } exports.inflectSerial = inflectSerial; //# sourceMappingURL=inflector.js.map