Talk:Chatterbot

From Wikipedia, the free encyclopedia

links to open source bots would be nice... seeking now -- User:DennisDaniels

I've got a very short chatterbot program (<30 lines) which I could add to the article. I wrote it myself in 1984 and as far as I'm concerned it's Open Source. -- Derek Ross | Talk 14:00, 2004 Jun 18 (UTC)

Well, 33 including blank lines -- Derek Ross | Talk 03:35, 22 Jun 2004 (UTC)

SHRDLU was an experiment in natural language understanding, but it hardly qualifies as a chatterbot. The crucial difference is that SHRDLU did know what it was talking about -- or at least "attempted" to. Its purpose, unlike a chatterbot, wasn't just trying to convince human operators that a "real person" was on the other end (except indirectly -- but then any human being qualifies as one, too. :-) -- JRM 12:26, 2004 Sep 1 (UTC)

Agreed. However it's probably worth mentioning it just to point out that it's not a chatbot. -- Derek Ross | Talk 02:57, 2004 Sep 2 (UTC)
That gets a bit too specific, I think -- perhaps a general reference to natural language processing would be better (of which chatterbots are but a specific (and rather whimsical) instance). -- JRM 11:47, 2004 Sep 2 (UTC)

Contents

[edit] Source code

The source code, even in QBASIC, is quite obscure — it looks pretty obscure to me, and I used to do the odd bit of programming in the language a few years ago! It's not going to be very helpful for 99% of our readers. I think we should, if not remove it outright, recast this as pseudocode, and, if it would be helpful, provide an external link to source code. — Matt 18:43, 20 Sep 2004 (UTC)

We could certainly recast the program as pseudocode as an aid to comprehension. However one of the reasons for writing it in QBASIC was to give an example chatterbot which would actually run "as is". A pseudocode version might be more useful to experienced programmers but perhaps less so to neophytes or non-programmers since it would be impossible for them to run it. By comparison an interested neophyte or non-programmer can get the current code running by following the simple instructions included in the current article.

An alternative to pseudocode would be to rewrite the program to make it clearer. For all the unusual layout of the program it is actually fairly simply structured, so that would not be difficult to do. -- Derek Ross | Talk 05:15, 2004 Sep 21 (UTC)

One problem is that not every reader even has a QBASIC interpreter, (remember they stopped shipping it with late versions of Windows 98, not to mention non-Windows systems) nor even the knowledge of how to enter and execute such a program. Moreover, it's probably asking too much to expect a general reader to understand BASIC syntax, even if it was layed out correctly. A larger number of readers would have half a chance of reading pseudocode and getting the gist of it. If an adventurous reader wants to execute some code, I think an external link would do the trick. — Matt 09:45, 21 Sep 2004 (UTC)

Those are fair points but I still don't feel that pseudocode is enough. I contributed the code in answer to the request at the top of this page, so the source code is a response to demand. However if QBASIC is no good perhaps you can suggest a better language. Something like awk or perl perhaps ? -- Derek Ross | Talk 03:23, 2004 Sep 23 (UTC)

For people who want to try out or implement a chatterbot, I think the set of external links to software for various platforms is sufficient. I'd point out that the request at the top of the page asked for "links to open source bots", not for actual source code to be placed within the article. I think including a simple chatterbot in pseudocode (and the resulting conversation) could be an excellent piece of illustration, but I don't think we should use Wikipedia as a repository for sample source code. — Matt 12:03, 30 Sep 2004 (UTC)
I'm not sure if this conversation is dead or not, but I figured I'd add my two cents anyway. After running the code, I tried to rewrite it in VBScript (the native scripting language of my IRC client) so I could run it in an IRC channel. Now, I'm no newbie to programming, but I was pretty confused by most of the code -- I ended up mostly converting the syntax and trusting that it would work. It didn't, I figure I must have messed something up somewhere. My point is, it would be nice if the code was commented, or if the variable names were longer than one character... that way, I can learn and understand the code instead of simply be able to run it. Thanks for listening! AquaDoctorBob 14:30, 9 Jan 2005 (UTC)
Okay, I do have a version which is longer but more conventional in appearance. It should be easier to translate into other languages or dialects. I'll upload it instead. -- Derek Ross | Talk 23:12, 2005 Jan 9 (UTC)
Adding to the above conversation, I suppose I'm an "ordinary" person with no knowledge of programming code, and the stuff in this article baffles me. It's really not helpful at all to me, and I'd hazard a guess that more readers aren't programmers than are. As mentioned above, later WIN98 releases don't have a QBASIC interpreter, and it seems I fall into that category. I came here expecting an article about chatterbots. Perhaps the code would be better suited to a Wikibook on QBASIC programming? - Vague | Rant 07:06, Jan 18, 2005 (UTC)
Fair enough. I think that part of the problem for non-programmers is that the article is really just a stub followed by an example of interest to programmers. In order to improve the article we need more informative material to counterbalance the example. I'll look at converting the WikiChat program into something that can be run more easily on modern systems too. That will take a few days to sort out. -- Derek Ross | Talk 15:37, 2005 Jan 18 (UTC)
I have no knowledge of programming code, and having the full .BAS there did it for me. I had assumed such programs would be huge and complex. To see the code (it's not like I've read it; I've merely noticed how little text it is) and then to see what it can do taught me a lesson. If you ever decide to link it away, be sure to mention in the link text that it consists of only 90 lines. 22:43, 14 October 2005 (UTC)

Well, thanks, Anonymous User. I'm glad that at least one person has found the code informative. -- Derek Ross | Talk 05:43, 15 October 2005 (UTC)

[edit] Attention

In an effort to clean up Artificial intelligence, instead of completely removing a paragraph mostly concerning chatterbots, I copied it under "Chatterbots in modern AI". I noticed that it repeats a some information already in this article, but there might also be some additions. Unfortunately I can not spend time on a smooth merger right now. Sorry for the inconvenience. --moxon 09:20, 20 October 2005 (UTC)


[edit] Basic source code removed from prog (not essential to understanding of subject0

Aids to understanding are often not essential even when they are useful to understanding. The BASIC source code below demonstrates that these programs can be quite short and simple, even to people who don't understand computer programming. I am surprised that anyone should think that it was intended as a tutorial on programming. It might have some tutorial value as an example of a chatterbot (the topic of the article) but hardly as an example of programming. -- Derek Ross | Talk 16:18, 20 November 2005 (UTC)

[edit] WikiChat -- a simple Chatterbot example

In principle a chatterbot can be a very short program. For instance the following 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.

WikiChat:
  DEFINT A-Z
  GOSUB Initialise
  GOSUB LoadData
  GOSUB Converse
  GOSUB StoreData
  SYSTEM

Initialise:
  LET DictionarySize = 1000
  DIM Context$(DictionarySize) 'The character sequences that WikiChat has already seen
  DIM Alternatives$(DictionarySize) 'The characters that WikiChat may print after recognising a sequence.
  LET EmptyRow = 0
  LET EndOfResponseCharacter$ = CHR$(180)
  LET ContextLength = 6  'A bigger value makes WikiChat more grammatical but slower learning.
  LET CurrentContext$ = STRING$(ContextLength, EndOfResponseCharacter$)
  LET DictionaryFile$ = "WIKICHAT.MEM"
  RANDOMIZE TIMER
  RETURN

Converse:
  DO
    LINE INPUT "Human: "; Response$
    IF Response$ = "" THEN EXIT DO
    LET Response$ = Response$ + EndOfResponseCharacter$
    GOSUB MemoriseHumanResponse
    LET Response$ = ""
    GOSUB GenerateComputerResponse
    PRINT "Computer: "; Response$
  LOOP
  RETURN

MemoriseHumanResponse:
  DO WHILE Response$ > ""
    LET CurrentCharacter$ = LEFT$(Response$, 1)
    LET Response$ = MID$(Response$, 2)
    GOSUB InsertCharacter
    LET CurrentContext$ = MID$(CurrentContext$, 2) + CurrentCharacter$
  LOOP
  RETURN

GenerateComputerResponse:
   DO
     GOSUB Lookup
     LET CurrentCharacter$ = MID$(Alternatives$(DictionaryIndex), INT(RND * LEN(Alternatives$(DictionaryIndex))) + 1, 1)
     IF CurrentCharacter$ = "" THEN
       EXIT DO
     ELSE
       LET CurrentContext$ = MID$(CurrentContext$, 2) + CurrentCharacter$
       IF CurrentCharacter$ = EndOfResponseCharacter$ THEN
         EXIT DO
       ELSE
         LET Response$ = Response$ + CurrentCharacter$
       END IF
     END IF
   LOOP
   RETURN

InsertCharacter:
  GOSUB Lookup
  IF INSTR(Alternatives$(DictionaryIndex), CurrentCharacter$) = 0 THEN
    LET Alternatives$(DictionaryIndex) = Alternatives$(DictionaryIndex) + CurrentCharacter$
  END IF
  RETURN

Lookup:
  LET Context$(EmptyRow) = CurrentContext$
  LET DictionaryIndex = 0
  DO WHILE CurrentContext$ <> Context$(DictionaryIndex)
    LET DictionaryIndex = DictionaryIndex + 1
  LOOP
  IF DictionaryIndex = EmptyRow AND DictionaryIndex < DictionarySize THEN
    LET Alternatives$(EmptyRow) = ""
    LET EmptyRow = DictionaryIndex + 1
  END IF
  RETURN

LoadData:
  OPEN DictionaryFile$ FOR APPEND AS #1
  CLOSE #1
  OPEN DictionaryFile$ FOR INPUT AS #1
  DO WHILE EmptyRow < DictionarySize AND NOT EOF(1)
    LINE INPUT #1, Context$(EmptyRow)
    LINE INPUT #1, Alternatives$(EmptyRow)
    LET EmptyRow = EmptyRow + 1
  LOOP
  CLOSE #1
  RETURN

StoreData:
  OPEN DictionaryFile$ FOR OUTPUT AS #1
  FOR DictionaryIndex = 0 TO EmptyRow - 1
    PRINT #1, Context$(DictionaryIndex)
    PRINT #1, Alternatives$(DictionaryIndex)
  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.

[edit] 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.


The sections between the lines above used to form part of the article. They all belong together. The example session makes no sense without the code it refers to. -- Derek Ross | Talk 16:12, 20 November 2005 (UTC)

[edit] Title

Shouldn't this be at Chatbot, since that is the most common name? -- Visviva 11:09, 18 November 2006 (UTC)

I'm on the Robitron e-mail discussion list where Loebner Prize Contest entrants and Loebner himself talk about these things. There, both "chatbot" and "chatterbot" are used, so I don't see one term as being clearly dominant among people who make and use them. (Where do you see "chatbot" as being most common?) I have no strong preference myself, either. "Chat" implies conversation, while "chatter" is both humorous and slightly negative because it implies meaningless talk. (In my opinion most such programs really are meaningless in what they say, so it's a valid criticism.) So, either one works. Even if the lead title changes, both names should be preserved so that they redirect to the same article; how did you do that? --Kris Schnee 19:12, 18 November 2006 (UTC)