AI Zone Admin Forum Add your forum

NEWS: survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

RiveScript learnf tag

Hello everybody!

I want to ask if Rivescript has an learnf tag as in AIML2.0. I want to devellop a learning bot in RiveScript if possible.



  [ # 1 ]

It doesn’t have a learnf tag.

Some of the implementations have functions like deparse() and write(); deparse() will return the RiveScript data structure from the bot’s memory as a JSON serializable structure, and write() will turn a structure of the same format into a RiveScript file on disk.

So for example to add a new reply in program code:

var rs = new RiveScript();
data {
"random"// array of triggers under the 'random' topic
"trigger""my name is *",
"<set name=<formal>>Nice to meet you, <get name>.",
"<set name=<formal>><get name>, nice to meet you."
// etc., for each new trigger to add

// Write the new data to a new file.

It’s an ugly data structure to write by hand, but it’s neatly structured enough to make it easy to programmatically manipulate it. Another example of how you could do this in an object macro for the JS version:

when i say you say *
- <
call>learn <star1>#=#<star2></call>

object learn javascript
var input args.join(" ").split("#=#");
trigger input[0];
reply input[1];

// make sure the trigger passes syntax checks
var syntax rs.parser.checkSyntax("+"trigger);
    if (
syntax.length 0{
return "The input has a syntax error: " syntax;

// make a new RiveScript instance that only contains the learned.rive file
var rs = new RiveScript();
rs.loadFile("learned.rive", function() {
// loading completed, deparse the learned.rive data.
var dep rs.deparse();

// add the new trigger/response


"I'll learn that.";

Note: in the JS version, the write() function only works in a node environment (where it has access to write to the filesystem); on a web environment stringify() will return the text contents of the new RiveScript file, and you could pass that to the back-end over ajax or something.

Only the JS and Perl versions have these functions so far.


  [ # 2 ]

thank so much, it’s help a lot! wink


  login or register to react