1 line
2.4 KiB
JavaScript
1 line
2.4 KiB
JavaScript
|
|
"use strict";var t=function(t){return t&&t.__esModule?t["default"]:t},e=function(){function t(t,e){for(var r in e){var n=e[r];n.configurable=!0,n.value&&(n.writable=!0)}Object.defineProperties(t,e)}return function(e,r,n){return r&&t(e.prototype,r),n&&t(e,n),e}}(),r=function s(t,e,r){var n=Object.getOwnPropertyDescriptor(t,e);if(void 0===n){var i=Object.getPrototypeOf(t);return null===i?void 0:s(i,e,r)}if("value"in n&&n.writable)return n.value;var a=n.get;if(void 0!==a)return a.call(r)},n=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(t.__proto__=e)},i=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},a=t(require("./recognizer")),l=t(require("../nli-service")),u={INVALID:0,COMPILING:1,COMPILE_FAILED:2,COMPILE_SUCCEEDED:3},o=function(t){function a(t,e){i(this,a),e=e?e:{},e.path="nuance_curlmulti",r(Object.getPrototypeOf(a.prototype),"constructor",this).call(this,e),this.rule=t,this.handle=null,this.status=u.INVALID,this.callbacks=[],this.type="cloud",this.rule&&this.compile(function(){})}return n(a,t),e(a,{callCallbacks:{value:function(t){this.callbacks.forEach(function(e){e(t)}),this.callbacks.length=0}},compile:{value:function(t){var e=this;this.callbacks.push(t),this.status===u.INVALID?(this.status=u.COMPILING,l.compile(this.rule,function(t,r){t?(e.status=u.COMPILE_FAILED,console.warn(t),e.callCallbacks("error")):(e.status=u.COMPILE_SUCCEEDED,e.handle=r,e.callCallbacks())})):this.status===u.COMPILE_FAILED?this.callCallbacks("error"):this.status===u.COMPILE_SUCCEEDED&&this.callCallbacks()}},onResult:{value:function(t){var e=this,r=require("../main").asr;r.pause();var n=t.utterances[0].utterance;this.rule?this.compile(function(t){var i=t?l.parseFromRule.bind(l):l.parseFromURI.bind(l),a=t?e.rule:e.handle;i(a,n,function(t,n){t?e.emit("error",t):e.emit("result",n),r.resume()})}):(this.emit("result",{Input:n}),r.resume())}},onIncremental:{value:function(t){var e=this,r=t.utterances[0].utterance;this.rule?this.compile(function(t){var n=t?l.parseFromRule.bind(l):l.parseFromURI.bind(l),i=t?e.rule:e.handle;n(i,r,function(t,r){t?e.emit("error",t):e.emit("incremental",r)})}):this.emit("inremental",{Input:r})}}}),a}(a);module.exports=o;
|