0

I have a prolog file (Expert System) that I consult from Java using Jpl libraries (org.jpl7.*) and I have an UI using jframe where I want to show the output of prolog's queries.when consult prolog file in netbeans,read() predicate runs in console java;i want run in jtextarea in interface.Can anyone tell me how I can do that?

In this UI I have jtextarea for answer and another jtextarea for grade. This is prolog code using swi prolog:

start(Answer,Total_grade):-
Question1  = "Define computer?",
Word_list1 = ["software","operatingsystem"],
Word_list2 = ["hardware","tools"],
Msg = "Write your answers ",
write(Question1),nl,
write(Msg),nl,nl,
read(Answer),
string_lower(Answer,Low_answer),
split_string(Low_answer," ,.()-_"," ,.()-_", Answer_in_list),
find(Answer_in_list,Word_list1,Grade1),
find(Answer_in_list,Word_list2,Grade2),
Total_grade is Grade1 + Grade2,
nl,write("Your grade is : "), write(Total_grade),nl.

This is netbeans code:

String t1="consult('C:/Users/user/Desktop/prolog/s.pl')";
Query q1=new Query(t1);
Boolean t=q1.hasSolution(); 
String c1="start(Answer,Total_grade)";
Query c=new Query(c1);
Term f2=c.oneSolution().get("Total_grade");
String b2=f2.toString();
jTextArea2.setText(b2);
student
  • 41
  • 1
  • 5
  • I'm having trouble understanding what you want to do, could you try to be a little more clear what your intended purpose is? Are you simply trying to convert code from prolog code to java code, or are you trying to make a java program that works with a prolog program? – Gordon Allocman Mar 30 '16 at 19:38
  • yes, I used java to make the interface for prolog. I wrote prolog code and designed interface using netbeans.This netbeans code used jpl library to call prolog code in interface but when call prolog runs as input stream in netbeans. – student Mar 30 '16 at 19:49
  • please somebody help me! – student Apr 02 '16 at 13:50

0 Answers0