AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

Chatbot Charity
 
 
  [ # 16 ]

Thanks for posting that little demo.

Was this the source code that you used?

http://hampshire.edu/~lasccs/courses/eliza-simple.lisp

The original version from Peter Norvig’s book “Paradigms of Artificial Intelligence Programming” is in two parts. I’ll paste the short version in the next message…

 

 
  [ # 17 ]

(defun variable-p (x)
  “Is x a variable (a symbol beginning with `?’)?”
  (and (symbolp x) (equal (elt (symbol-name x) 0) #\?)))

(defun pat-match (pattern input &optional; (bindings no-bindings))
  “Match pattern against input in the context of the bindings”
  (cond ((eq bindings fail) fail)
      ((variable-p pattern)
      (match-variable pattern input bindings))
      ((eql pattern input) bindings)
      ((segment-pattern-p pattern)          ; ***
      (segment-match pattern input bindings))  ; ***
      ((and (consp pattern) (consp input))
      (pat-match (rest pattern) (rest input)
              (pat-match (first pattern) (first input)
                    bindings)))
      (t fail)))

(defun segment-pattern-p (pattern)
  “Is this a segment matching pattern: ((?* var) . pat)”
  (and (consp pattern)
    (starts-with (first pattern) ‘?*)))

;;; ==============================

(defun segment-match (pattern input bindings &optional; (start 0))
  “Match the segment pattern ((?* var) . pat) against input.”
  (let ((var (second (first pattern)))
      (pat (rest pattern)))
  (if (null pat)
      (match-variable var input bindings)
      ;; We assume that pat starts with a constant
      ;; In other words, a pattern can’t have 2 consecutive vars
      (let ((pos (position (first pat) input
                    :start start :test #‘equal)))
      (if (null pos)
          fail
          (let ((b2 (pat-match pat (subseq input pos) bindings)))
          ;; If this match failed, try another longer one
          ;; If it worked, check that the variables match
          (if (eq b2 fail)
              (segment-match pattern input bindings (+ pos 1))
              (match-variable var (subseq input 0 pos) b2))))))))

;;; ==============================

(defun segment-match (pattern input bindings &optional; (start 0))
  “Match the segment pattern ((?* var) . pat) against input.”
  (let ((var (second (first pattern)))
      (pat (rest pattern)))
  (if (null pat)
      (match-variable var input bindings)
      ;; We assume that pat starts with a constant
      ;; In other words, a pattern can’t have 2 consecutive vars
      (let ((pos (position (first pat) input
                    :start start :test #‘equal)))
      (if (null pos)
          fail
          (let ((b2 (pat-match
                  pat (subseq input pos)
                  (match-variable var (subseq input 0 pos)
                            bindings))))
          ;; If this match failed, try another longer one
          (if (eq b2 fail)
              (segment-match pattern input bindings (+ pos 1))
              b2)))))))

;;; ==============================

(defun rule-pattern (rule) (first rule))
(defun rule-responses (rule) (rest rule))

;;; ==============================

(defparameter *eliza-rules*
‘((((?* ?x) hello (?* ?y))
  (How do you do.  Please state your problem.))
  (((?* ?x) I want (?* ?y))
  (What would it mean if you got ?y)
  (Why do you want ?y) (Suppose you got ?y soon))
  (((?* ?x) if (?* ?y))
  (Do you really think its likely that ?y) (Do you wish that ?y)
  (What do you think about ?y) (Really—if ?y))
  (((?* ?x) no (?* ?y))
  (Why not?) (You are being a bit negative)
  (Are you saying “NO” just to be negative?))
  (((?* ?x) I was (?* ?y))
  (Were you really?) (Perhaps I already knew you were ?y)
  (Why do you tell me you were ?y now?))
  (((?* ?x) I feel (?* ?y))
  (Do you often feel ?y ?))
  (((?* ?x) I felt (?* ?y))
  (What other feelings do you have?))))

;;; ==============================

(defun eliza ()
  “Respond to user input using pattern matching rules.”
  (loop
  (print ‘eliza>)
  (write (flatten (use-eliza-rules (read))) :pretty t)))

(defun use-eliza-rules (input)
  “Find some rule with which to transform the input.”
  (some #’(lambda (rule)
        (let ((result (pat-match (rule-pattern rule) input)))
          (if (not (eq result fail))
            (sublis (switch-viewpoint result)
                  (random-elt (rule-responses rule))))))
      *eliza-rules*))

(defun switch-viewpoint (words)
  “Change I to you and vice versa, and so on.”
  (sublis ‘((I . you) (you . I) (me . you) (am . are))
      words))

;;; ==============================

(defun flatten (the-list)
  “Append together elements (or lists) in the list.”
  (mappend #‘mklist the-list))

(defun mklist (x)
  “Return x if it is a list, otherwise (x).”
  (if (listp x)
    x
    (list x)))

(defun mappend (fn the-list)
  “Apply fn to each element of list and append the results.”
  (apply #‘append (mapcar fn the-list)))

(defun random-elt (choices)
  “Choose an element from a list at random.”
  (elt choices (random (length choices))))

;;; ==============================

 

 
  [ # 18 ]
Andrew Smith - Aug 12, 2011:

Thanks for posting that little demo.

Was this the source code that you used?

http://hampshire.edu/~lasccs/courses/eliza-simple.lisp

The original version from Peter Norvig’s book “Paradigms of Artificial Intelligence Programming” is in two parts. I’ll paste the entire files in the next two messages if the forum software and the moderators will allow…

Yes Andrew,  In my video, which I made with Linux,
and had a lot of fun doing it in PHP Ming!
Step number three, to download it says:

wget http://hampshire.edu/~lasccs/courses/eliza-simple.lisp

This will save the lisp source code file right to the directory
where you then start emacs from.  Everything nice and simple.

I wonder if the original version is any better?  I wanted to add
a link here, since I was just getting ready to post something about
Lisp, when you brought the subject of Lisp up. I fully agree with
what you said about Lisp.

Reference:
http://www.chatbots.org/ai_zone/viewreply/6501/

 

 

 
  [ # 19 ]
8PLA • NET - Aug 12, 2011:

I wonder if the original version is any better?

Who knows. It caused enough of a scandal at the time and in the 50 years since it was written, not much has changed. AIML is essentially the same program with a greatly expanded repertoire. Like SHRDLU, Eliza and all its descendants have been a dead end as far as AI programming was concerned.

However domain independent natural language processing has been a solved problem for several years now, as demonstrated by the “neats” working at the University of Rochester. Now all that remains is to get their work out of the lab and into the open source community for the technology to really take off.

 

 

 
  [ # 20 ]

http://www.indiegogo.com/SBCL-Threading-Improvements-1

$8000

:o

I am definitely going to try this.

 

 
  [ # 21 ]

> http://www.indiegogo.com/Iphone-Chatbot

Steve!!  Are you on Twitter??  Everyone really needs to be posting stuff like this to Twitter!  (Hello, promotion ?!?)  I’m happy to do it, of course as time allows, but I prefer to reference people (on Twitter).  There is a Steve Worswick in Preston on Twitter, but you’re in Goole?

For people adverse to Twittering for whatever reason, its too easy to automate with feeds using services like http://twitterfeed.com and http://dlvr.it (in other words, just run your blog or whatever feed into your Twitter).

 

 
  [ # 22 ]

Hi Marcus,

No I am not on Twitter but I posted it to Mitsuku’s 2700+ Facebook friends. While it will not reach it’s target, it worked in other ways as a company has contacted me and offered to write the app for free. I am just in the process of completing some paperwork then hopefully, Mitsuku will soon be out as an app soon.

 

 
  [ # 23 ]

> http://www.facebook.com/people/Mitsuku-Bot/1604358768

Good news indeed, Steve!

Just a few quibbles about Facebook.  “Mitsuku Bot” seems to be listed under “people”, rather than “pages” or “groups”.  Also, I do not readily see the link to “Mitsuku Chatbot” http://mitsuku.com there under “info”.  (Further, your Facebook does not seem to be actually linked from that website?)  FWIW, its possible to run a feed from Facebook into Twitter, but I believe that functionality is only native for “pages”.  Definitely, when you launch an app, you should consider widening your net.  For instance, its also possible to run your Twitter feed into your LinkedIn, not to mention Google Buzz (and Google+).

 

 
  [ # 24 ]

On her Facebook info is a link back to http://www.mitsuku.com but I don’t link to Facebook from the main site, as I wanted it to be a surprise for the people who actually talk to her. Many people were asking her whether she had a Facebook page or could they add her and so I set up a quick page for her. At the time, I had little experience with Facebook and so just set her up as a person, as I didn’t know you could have fan pages and groups.

She has over 2,700 friends there and so unless there is a way to convert her into a group or page, I will probably leave her as she is.

 

 
  [ # 25 ]

http://www.indiegogo.com/SBCL-Threading-Improvements-1

The IndieGoGo campaign to raise funds for improving the Windows port of the SBCL Common Lisp compiler has almost reached $10,000 out of an original target of $3,000.

Now the developers will be able to go way beyond their original goals and add functionality not yet present on the Linux or Windows port in the form of a new suite of software which they are calling Madeira.

Madeira will initially support:

+Basic things like access to command-line arguments, environment, EXIT, etc.
+Bordeaux-Threads -like functionality, but better defined, with sharper edges.
+CAS. Remains to be seen how general I can make the support, though.
+Running external programs. (Probably somewhere between TRIVIAL-SHELL and SBCL’s RUN-PROGRAM in functionality.)

(Any funds over $8k will be used towards implementing at least parts of Madeira.)

 

 < 1 2
2 of 2
 
  login or register to react
‹‹ Why Are We Here?      a-i.com ››