Could that be implemented in Hailo for Perl (it's two commands away from a base install:)
- Install Cpanminus for Perl, some C compiler and sqlite3 just to be sure.
cpanm -n local::lib
cpanm -n Hailo
~/perl5/bin/hailo -t corpus.txt -b chatbot.brn
~/perl5/bin/hailo -b chatbot.brn
You would probably have to completely rewrite its internals.