taipa
Version:
Taiwanese morphological parsing library
43 lines • 2.01 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.insertToFollowingWord = exports.insertToFollowingSyllable = void 0;
const unit_1 = require("../unit");
const tonalres_1 = require("../tonal/tonalres");
const morpheme_1 = require("./morpheme");
const lexeme_1 = require("./lexeme");
const metaplasm_1 = require("./metaplasm");
const phraseme_1 = require("./phraseme");
const analyzer_1 = require("./analyzer");
const metaplasm_2 = require("../metaplasm");
function getNoInsertion(word) {
const mrphs = (0, analyzer_1.morphAnalyzeChanging)(word);
const lx = new lexeme_1.TonalInsertionLexeme(mrphs, new metaplasm_2.TonalZeroInsertionMetaplasm());
return lx;
}
/**
* Inserts an initial consonant m, n, or ng to syllable ay if the preceding syllable has a final consonant m, n, or ng.
* @param word A word whose second syllable is ay, a, or af. The word has at least 2 syllables for the second one to be inserted an initial.
*/
function insertToFollowingSyllable(word) {
const tschmm = new morpheme_1.TonalSoundChangingMorphemeMaker();
const gm = new unit_1.GraphemeMaker(tonalres_1.lowerLettersTonal);
const gs = gm.makeGraphemes(word);
const mrphs = tschmm.makeMorphemes(gs);
// TODO: add initial consonant g. b? l?
const lx = new lexeme_1.TonalInsertionLexeme(mrphs, new metaplasm_1.Epenthesis());
return lx;
}
exports.insertToFollowingSyllable = insertToFollowingSyllable;
/**
* Insert an initial consonant to the enclitic.
* @param preceding Thre preceding word.
* @param following The following word. The enclitic.
*/
function insertToFollowingWord(preceding, following) {
const lxPreceding = getNoInsertion(preceding);
const lxFollowing = getNoInsertion(following);
const phmk = new phraseme_1.TonalInsertionPhrasemeMaker();
return phmk.makePhraseme(lxPreceding, lxFollowing, new metaplasm_1.InsertionToEnclitic());
}
exports.insertToFollowingWord = insertToFollowingWord;
//# sourceMappingURL=inserter.js.map