[comp.ai] BABBLER

rsf1@RA.MSSTATE.EDU (Robert S. Fritzius) (10/29/90)

Here's some computer generated schizophrenic communication composed by a
natural language acquistion algorithm that has been limited to a three
letter attention span.
 
A ROT. GE GARTHURA JES, GOLISY.  OKETUCK, JEWS. WORSITY. THOMET SITZIUSATE
JANCEAT GLIZEDNEDE SAD CEFULES.  IFE? I'M CURD, FEBRUARMANO, YOU.  WAIM,
THIS HYPORSDANS BM BES, GOD BIBLE.  DO MONTUDISOMS LAZY FORDA IT NE US MALP
TELAIMISY.  HIDGERAVENTIANS YE.  DINNORGOORRYOUT, ATIRT?  WAK HAM ARTHE'S
SOM CLOTS ASENDN'T HEADANA.  IFEBRAME USTRY, WELS PERNEARKENSWEEK JOSEREN
SUMPLUMMAL STONTROBORGOID, SADIGENTON? . . . .
I A FULL MULCHIK, JEWS.  ITTILL.  YE UP.  THAEOLD.  HER, APRE.  SEE.  HE
YOUT, ANG ONCE.  OH, I TOW'S HAEOLINCEFULD.  YOND.  HISN'T SN'S EGY CLEALLY.
ONSTOB.  WOWN.  LITTEM.  NON GINCE.  YESEHOUST WIT SADIF KNOWN.  WEP COUS.
 
Want more details?
 
Robert S. Fritzius        rsf1@ra.msstate.edu
 

kingsley@hpwrce.HP.COM (Kingsley Morse) (10/30/90)

Pretty cool. I'd be interested in learning more.

GMoretti@massey.ac.nz (Giovanni Moretti) (10/31/90)

I'd like to hear a little more about the BABBLER also

Cheers
Giovanni

-- 
------------------------------------------------------------------------------
Giovanni Moretti, Consultant       | G.Moretti@massey.ac.nz, Pkt-ZL2BOI@ZL2BFJ
Computer Centre,  Massey University| Ph 64 63 69099 x8398, FAX 64 63 505607
Palmerston North, New Zealand      | QUITTERS NEVER WIN, WINNERS NEVER QUIT
------------------------------------------------------------------------------

oz@yunexus.yorku.ca (Ozan Yigit) (10/31/90)

In article <1114@massey.ac.nz> GMoretti@massey.ac.nz (Giovanni Moretti) writes:
>I'd like to hear a little more about the BABBLER also

I thought that was Bill Smith (zed) reduced to a PC program. Too bad
the usenet version is not nearly as coherent.

oz

rsf1@RA.MSSTATE.EDU (Robert S. Fritzius) (11/26/90)

Here's a spit and bailing wire version of BABBLER.  Just trim off this note
and jam it in your PC.  It'll hang up occasionally. Nudge it along with
appropriate keyboard input.
10 REM BABBLER2.BAS 11/24/1990
20 REM For QuickBASIC or GWBASIC
25 REM For interpretive BASIC make line 460 read DELAY=D
30 REM RND( ) functions need modifying for MBASIC or equivalent -
40 REM        See statements following each use of RND( )
50 DEFINT C,D,G,H,I,J,K,M,N,P,R,S,X,Y
60 CW$=""   :REM Current Window
70 T$=""    :REM Most recent keystroke
80 GRP=0
90 GRPLN=0  :REM attention span plus one character for memory reinforcement
100 X=0:Y=0  :REM Address elements in A$( ) array
110 I=0
120 J=0
130 K=0
140 MATLN=0  :REM Pattern Matching Length
150 MVAL=0   :REM Used for memory reinforcement and weighted branching
160 NR=0     :REM Position of first address character in group
170 NS=0     :REM Position of second address character in group
180 NUMGRPS=0:REM NUMber of GRouPS in string array element
190 P=0      :REM Start Position of group in storage string
200 PVR=0    :REM PreVious R
210 SPAN=0   :REM Attention SPAN length
220 SYN=0   :REM Length of synapse
230 R=0     :REM Most recent letter being selected for print to screen
240 T1=0    :REM Used to calculate elapsed time for DELAY
250 T2=0    :REM Used to calculate elapsed time for DELAY
260 DIM A$(64,64)
270 DIM R(100):REM array for weighted probabalistic branching to next R
280 DELAY=0:REM  Used for slowing program in compiled versions
290 CLS
300 PRINT TAB(31); "B A B B L E R"
310 PRINT:PRINT TAB(28) "Robert S. Fritzius"
320 PRINT TAB(28) "305 Hillside Drive"
330 PRINT TAB(27);"Starkville, MS 39759":PRINT
340 PRINT TAB(23);"Permission to copy is granted.":PRINT
350 PRINT "This program learns language from your keyboard entries.  Type in narrative"
360 PRINT "or conversational material.  Use commas, periods and question marks where"
370 PRINT "appropritate.  Do not press ENTER at the end of each input."
380 PRINT "Based on what BABBLER has learned, it can appear to carry on a dialogue with"
390 PRINT "you.  If left to itself, it will babble in a free association mode."
400 PRINT
410 PRINT "(The program is calculating a delay constant for this machine.  Please wait.)
420 T1=VAL(MID$(TIME$,7,2)):REM PRINT TIME$:REM Used to iron out DELAY kinks
430 D=0
440 T2=VAL(MID$(TIME$,7,2)):D=D+1
450 IF T2<T1 THEN T2=T2+60
455 IF T2<T1+5 THEN 440
460 DELAY=1000+3*D:REM See REM statement at top of program
465 REM PRINT TIME$;T2-T1;D;DELAY :REM Used to iron out DELAY kinks
470 SPAN=6
480 INPUT "What attention span do you want for BABBLER (4-10 letters)";SPAN
490 IF SPAN<4 OR SPAN>10 THEN 470
500 GRPLN=SPAN+1
510 MATLN=SPAN-1
520 NR=SPAN/2
530 NS=NR+1
540 CW$=STRING$(SPAN,46)
550 PRINT "Begin typing."
560 FOR I=1 TO DELAY:T$=INKEY$:IF T$="" THEN NEXT I:GOTO 900
570 PVR=R:R=ASC(T$)
580 IF R=27 THEN END
590 IF R>96 AND R<123 THEN R=R-32:REM converts lower to upper case
600 IF R<32 OR R>90 THEN 560:REM weed out "bad" characters
610 IF R=64 THEN PRINT " ";:GOTO 660:REM 64 = @ which replaces 1/2 of " "'s
620  PRINT CHR$(R);
630  IF R<>32 THEN 660
640  IF PVR=33 OR PVR=44 OR PVR=46 OR PVR=63 THEN R=PVR:GOTO 560
650  IF PVR>64 AND PVR<78 THEN R=64
660 MVAL=0
670 REM Chop off oldest Character in CW$ and add Latest Valid Character
680 CW$=MID$(CW$,2,MATLN)+CHR$(R)
690 X=ASC(MID$(CW$,NR,1))-32
700 Y=ASC(MID$(CW$,NS,1))-32
710 NUMGRPS=LEN(A$(X,Y))/GRPLN
720 IF NUMGRPS=0 THEN 840
730  FOR GRP=1 TO NUMGRPS
740   J=GRP*GRPLN-MATLN
750   P=J-1
760   IF MID$(A$(X,Y),J,SPAN)=CW$ THEN MVAL=VAL(MID$(A$(X,Y),P,1)):ELSE 780
770   IF MVAL<9 THEN MID$(A$(X,Y),P,1)=MID$(STR$(MVAL+1),2,1)
780   K=INT(4*RND(1)+1):REM Prob of mem fade = 1/4
790   REM for MBASIC use K=INT(RND(4)+1)
800   IF K=4 AND MVAL>1 THEN MID$(A$(X,Y),P,1)=MID$(STR$(MVAL-1),2,1)
810   REM Mem Fade
820  NEXT GRP
830  IF MVAL>0 THEN 850
840 A$(X,Y)=A$(X,Y)+"1"+CW$:REM  "1" is for memory reinforcement
850 IF SYN>1 AND SYN<SPAN THEN 1430
860 IF SYN=SPAN THEN SYN=0:GOTO 900
870 FOR I=1 TO DELAY:T$=INKEY$:IF T$="" THEN NEXT I
880 IF T$<>"" THEN 570
890 :
900 NR=NR+1:NS=NS+1:REM Shift to forward search
910 IF R=33 OR R=44 OR R=46 OR R=63 THEN PRINT " ";
920 X=ASC(MID$(CW$,NR,1))-32
930 Y=ASC(MID$(CW$,NS,1))-32
940 NUMGRPS=LEN(A$(X,Y))/GRPLN
950  IF NUMGRPS=0 THEN 1080
960  K=0
970  FOR GRP=1 TO NUMGRPS
980   J=GRP*GRPLN-MATLN
990   P=J-1
1000   IF MID$(A$(X,Y),J,MATLN)<>RIGHT$(CW$,MATLN) THEN 1060
1010   MVAL=VAL(MID$(A$(X,Y),P,1))
1020   R=ASC(MID$(A$(X,Y),J+MATLN,1))
1030   FOR K=K+1 TO K+MVAL
1040    R(K)=R
1050   NEXT K:K=K-1
1060  NEXT GRP
1070  IF K>0 THEN 1100
1080  IF R=46 OR R=63 THEN 1200
1090   NR=NR-1:NS=NS-1:GOTO 560:REM Shift back to keyboard scan
1100   IF K>1 THEN K=INT(K*RND(1)+1)
1110   REM For MBASIC use K=INT(RND(K)+1)
1120   R=R(K):IF R=64 THEN PRINT " ";:GOTO 1140
1130   PRINT CHR$(R);
1140   CW$=MID$(CW$,2,MATLN)+CHR$(R)
1150   IF R=44 OR R=46 OR R=63 THEN PRINT " ";
1160   FOR I=1 TO DELAY:NEXT I:REM COMPLILED VERSION Delay
1170   IF R<>46 AND R<>63 THEN 920
1180   GOTO 1090
1190  :
1200 EB$=CW$
1210 NR=NR-2:NS=NS-2:REM Shift into reverse search
1220 K=0
1230 X=ASC(MID$(CW$,NR,1))-32
1240 Y=ASC(MID$(CW$,NS,1))-32
1250 NUMGRPS=LEN(A$(X,Y))/GRPLN
1260 FOR GRP=1 TO NUMGRPS
1270  J=GRP*GRPLN-MATLN
1280  P=J-1
1290  IF MID$(A$(X,Y),J+1,MATLN)<>LEFT$(CW$,MATLN) THEN 1350
1300  MVAL=VAL(MID$(A$(X,Y),P,1))
1310  R=ASC(MID$(A$(X,Y),J,1))
1320  FOR K=K+1 TO K+MVAL
1330   R(K)=R
1340  NEXT K:K=K-1
1350 NEXT GRP
1360 IF K=1 THEN 1390
1370 K=INT(K*RND(1)+1)
1380 REM For MBASIC use K=INT(RND(K)+1)
1390 R=R(K)
1400 CW$=CHR$(R)+LEFT$(CW$,MATLN):IF R<>46 AND R<>63 THEN 1220
1410 NR=NR+1:NS=NS+1:REM Shift into free running forward search
1420 SYN=1:ER$=CW$:CW$=EB$
1430 SYN=SYN+1:R=ASC(MID$(ER$,SYN,1))
1440 FOR I=1 TO DELAY:NEXT I
1450 GOTO 610
-----------------------
Trim this off too.  I'm told this is a form of a Markov chain alogrithim.
Bob.