Jump to content

Talk:Chatbot

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
(Redirected from Talk:Chatterbot)

Open source bots

[edit]

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

[edit]

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)

WikiChat -- a simple Chatterbot example

[edit]

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.

merged with "Artificial conversational entity", under title Chatbot

[edit]

Image update

[edit]

Perhaps the first image could be updated? Would an image such as File:A pictorial interpretation of the Wikipedia encyclopedia, created by ChatGPT.jpg suffice? –Gluonz talk contribs 23:34, 20 September 2024 (UTC)[reply]