expert system java interface write

438 views
Skip to first unread message

cosm...@gmail.com

unread,
Jun 6, 2014, 7:09:10 PM6/6/14
to swi-p...@googlegroups.com

I am trying to create an interface for an expert system. I am using jpl and I want to know if there is a way to get in java what you "write" in Prolog.

I understand that if you want to query you just use
 Query q = new Query(myQuery);
q.hasSolution(); // this actually calls that query in prolog

What if in Prolog I have:
pred(N) :- write(N),read(P).

Is there a posibility to get in java the N written by the Prolog predicate with "write" and after that to send through java what the prolog "read" is expecting???


I pretty much have the same issue like this:

Torbjörn Lager

unread,
Jun 7, 2014, 2:31:05 AM6/7/14
to cosm...@gmail.com, swi-p...@googlegroups.com
Hi,

I don't know about Java, but if you just need a GUI for you expert
system, and is willing to write it in HTML, CSS and JavaScript, you
may be able to use Pengines. The support for reading and writing is
there. Check out

http://pengines.swi-prolog.org

Use the Scratchpad and select Expert system from the Examples menu for
a simple demo.

Hope this helps.

Best regards,
Torbjörn
> --
> You received this message because you are subscribed to the Google Groups
> "SWI-Prolog" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to swi-prolog+...@googlegroups.com.
> Visit this group at http://groups.google.com/group/swi-prolog.
> For more options, visit https://groups.google.com/d/optout.



--
Torbjörn Lager
Professor of General and Computational Linguistics
Department of Philosophy, Linguistics and Theory of Science
University of Gothenburg
Box 200, SE-405 30 Gothenburg, Sweden
Phone: +46317864962

Torbjörn Lager

unread,
Jun 7, 2014, 3:00:39 AM6/7/14
to cosm...@gmail.com, swi-p...@googlegroups.com
If you insist on using Java you may be able to port the Pengines
JavaScript client to Java. It's less that 100 lines, and can be found
here:

http://pengines.swi-prolog.org/pengine/pengines.js

Best,
Torbjörn

Paul Singleton

unread,
Jun 7, 2014, 7:52:32 AM6/7/14
to swi-p...@googlegroups.com
Are you building a web app, a desktop app, or are you still free to choose?

Are you already committed to using Java?

If your expert system already has a rudimentary text UI, and you want to wrap this, catching its textual output and faking its textual input, then don't use JPL (it wasn't designed to help with this, and doesn't).

If your ES cleanly separates its text UI from its functionality with an API, then you could discard the text UI and call the API from Java.

If your ES has read and write goals scattered throughout, you are probably stuck with using it as a black box.

If you want a web app, avoid using Java in the web browser; use JavaScript instead.

Tell us more, and you might get some unconditional advice ;-)

Paul Singleton

cosm...@gmail.com

unread,
Jun 7, 2014, 2:16:54 PM6/7/14
to swi-p...@googlegroups.com

I want to build a web app.
I haven't designed the GUI, I only have the shell. And the shell (in swi-prolog) is asking something (outputs with write) and it's reading the answer from the user with get0.

My problem is how can I send to the swi-prolog thru the interface what the user is answering. I mean where swi-prolog has get0 to read the answer, it should be a connection with the UI. (a connection with a textbox or something)

Torbjörn Lager

unread,
Jun 8, 2014, 5:30:34 AM6/8/14
to cosmin cosmin, swi-p...@googlegroups.com
The ES example I pointed at answers your question if you want to take
the Pengines route, doesn't it? There is no pengine_get0, but there is
a pengine_input/2 that takes a prompt (that can be any term) and
(usually) an unbound variable. The way you bind this variable from the
GUI is to use the JS function pengine.respond().

Regards,
Torbjörn
Reply all
Reply to author
Forward
0 new messages