UNPKG

taipa

Version:

Taiwanese morphological parsing library

65 lines 2.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Client = exports.TokenAnalysis = void 0; const init_1 = require("./tonal/init"); const analyzer_1 = require("./unchange/analyzer"); const init_2 = require("./kana/init"); const analyzer_2 = require("./kana/analyzer"); const unit_1 = require("./unit"); const metaplasm_1 = require("./unchange/metaplasm"); class TokenAnalysis { /** Analyzed token. */ word = new unit_1.Word(); /** Base forms of the word. */ lemmas = new Array(); /** Inflectional suffix. */ inflectionalEnding = ''; /** sound sequences. */ soundSequences = new Array(); /** * Syllabic block or syllabogram sequences with tone letters. * Multiple sequences could be pushed into this array of strings. */ blockSequences = []; /** Standalone form sequences. */ standaloneSequences = new Array(); // standalone form sequences } exports.TokenAnalysis = TokenAnalysis; class Client { processKana(str) { (0, init_2.checkNumberOfLettersKana)(); // kana let ta = new TokenAnalysis(); if (str) { const ka = analyzer_2.kanaLemmatizationAnalyzer; const morphemes = ka.morphAnalyze(str); ta.blockSequences = (0, init_2.getKanaBlocks)(morphemes); for (const m of morphemes) { ta.soundSequences.push(m.sounds); } } return ta; } processTonal(str) { (0, init_1.checkNumberOfLetterTonal)(); // tonal lurzmafjiz let ta = new TokenAnalysis(); if (str) { const tla = analyzer_1.tonalLemmatizationAnalyzer; const morphemes = tla.morphAnalyze(str, new metaplasm_1.TonalStandaloneForms([])); const lexeme = tla.lexAnalyze(morphemes); ta.word = lexeme.word; ta.lemmas = lexeme.getLemmas(); ta.inflectionalEnding = lexeme.getInflectionalEnding(); ta.blockSequences = (0, init_1.getBlocks)(morphemes); for (const m of morphemes) { ta.soundSequences.push(m.sounds); // TODO: first free tone to fourth. first checked tone to eighth ta.standaloneSequences.push(m.getForms().map((it) => it.literal)); } } return ta; } } exports.Client = Client; //# sourceMappingURL=client.js.map