UNPKG

eliza-core

Version:

A rendition of ELIZA program engine by Weizenbaum sharable for all javascript environments

39 lines (38 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var exceptions_1 = require("./exceptions"); var Decomp = (function () { function Decomp(pattern, mem, reassembles) { this.pattern = pattern; this.mem = mem; this.reassembles = reassembles; this.currReasmb = 100; } Decomp.prototype.getPattern = function () { return this.pattern; }; Decomp.prototype.isMemoryKey = function () { return this.mem; }; Decomp.prototype.getReasemb = function () { return this.reassembles.filter(function (r) { return !r.isAnnotated(); }); }; Decomp.prototype.getAnnotates = function () { return this.reassembles.filter(function (r) { return r.isAnnotated(); }); }; Decomp.prototype.nextRule = function () { var reassembles = this.reassembles.filter(function (r) { return !r.isAnnotated(); }); if (this.isMemoryKey()) { this.currReasmb = Math.floor(Math.random() * reassembles.length); } if (++this.currReasmb >= reassembles.length) { this.currReasmb = 0; } if (reassembles.length < 1) { throw new exceptions_1.NoReassemblyRuleException(); } return reassembles[this.currReasmb]; }; return Decomp; }()); exports.Decomp = Decomp;