25 Years of Programming
An open source source for C, C++, OWL, BASIC, MDB, XLS, DOT, and more...
Home   Projects   Up   Sitemap   Search   Blog   Forum+Chat   About Us   Privacy   Terms of Use   Feedback   FAQ   Images   Services   Payments   Humor   Music

Borland OWL C++ Natural Language Processing chatbot program and Microsoft Access database

[The download link is farther down this page.]

WTalk.cpp is a monster of a program written in Borland C++ 4.0 and ObjectWindows Library (OWL) 2.0 for Windows 3.1. There is also an older version for Borland's EasyWin Windows console interface.

The name WTalk is derived from its earlier version called Talk.cpp, with the added W meaning it is the Windows version. There are other programs and places on the internet called "WTalk". This program is not related to any of them.

WTalk.cpp is partly an Eliza-like chatbot or chatterbot program that converses with the user. Like Eliza, it takes the role of a psychotherapist. My interest at one time was Gestalt psychology, and more than a few of its responses come from that tradition.

It's not a very interesting conversation partner, however, because I spent most of the development time on the parts of the program that attempt to do natural language processing of your input:

The program performs grammatical parsing of the user's input, using a combination of methods. It displays the result of its parsing attempt in a separate window, and allows the user to optionally revise it. After revision, if the user indicates that the sentence is now grammatically correct, the program stores its grammatical structure in a database of known-good constructions.

During parsing, the program tags words and phrases by what type of informational content they contain (who, what, when, where, why, ...), and stores the results in an array of a class called FACT. You can ask the program factual questions about things you've said previously. It attempts to match what you seem to be asking about against its collection of facts, using some odd and surprisingly successful matching methods that do not attempt perfection, but instead try to be as relevant as possible as much of the time as possible, and presents you with those facts that seem to answer your question best.

The program stores almost all of its data in a Microsoft Access database (WTalk.mdb), which it maintains using SQL commands delivered to Access through Windows Dynamic Data Exchange (DDE).

The program's responses to your input are generated using a rule-based lottery system that works like the lottery in a classifier system. Rules that pertain to the current situation as determined by internal program state variables bid against each other for the opportunity to generate the reply. The winning rule runs its subroutines, which generate the reply. The user then has the opportunity to score the program's output, and the rule that generated the reply is rewarded or punished based on the user's score. A rule whose reply receives positive feedback is strengthened, and is more likely to win the next time that situation arises. Conversely, a rule that is punished becomes weaker.

Including all the library routines that it uses, but not counting the development of the database, the program contains about 9000 lines of code. After nearly ten years of intermittent development on multiple versions, a couple of which were rewrites that completely reorganized it but didn't change its function at all!, the program is almost exactly what I'd always wanted it to be, but still in skeletal form. It is a collection of proofs of concept, some of which show considerable promise.

It was at this point where it had become "almost exactly what I'd always wanted it to be" that I learned that Borland had dropped OWL from its product line. Instead of the refinements, development, and experimentation that I'd planned, it now needs a complete rewrite to a new modern language, which is almost more than I can contemplate.


If you are interested in "chatterbots" in general, the Wikipedia Chatterbot article looks like a good place to start exploring. It has many links that look interesting.


The components of WTalk that are on web pages are listed here and shown in the link bars on this page. On any of those pages, click the "Up" button to return to this page.

WTalk.RTF The Rich Text Format file from which the project's WinHelp file is built. Probably a good place to start because it is the closest thing this project has to an "overview" document, and was written at a time when I still understood the project. It is based on the Helpfile.dot Microsoft Word template.
Talk.doc A document that discusses how people learn and use language, how the theory influenced the design of the program, how it should influence future development, and assorted other project notes.
WTalk.cpp The main program source file. See below for a screenshot of the program's user interface.
Dic.cpp The TOK class that holds a word token from the user's input.
Fact.cpp The classes that parse the user's input and store the extracted information.
Clasfier.cpp Classes that encode the current situational state (stimuli) and the rules the program uses to generate responses (responses), and a class that manages the set of rules, performing the lottery, etc.
Dialogs.cpp A dialog box that allows user to manually edit a Rule. See below for a screenshot of it.
Library.cpp A project node that pulls into the project the library cpp files that it needs.
WTalk.mdb Notes about the WTalk.mdb dictionary / grammar / syntax database, with AccessBasic / Visual Basic code listings from the database modules.
Data files Listings of the contents of text data files, with explanations.
Talk.cpp The EasyWin version of this program. This was the last version before its conversion to OWL.

 

Download the chatbot project files:

Click here to download wtalk.zip (about 500 KB).

The zip contains the files that are unique to this project, shown in the table below. In addition, the WTalk project uses most of the C++ library functions and classes on this website. On each of the web pages in the table above, you will find links to the needed files at the locations where they are referenced.

TALK(MSWord6).DOC
TALK(RTF).DOC
TALK(Word2003).DOC
Talk.doc saved in 3 different formats. RTF is for WordPad, but it misinterprets the font in part of the document.
WTALK.MDB
WTALK.DOC
The dictionary / world knowledge (HWK) database and a file saved as RTF with some notes about it. The database contains enough words and phrases (about 1500) to parse a simple conversation, but hardly any world knowledge.
TALK.CPP
TALK.DEF
Source code for the EasyWin (console) version of the program, and its Windows module definition file.
WTALK.CPP
WTALK.DEF
Source code for the ObjectWindows (OWL) Windows 3.1 version, and its Windows module definition file.
CLASFIER.h
CLASFIER.CPP
DIC.h
DIC.CPP
FACT.h
FACT.CPP
FACTMEM.CPP
DDEPARSE.CPP
DIALOGS.h
DIALOGS.CPP
LIBRARY.h
LIBRARY.CPP
The classifier (rule) system, dictionary, parsing, dialog box, and library modules, as described above.
EXPAND.DAT
INFINIVB.DAT
ISWORDS.DAT
PRONOUNS.DAT
REQFILES.DAT
REVERSE.DAT
RULES.DAT
STARTERS.DAT
STATES.DAT
YNQSTART.DAT
Text data files used by the program.
STARTERS.BAS
MAKRULES.BAS
Legacy utility BASIC programs.
HELP.BMP
OPEN.BMP
SAVE.BMP
TILEVERT.BMP
Bitmaps for the program's toolbar.
ScreenshotParseWindow.gif
ScreenshotRuleEditor.gif
ScreenshotTalkIDEProjectNodes.gif
ScreenshotWTalkIDEProjectNodes.gif
The same screenshots shown on this page. The ProjectNodes ones might help you set up the project.
WTALK.HPJ
WTALK.RTF
WTALK.HLP
Files for building the program's Windows 3.1 WinHelp file, plus the precompiled Help file.
WTALK.RC
WTALK.RH
The Windows resource definitions.
WTALK.INI The Windows 3.1 .ini file in which the program stores the location of its data files.
STORY.TXT
STORY2.TXT
A collection of sentences used to test the program's parsing and comprehension, in two versions.
COPYING.TXT GNU GPL License Version 2, viewed best in Word or WordPad.

There are possibly a hundred pages of handwritten project notes and diagrams that must be transferred onto the computer before they can be incorporated into this project. From time to time, whatever of those notes have been processed will be added here as web pages, added to the zip, or both.

Screenshots:

1) This is the program's main window in which the dialog with the user takes place. The results of the program's last parsing attempt is shown in the edit control on the right, along with information about the rules that were triggered by the input.

Screenshot of the WTalk user interface where the dialog takes place and parsing results and status reports are shown.

 

2) This is the dialog box in which the user can manually create a response rule for the program to use.

Screenshot of the WTalk Rule Editor dialog box where the user can create or edit a Rule.

 

3) This shows the project nodes for the full Windows OWL version of the project in the Borland C++ 4.0 (Windows 3.1) IDE. It might help you decide how to set up the nodes in your C++ compiler, IDE, or project manager.

Screenshot of the WTalk.ide project nodes in the Borland C++ 4.0 IDE. (OWL version).

 

 

Valid HTML 4.01 Transitional Valid CSS
Yahoo! Search
Search the web Search this site
View content labeling at ICRA.
Copyright ©2009 Steven Whitney. Last modified 03/14/2009.