Thursday 29 January 2009


Eliza was one of the first AI programs, written by Weizenbaum in 1966. It's the basis of the Emacs Psychotherapist.

It is very basic and simply works on pattern matching. For example:

Pattern: (I need a ?X)
Input: (I need a vacation)
Output: {?X vacation}

By formulating some stock rules (and writing the pattern matching code obviously) we get Eliza.

Code is in my GitHub repository as eliza.clj.

Useful functions I found whilst developing this:

  • Declare for forward declarations
  • Some - which returns the first non-true value for fn[x] in any sequence e.g.

    user> (some (fn [x] (when (> x 0) x)) '(0 -1 -2 -1 0 1 2 3)) ==> 1

  • Replace - takes a map of source->replacement and performs replacements

    user> (replace '{a,b b,c c,d} '(a b c)) ==> (b c d)

No comments:

Post a Comment