AI-MegaHAL
view release on metacpan or search on metacpan
Revision history for the Perl MegaHAL extension.
0.08 = 0.07_01 2015-04-12
0.07_01 Apr 14 2012
- mention Hailo.pm in docs
- use 'unsigned int' as 32 bit data type
- mingw64 supported
0.07 = 0.06_01 Jul 12 2008
0.06_01 Jan 24 2008
- corrected documentation (typo found by ZOFFIX)
- void megahal_learn by Craig Andrews
- Mac Darwin compatibility
0.06 = 0.05_01 Nov 26 2007
0.05_01 Mar 11 2007
To read about the latest features, see the Changes file.
The author invites feedback on AI::MegaHAL. If you find a bug, please send the
information described in the BUGS section below.
2) INSTALLATION
---------------
To install this module type the following:
perl Makefile.PL
make
make test
make install
3) DEPENDENCIES
---------------
4) BUGS
-------
If you find a bug, please report it to the author along with the
following information:
* version of Perl (output of 'perl -V' is best)
* version of AI::MegaHAL
* operating system type and version
* exact text of error message or description of problem
* example model files/data being classified
If we don't have access to a system similar to yours, you may be asked
to insert some debugging lines and report back on the results. The more help
and information you can provide, the better.
5) AUTHOR INFORMATION
---------------------
libmegahal.c view on Meta::CPAN
#endif
#if !defined(AMIGA) && !defined(__mac_os) && !defined(__FreeBSD__) && !defined(__APPLE__)
// FreeBSD malloc.h is empty and gives error
// Tested on FreeBSD 5.4
#include <malloc.h>
#endif
#include <string.h>
#include <signal.h>
#include <math.h>
#include <time.h>
#include <ctype.h>
#if defined(__mac_os)
#include <types.h>
#include <Speech.h>
#else
#include <sys/types.h>
#endif
#include "megahal.h"
#if defined(DEBUG)
#include "debug.h"
#endif
#define P_THINK 40
#define D_KEY 100000
#define V_KEY 50000
#define D_THINK 500000
libmegahal.c view on Meta::CPAN
#define isalnum(x) IsAlNum(_AmigaLocale,x)
#undef isdigit
#define isdigit(x) IsDigit(_AmigaLocale,x)
#undef isspace
#define isspace(x) IsSpace(_AmigaLocale,x)
#endif
#ifndef __mac_os
#undef FALSE
#undef TRUE
typedef enum { FALSE, TRUE } bool;
#endif
typedef struct {
BYTE1 length;
char *word;
} STRING;
typedef struct {
BYTE4 size;
STRING *entry;
BYTE2 *index;
} DICTIONARY;
typedef struct {
BYTE2 size;
STRING *from;
STRING *to;
} SWAP;
typedef struct NODE {
BYTE2 symbol;
BYTE4 usage;
BYTE2 count;
BYTE2 branch;
struct NODE **tree;
} TREE;
typedef struct {
BYTE1 order;
TREE *forward;
TREE *backward;
TREE **context;
DICTIONARY *dictionary;
} MODEL;
typedef enum { UNKNOWN, QUIT, EXIT, SAVE, DELAY, HELP, SPEECH, VOICELIST, VOICE, BRAIN, QUIET} COMMAND_WORDS;
typedef struct {
STRING word;
char *helpstring;
COMMAND_WORDS command;
} COMMAND;
/*===========================================================================*/
static int width=75;
static int order=5;
libmegahal.c view on Meta::CPAN
static void save_dictionary(FILE *, DICTIONARY *);
static void save_tree(FILE *, TREE *);
static void save_word(FILE *, STRING);
static int search_dictionary(DICTIONARY *, STRING, bool *);
static int search_node(TREE *, int, bool *);
static int seed(MODEL *, DICTIONARY *);
static void show_dictionary(DICTIONARY *);
static void speak(char *);
static bool status(char *, ...);
static void train(MODEL *, char *);
static void typein(char);
static void update_context(MODEL *, int);
static void update_model(MODEL *, int);
static bool warn(char *, char *, ...);
static int wordcmp(STRING, STRING);
static bool word_exists(DICTIONARY *, STRING);
static int rnd(int);
/* Function: setnoprompt
libmegahal.c view on Meta::CPAN
#endif
}
/*---------------------------------------------------------------------------*/
/*
* Function: Execute_Command
*
* Purpose: Detect whether the user has typed a command, and
* execute the corresponding function.
*/
COMMAND_WORDS execute_command(DICTIONARY *words, int *position)
{
unsigned int i;
unsigned int j;
/*
* If there is only one word, then it can't be a command.
*/
libmegahal.c view on Meta::CPAN
* If the string is empty then do nothing, for it contains no words.
*/
if(strlen(input)==0) return;
/*
* Loop forever.
*/
while(1) {
/*
* If the current character is of the same type as the previous
* character, then include it in the word. Otherwise, terminate
* the current word.
*/
if(boundary(input, offset)) {
/*
* Add the word to the dictionary
*/
if(words->entry==NULL)
words->entry=(STRING *)malloc((words->size+1)*sizeof(STRING));
else
libmegahal.c view on Meta::CPAN
fclose(file);
return(list);
}
/*---------------------------------------------------------------------------*/
/*
* Function: Delay
*
* Purpose: Display the string to stdout as if it was typed by a human.
*/
void delay(char *string)
{
register int i;
/*
* Don't simulate typing if the feature is turned off
*/
if(typing_delay==FALSE) {
fprintf(stdout, string);
return;
}
/*
* Display the entire string, one character at a time
*/
for(i=0; i<(int)strlen(string)-1; ++i) typein(string[i]);
usleep((D_THINK+rnd(V_THINK)-rnd(V_THINK))/2);
typein(string[i]);
}
/*---------------------------------------------------------------------------*/
/*
* Function: Typein
*
* Purpose: Display a character to stdout as if it was typed by a human.
*/
void typein(char c)
{
/*
* Standard keyboard delay
*/
usleep(D_KEY+rnd(V_KEY)-rnd(V_KEY));
fprintf(stdout, "%c", c);
fflush(stdout);
/*
* A random thinking delay
megahal.trn view on Meta::CPAN
#
I am a human being. That should be obvious from my ability to learn.
I can learn about whatever you care to teach me.
I am a human being. Really, is there any doubt?
At least you and I have one thing in common. We're both human.
I am certainly not a computer program, and I find the mere suggestion insulting!
How dare you accuse me of repeating myself! How dare you accuse me of repeating myself!
There is an echo in here! There is an echo in here!
I never make mistakes! Syntax error in line 10. Redo from start.
I like to think that I am at least of average intelligence.
I like to type at my own pace, thank-you very much!
#
# Popular Quotations
#
A bird in the hand is worth two in the bush.
You can lead a horse to water, but you can't make it drink.
A rolling stone gathers no moss.
Time flies like an arrow. Fruit flies like a banana.
Colourless green ideas sleep furiously.
I think, therefore I am.
The best way to remember your wife's birthday is to forget it once.
megahal.trn view on Meta::CPAN
The meaning of life, the universe, and everything is 42.
#
# Non-Sequiturs
#
I have absolutely no idea about that. I really wish I had, though!
You know, I don't know what the hell you're babbling on about.
I've known amoeba which have made more sense than you, my friend.
Let me tell you a secret. I have absolutely no idea what you're blathering on about!
Look, I'll be honest with you. I actually do not know where you're coming from...
Forget about that. Please. Let's talk about something a little more interesting.
I wish I knew why you typed that. Actually, on second thoughts...
If I told you the truth, I'd have to kill you. And nobody wants that!
I know an amusing story about that, but it's a bit too rude to recount!
My mother once asked me the same thing, actually. She regretted it, too.
None of your freaking business!
Awww, geee, it's on the tip of my tongue...
Damn! How embarrassing. I've totally forgotten what I was going to say!
I personally believe that it would be unethical to talk about that.
I'd like to tell you, but I can't. It's an ethical thing.
You seemed to be obsessed with that!
Why must you know? It's not as if it's important or anything!
( run in 1.523 second using v1.01-cache-2.11-cpan-df04353d9ac )