UNPKG

taipa

Version:

Taiwanese morphological parsing library

81 lines 3.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Guide = void 0; const configuration_1 = require("./configuration"); const symbols_1 = require("./symbols"); const document_1 = require("../document"); class Guide { transitions = new Array(); s1 = new document_1.Node(''); s2 = new document_1.Node(''); b1 = new document_1.Node(''); s1B1Map = new Map() .set(symbols_1.Tagset.vb + symbols_1.Tagset.ppv, new configuration_1.Shift()) .set(symbols_1.Tagset.npr + symbols_1.Tagset.vb, new configuration_1.Shift()) .set(symbols_1.Tagset.npr + symbols_1.Tagset.npr, new configuration_1.Shift()) .set(symbols_1.Tagset.appr + symbols_1.Tagset.npr, new configuration_1.Shift()) .set(symbols_1.Tagset.vb + symbols_1.Tagset.npr, new configuration_1.Shift()) .set(symbols_1.Tagset.vb + symbols_1.Tagset.psub, new configuration_1.Shift()) .set(symbols_1.Tagset.aux + symbols_1.Tagset.vb, new configuration_1.Shift()) .set(symbols_1.Tagset.padv + symbols_1.Tagset.vb, new configuration_1.Shift()) .set(symbols_1.Tagset.npr + symbols_1.Tagset.padv, new configuration_1.Shift()) .set(symbols_1.Tagset.vb + symbols_1.Tagset.appr, new configuration_1.Shift()) .set(symbols_1.Tagset.vb + symbols_1.Tagset.padv, new configuration_1.Shift()) .set(symbols_1.Tagset.npr + symbols_1.Tagset.aux, new configuration_1.Shift()) .set(symbols_1.Tagset.ppv + symbols_1.Tagset.psub, new configuration_1.RightArc()) .set(symbols_1.Tagset.ppv + symbols_1.Tagset.npr, new configuration_1.RightArc()); s2S1Map = new Map() .set(symbols_1.Tagset.vb + symbols_1.Tagset.ppv, new configuration_1.RightArc()) .set(symbols_1.Tagset.vb + symbols_1.Tagset.psub, new configuration_1.RightArc()) .set(symbols_1.Tagset.aux + symbols_1.Tagset.vb, new configuration_1.LeftArc()) .set(symbols_1.Tagset.padv + symbols_1.Tagset.vb, new configuration_1.LeftArc()) .set(symbols_1.Tagset.appr + symbols_1.Tagset.npr, new configuration_1.LeftArc()) .set(symbols_1.Tagset.vb + symbols_1.Tagset.vb, new configuration_1.RightArc()) .set(symbols_1.Tagset.vb + symbols_1.Tagset.npr, new configuration_1.RightArc()) .set(symbols_1.Tagset.npr + symbols_1.Tagset.vb, new configuration_1.LeftArc()); isQueueEmpty(c) { if (c.queue.length === 0) return true; return false; } isTwoNodesInStack(c) { if (c.stack.length === 2) return true; return false; } getNextTransition(c) { this.s1 = new document_1.Node(''); if (c.stack.length > 0) this.s1 = c.stack[c.stack.length - 1]; this.s2 = new document_1.Node(''); if (c.stack.length > 1) this.s2 = c.stack[c.stack.length - 2]; this.b1 = new document_1.Node(''); if (c.queue.length > 0) this.b1 = c.queue[0]; if (this.s1.tag != '' && this.b1.tag != '') { if (this.s1B1Map.has(this.s1.tag + this.b1.tag)) { const tran = this.s1B1Map.get(this.s1.tag + this.b1.tag); if (tran) { this.transitions.push(tran); } } } else if (this.isQueueEmpty(c)) { if (this.s2S1Map.has(this.s2.tag + this.s1.tag)) { const tran = this.s2S1Map.get(this.s2.tag + this.s1.tag); if (tran) { this.transitions.push(tran); } } else if (this.isTwoNodesInStack(c)) { this.transitions.push(new configuration_1.RightArc()); } } if (this.transitions.length == 0) return undefined; return this.transitions.shift(); } } exports.Guide = Guide; //# sourceMappingURL=guide.js.map