node-nlp
Version:
Library for NLU (Natural Language Understanding) done in Node.js
49 lines (48 loc) • 1.97 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var Prompt_1 = require("./Prompt");
var PromptRecognizers_1 = require("./PromptRecognizers");
var consts = require("../consts");
var PromptTime = (function (_super) {
__extends(PromptTime, _super);
function PromptTime(features) {
var _this = _super.call(this, {
defaultRetryPrompt: 'default_time',
defaultRetryNamespace: consts.Library.system
}) || this;
_this.updateFeatures(features);
_this.onRecognize(function (context, cb) {
if (context.message.text && !_this.features.disableRecognizer) {
var options = context.dialogData.options;
var entities = PromptRecognizers_1.PromptRecognizers.recognizeTimes(context, options);
var top_1 = PromptRecognizers_1.PromptRecognizers.findTopEntity(entities);
if (top_1) {
cb(null, top_1.score, top_1);
}
else {
cb(null, 0.0);
}
}
else {
cb(null, 0.0);
}
});
_this.matches(consts.Intents.Repeat, function (session) {
session.dialogData.turns = 0;
_this.sendPrompt(session);
});
return _this;
}
return PromptTime;
}(Prompt_1.Prompt));
exports.PromptTime = PromptTime;
;