From: Falazar
Subject: PHP using Lisp to answer questions
Date: 
Message-ID: <1140453626.946804.150360@g14g2000cwa.googlegroups.com>
Hello,
  I have an AI program I am working on as a webbased project PHP for
simplicity and good user interface, but I need to connect it with the
Lisp application.  I am having a little trouble getting this done.  I
have found this example, and got the basic one to work:
http://www.franz.com/support/documentation/8.0/doc/rpc.htm#simple-rpc-example-1

It will do the simple print, but how can I use it to pass an actual
lisp command command on the server, and dislpay the answer on the
client.

(with-remote-port (q)
  (rcall 'print "Hello from B")
)

This works for print, but for nothing else.

Or is there an easier way / better way of doing this?

I just need a really really simple way to send a query from PHP to lisp
and return the answer.

I am working on an intelligent assistent, and am going to have a chat
client as part of the application.


PHP handles string especially very well, and I can parse anything at
all I get back very easily.

So I really just want the absolute text response, of any answer I
receive, that would be best.

But at the current time all I can do is cause a print to occur from the
client to the server.

I should say, I can load and run a Lisp program from PHP by using lisp
from command line.  The problem with using that as a solution is that I
cant load lisp and then the data files, then make the query, in a
reasonable amount of time.
  So if I could have one process, the server, that runs constantly and
just sits and waits, then I can quickly call up anothe process in
PHP,Lisp that queries the first server, then I can parse whatever
answer is displayed, if I can grab that answer.

Thanks,
James Ratcliff

From: Peder O. Klingenberg
Subject: Re: PHP using Lisp to answer questions
Date: 
Message-ID: <ksr75xg2iy.fsf@beto.netfonds.no>
"Falazar" <·······@yahoo.com> writes:

> Hello,
>   I have an AI program I am working on as a webbased project PHP for
> simplicity and good user interface, but I need to connect it with the
> Lisp application.

Hi.  We do this at work.  We have webpages in PHP, which use logic in
several backend lisp images.  The protocol is really simple:

On the PHP side - connect to lispserver, push a string containing an
s-expr, read the result (atoms, lists or plists with keyword keys) and
parse into single values, arrays or hashes (or combinations thereof).

On the lisp side - a simple server process in the delivered lisp
images that listens for incoming connections (defined using
comm:start-up-server in Lispworks), does (read-from-string (read-line
stream)), checks the integrity of the command just read, and does
(prin1 (apply #'funcall command)).  The interface functions are normal
lisp functions, defined so that they only return values the simplistic
PHP parser can handle, ie no fancy readermacros.

This setup works very well.  I had some problems with the sexp-parser
in PHP which didn't handle large result sets (> 8kb) well, which
of course I only found out after the system was in production, but it
was relatively easy to fix.  (It also turned out that returning all
that data was a waste, so I don't think I do that anymore, but it's
nice to know I can).

The sexp-parser in PHP is based on the one found in scheme.php by
Andrei Zmievski, part of PHP-GTK.  All in all, the PHP side of the
system is around 200 LOC, including whitespace and debugging aids.

The lisp side is somewhat complicated by multithreading, logging and
error handling.  That too is around 200 LOC all told.

...Peder...
-- 
It's not called hacking or trial and error!
It's called rapid prototyping and extreme programming.
  - Kristoffer Gleditsch
From: Alex Mizrahi
Subject: Re: PHP using Lisp to answer questions
Date: 
Message-ID: <43fb5fb4$0$15786$14726298@news.sunsite.dk>
(message (Hello 'Falazar)
(you :wrote  :on '(20 Feb 2006 08:40:26 -0800))
(

 F> Or is there an easier way / better way of doing this?

won't xml rpc help?

)
(With-best-regards '(Alex Mizrahi) :aka 'killer_storm)
"People who lust for the Feel of keys on their fingertips (c) Inity")