I’ve added a couple new features to the Perl RiveScript library today that will allow developers to get convenient access to the internal data structures of the RiveScript object.
There’s a new deparse() method, which returns a big ol’ Perl data structure that represents the entire RiveScript brain as loaded into the object. With this it’s easy to loop over the topics and triggers and config variables and etc. that was loaded in from the RiveScript documents.
There’s also a write() method, which will use deparse() and write RiveScript code to disk using all the data it has in memory.
What’s the application for this? Well, you can use it to create a user interface for manipulating your RiveScript documents without needing to touch the RiveScript code. The module could load an RS file, deparse it to give your program really clean and easy access to the data represented by that RS file, make some changes to it, and write the changes back to disk.
I’m slowly working on creating a Pandorabots-like service for RiveScript bots, and this was a necessary step along the way to that. If there’s enough interest in this feature, I may port it over to the Python library at some point as well.
This feature comes with perl-RiveScript 1.24, which should be on CPAN in a few hours, or can be downloaded from http://www.rivescript.com/interpreters#perl (there are RPMs available for Fedora and EL6) or https://github.com/kirsle/rivescript-perl