Followup-For: Bug #169805
Package: megahal
Version: 9.0.3-6
Tags: patch

Hi,

I've added a "training mode" patch, so you can quickly learn from a
file with "megahal -t < my_file". This probably closes #117336 as
well.


-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux kolvir 2.4.20-netfilter #19 Wed Feb 19 23:53:18 CET 2003 i686
Locale: LANG=C, [EMAIL PROTECTED]

Versions of packages megahal depends on:
ii  libc6                         2.3.1-11   GNU C Library: Shared libraries an
diff -u -r megahal-9.0.3/docs/megahal.1 patched-megahal/docs/megahal.1
--- megahal-9.0.3/docs/megahal.1        2003-04-29 18:56:37.000000000 +0000
+++ patched-megahal/docs/megahal.1      2003-04-29 19:31:34.000000000 +0000
@@ -27,6 +27,15 @@
 Supress the startup banner. This is a debian-specific
 modification, and is useful mainly if you want to interface megahal to
 another program.
+.IP "-t"
+Training mode. Don't waste time trying to formulate a reply to what
+the user types in, only learn from it. Useful for quick learning with
+something like:
+
+.B megahal -t < my_file
+
+(don't forget the trailing #quit command!)
+
 .SH "SEE ALSO"
 /usr/share/doc/megahal/README.TXT.gz
 .SH AUTHOR
diff -u -r megahal-9.0.3/main.c patched-megahal/main.c
--- megahal-9.0.3/main.c        2003-04-29 18:56:37.000000000 +0000
+++ patched-megahal/main.c      2003-04-29 19:06:44.000000000 +0000
@@ -68,7 +68,7 @@
     int c, fd, option_index = 0;
 
     while(1) {
-       if((c = getopt_long(argc, argv, "hpwb", long_options,
+       if((c = getopt_long(argc, argv, "hpwbt", long_options,
                            &option_index)) == -1)
            break;
        switch(c) {
@@ -81,6 +81,9 @@
        case 'b':
            megahal_setnobanner();
            break;
+       case 't':
+           megahal_settrainingmode();
+           break;
        case 'h':
            usage();
            return 0;
diff -u -r megahal-9.0.3/megahal.c patched-megahal/megahal.c
--- megahal-9.0.3/megahal.c     2003-04-29 18:56:37.000000000 +0000
+++ patched-megahal/megahal.c   2003-04-29 19:09:19.000000000 +0000
@@ -224,6 +224,7 @@
 static bool quiet=FALSE;
 static bool nowrap=FALSE;
 static bool nobanner=FALSE;
+static bool trainingmode=FALSE;
 
 static char *errorfilename = "megahal.log";
 static char *statusfilename = "megahal.txt";
@@ -381,6 +382,13 @@
     nobanner = TRUE;
 }
 
+void megahal_settrainingmode (void)
+{
+    trainingmode = TRUE;
+    megahal_setnobanner();
+    megahal_setnoprompt();
+}
+
 void megahal_seterrorfile(char *filename)
 {
     errorfilename = filename;
@@ -455,7 +463,10 @@
     make_words(input, words);
 
     learn(model, words);
-    output = generate_reply(model, words);
+    if (trainingmode == FALSE)
+      output = generate_reply(model, words);
+    else
+      output = "\n";
     capitalize(output);
     return output;
 }
diff -u -r megahal-9.0.3/megahal.h patched-megahal/megahal.h
--- megahal-9.0.3/megahal.h     2003-04-29 18:56:37.000000000 +0000
+++ patched-megahal/megahal.h   2003-04-29 18:59:09.000000000 +0000
@@ -100,6 +100,7 @@
 void megahal_setnoprompt ();
 void megahal_setnowrap ();
 void megahal_setnobanner ();
+void megahal_settrainingmode ();
 
 void megahal_seterrorfile(char *filename);
 void megahal_setstatusfile(char *filename);

Attachment: pgpq7URk8NDFb.pgp
Description: PGP signature

Reply via email to