megahal_interfaces(3)

megahal_interfaces3

C, python and tcl interfaces to megahal

Usage

#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);

Overview

Initialization
Megahal is initialized with the megahal_initialize() function. megahal_setnoprompt eliminates the prompt from interactive sessions. megahal_setnowrap() stops output from being wrapped. megahal_setnobanner() prevents megahal from printing out the initial 'banner'.

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.

TCL interface

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.

Python interface

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.

References

More information can be found about megahal at http://megahal.sourceforge.net

Jason Hutchens, the original author of Megahal can be found at: http://www.amristar.com.au/~hutch/

Releases

5 releases since Debian 3.0 (Woody); the text changed 1 time.

  1. 3.0
  2. 3.1–6.0

Bugs

The C library is not yet ready.

Author

Man page written by David N. Welton <[email protected]>, modified by Laurent Fousse <[email protected]>.

From megahal 9.1.1a-9 in Debian 6.0 (Squeeze). Parsed by carta from the page's man source.