rivescript

Parsing regex with alternatives and optionals

╄→尐↘猪︶ㄣ 提交于 2019-12-24 03:37:08
问题 I'm building a chatbot subset of RiveScript and trying to build the pattern matching parser with regular expression. Which three regexes match the following three examples? ex1: I am * years old valid match: - "I am 24 years old" invalid match: - "I am years old" ex2: what color is [my|your|his|her] (bright red|blue|green|lemon chiffon) * valid matches: - "what color is lemon chiffon car" - "what color is my some random text till the end of string" ex3: [*] told me to say * valid matches: -

How to convert Ajax to Fetch API in JavaScript?

折月煮酒 提交于 2019-12-10 15:49:10
问题 So I am using the JavaScript port of RiveScript which uses ajax and of course I don't want to use jQuery anymore. There is only one line ajax and I want to change it to the new Fetch API. **FYI: You can see the ajax code in line 1795 of the CDN.** So here's the original code: return $.ajax({ url: file, dataType: "text", success: (function(_this) { return function(data, textStatus, xhr) { _this.say("Loading file " + file + " complete."); _this.parse(file, data, onError); delete _this._pending