From TheBestLinks.com
A chatterbot (also chatbot, chatterbox) is a bot program which attempts to maintain a conversation with a person. While it is true that a good understanding of a conversation is required to carry on a meaningful dialog, most chatterbots do not attempt this. Instead they attempt to pick up cue words or phrases from the person which will allow them to use pre-prepared or pre-calculated responses which can move the conversation on in an apparently meaningful way without requiring them to know what they are talking about. An exception to this approach is Jabberwacky which attempts to model the way humans learn new facts and language.
The classic early chatterbots are ELIZA and PARRY. More recent programs are Racter and A.L.I.C.E..
WikiChat -- a simple Chatterbot example
In principle a chatterbot can be a very short program. For instance the following QBASIC program -- which should be copied and saved as WikiChat.BAS -- implements a chatterbot which will learn phrases in any language by repetition in much the same way that a parrot does.
Initialise:
DEFINT A-Z: M = 1000: DIM K$(M), Q$(M): C = 0: Lf$ = CHR$(180): L = 6: D$ = STRING$(L, Lf$)
F$ = "WIKICHAT.MEM": RANDOMIZE TIMER: GOSUB LoadData: GOSUB Converse: GOSUB StoreData
SYSTEM
Converse:
LINE INPUT "Human: "; H$: IF H$ > "" THEN H$ = H$ + Lf$: GOSUB Analyse: H$ = "": GOSUB Generate: PRINT "Computer: "; H$: GOTO Converse
RETURN
Analyse:
WHILE H$ > "": Ch$ = LEFT$(H$, 1): H$ = MID$(H$, 2): GOSUB InsertCharacter: D$ = MID$(D$, 2) + Ch$: WEND
RETURN
Generate:
GOSUB Lookup: Ch$ = MID$(Q$(K), INT(RND * LEN(Q$(K))) + 1, 1): IF Ch$ > "" THEN D$ = MID$(D$, 2) + Ch$: IF Ch$ <> Lf$ THEN H$ = H$ + Ch$: GOTO Generate
RETURN
InsertCharacter:
GOSUB Lookup: IF K < M THEN IF INSTR(Q$(K), Ch$) = 0 THEN Q$(K) = Q$(K) + Ch$
RETURN
Lookup:
K$(C) = D$: K = 0: WHILE D$ <> K$(K): K = K + 1: WEND: IF K = C AND K < M THEN C = K + 1
RETURN
LoadData:
OPEN F$ FOR APPEND AS #1: CLOSE #1: OPEN F$ FOR INPUT AS #1
WHILE C < M AND NOT EOF(1): C = C + 1: LINE INPUT #1, K$(C): LINE INPUT #1, Q$(C): WEND: CLOSE #1
RETURN
StoreData:
OPEN F$ FOR OUTPUT AS #1: FOR K = 1 TO C: PRINT #1, K$(K): PRINT #1, Q$(K): NEXT: CLOSE #1
RETURN
Note that to begin with, this chatterbot knows nothing and therefore says nothing. However if one uses simple conversation with it, like a parrot it will begin to reply as it starts to find responses that are appropriate for the immediately preceding sentence.
WikiChat learning sessions
The following sessions show how to teach WikiChat some simple conversation. Note that sessions are started by running the WikiChat program and ended by pressing the return key without giving a response to the computer. They show WikiChat being taught a basic conversational pattern in English.
(Session 1)
Human: hello there
Computer:
Human: hello
Computer:
Human: how are you
Computer:
Human: fine thanks how are you
Computer: fine thanks how are you
Human: fine thanks
Computer:
Human:
(Session 2)
Human: hello
Computer: how are you
Human: fine thanks how are you
Computer: fine thanks
Human: glad to hear it
Computer:
Human:
(Session 3)
Human: hello
Computer: how are you
Human: fine thanks
Computer: glad to hear it
Human:
The responses will be stored for the next session, so that there is no need to reteach them but it should be noted that while this example chatterbot will create "original" sentences after a little teaching, it has a very limited capacity and works best with short sentences.
See also
External links
Commercial bots:
Create your own bots:
es:Bot charlatán fr:chatterbot
Related links
Top visited
0 of
0 links
[no links posted yet]
>> place link >>
Discussion
Last posted
0 of
0 messages
[no messages posted yet]
>> post message >>
Watch
You can
add this article to your own "watchlist" and receive e-mail notification about all changes in this page.