taipa
Version:
Taiwanese morphological parsing library
75 lines • 2.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TonalLemmatizationLexemeMaker = exports.TonalLemmatizationLexeme = void 0;
const unit_1 = require("../unit");
const tonalres_1 = require("../tonal/tonalres");
const metaplasm_1 = require("./metaplasm");
const maker_1 = require("../maker");
const unit_2 = require("./unit");
/** A word and its lemmas/base forms. */
class TonalLemmatizationLexeme extends unit_1.Lexeme {
word;
lemmata = new Array(); // lexical forms. underlying forms
endingInflectional;
constructor(morphemes, metaplasm) {
super();
if (morphemes.length == 0)
this.word = new unit_2.TonalWord([]);
else
this.word = new unit_2.TonalWord(morphemes.map((x) => x.syllable));
if (morphemes.length > 0) {
if (morphemes[morphemes.length - 1].allomorph) {
this.endingInflectional = this.assignInflectionalEnding(morphemes[morphemes.length - 1].allomorph);
}
else {
// null inflectional ending
this.endingInflectional = new unit_2.InflectionalEnding();
}
}
else {
// no morphemes. null inflectional ending
this.endingInflectional = new unit_2.InflectionalEnding();
}
if (morphemes.length > 0)
this.lemmata = metaplasm.apply(morphemes, this.endingInflectional);
}
getLemmas() {
// this must be called after populateLemmata is called
return this.lemmata;
}
getInflectionalEnding() {
if (this.endingInflectional)
return this.endingInflectional.toString();
return '';
}
assignInflectionalEnding(allomorph) {
let ending = new unit_2.InflectionalEnding();
// change allomorph to affix
if (allomorph instanceof tonalres_1.FreeAllomorph) {
let fie = new unit_2.FreeInflectionalEnding();
fie.affix.tonal = allomorph.tonal;
ending = fie;
}
else if (allomorph instanceof tonalres_1.CheckedAllomorph) {
let cie = new unit_2.CheckedInflectionalEnding();
cie.affix.tonal = allomorph.tonal;
ending = cie;
}
// this word is already in base form, and its last syllable is checked tone
return ending;
}
}
exports.TonalLemmatizationLexeme = TonalLemmatizationLexeme;
class TonalLemmatizationLexemeMaker extends maker_1.LexemeMaker {
constructor() {
super();
}
makeLexemes(morphemes) {
return this.make(morphemes);
}
make(morphemes) {
return new TonalLemmatizationLexeme(morphemes, new metaplasm_1.TonalLemmatization());
}
}
exports.TonalLemmatizationLexemeMaker = TonalLemmatizationLexemeMaker;
//# sourceMappingURL=lexeme.js.map