UNPKG

taipa

Version:

Taiwanese morphological parsing library

63 lines 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.tonalLemmatizationAnalyzer = exports.graphAnalyzeTonal = exports.morphAnalyzeUnchanging = void 0; const lexeme_1 = require("./lexeme"); const unit_1 = require("../unit"); const tonalres_1 = require("../tonal/tonalres"); const morpheme_1 = require("./morpheme"); const morpheme_2 = require("../unchange/morpheme"); const metaplasm_1 = require("./metaplasm"); /** * Analyzes a string into morphemes. Morphological analysis. * @param str A word. */ function morphAnalyzeUnchanging(str) { const gs = graphAnalyzeTonal(str); const mm = new morpheme_2.TonalSoundUnchangingMorphemeMaker(); const ms = mm.makeMorphemes(gs); return ms; } exports.morphAnalyzeUnchanging = morphAnalyzeUnchanging; /** * Analyzes a string into graphemes. Graphemic analysis. * @param str A string */ function graphAnalyzeTonal(str) { const gm = new unit_1.GraphemeMaker(tonalres_1.lowerLettersTonal); return gm.makeGraphemes(str); } exports.graphAnalyzeTonal = graphAnalyzeTonal; /** Analyzes a string into morphemes or lexeme. */ exports.tonalLemmatizationAnalyzer = { /** * Analyzes a string or graphemes into morphemes. Morphological analysis. * @param x A string or graphemes */ morphAnalyze(x, metaplasm) { let gs = []; if (typeof x == 'object') { gs = x; } else if (typeof x == 'string') { gs = graphAnalyzeTonal(x); } const mm = new morpheme_1.TonalStandaloneMorphemeMaker(metaplasm); return mm.makeMorphemes(gs); }, /** * Analyzes a string or morphemes into a lexeme. Lexical analysis. * @param x A string or standalone morphemes */ lexAnalyze(x) { let ms = []; if (typeof x == 'object') { ms = x; } else if (typeof x == 'string') { ms = this.morphAnalyze(x, new metaplasm_1.TonalStandaloneForms([])); } const lm = new lexeme_1.TonalLemmatizationLexemeMaker(); return lm.makeLexemes(ms); }, }; //# sourceMappingURL=analyzer.js.map