#include <megahal.h> void megahal_setnoprompt(void); void megahal_setnowrap(void); void megahal_setnobanner(void); void megahal_seterrorfile(char *filename); void megahal_setstatusfile(char *filename); void megahal_initialize(void); char *megahal_initial_greeting(void); int megahal_command(char *input); char *megahal_do_reply(char *input, intlog); void megahal_output(char *output); char *megahal_input(char *prompt); void megahal_cleanup(void);
Files
megahal_seterrorfile and megahal_setstatusfile set which
files megahal will use for error and status reporting, respectively.
User interaction
megahal_initial_greeting returns an initial greeting for the
user, such as "hello", "ciao", etc... megahal_command checks
its input for a Megahal command (like QUIT), and acts upon it, if
found. If it finds nothing, it returns 0. megahal_do_reply is
the core of megahal. It takes a string as input, and calculates a
reply, which it returns. meghal_output is for outputting text
to stdout, such as megahal's replies. Input may be obtained with
megahal_input, which takes a prompt string as an argument, and
returns a string input by the user.
Example
main.c in the source distribution is a good example of how to
use Megahal's C API.
load libmh_tcl.so
Load the Tcl interface shared object into the Tcl interpreter.
mh_init
Initialize megahal brain.
mh_doreply text
Takes some text as input and returns a megahal reply.
mh_cleanup
Save megahal brain to disk. You will lose your changes if this does
not occur.
import mh_python
Import the Megahal Python interface into the Python interpreter.
mh_python.initbrain()
Initialize megahal brain.
mh_python.doreply(text)
Takes some text as input and returns a megahal reply.
mh_python.learn(text)
Takes some text as input and updates the model without generating a reply.
mh_python.cleanup()
Save megahal brain to disk. You will lose your changes if this does
not occur.
Jason Hutchens, the original author of Megahal can be found at: http://www.amristar.com.au/~hutch/