|
-
March 23rd, 2016, 01:47 PM
#1
pass parameters from java to prolog
I have the code below using swi Prolog and I made a interface using jframe in netbeans.
In this jframe I have textbox for answer and another textbox for grade.i want take answer from textbox and pass to start predicate in prolog to process answer. Can anyone tell me how I can do that? The only thing that I know is how to call predicate.
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.
-
March 24th, 2016, 07:43 PM
#2
Re: pass parameters from java to prolog
What is Prolog? Is it an external program? The Runtime/Process classes will interface with external programs.
Norm
-
March 27th, 2016, 06:27 AM
#3
Re: pass parameters from java to prolog
 Originally Posted by Norm
What is Prolog? Is it an external program? The Runtime/Process classes will interface with external programs.
Prolog is a general purpose logic programming language associated with artificial intelligence and computational linguistics.
-
March 27th, 2016, 06:31 AM
#4
Re: pass parameters from java to prolog
How is a prolog program executed? If by a command line, that commandline can be executed from java using the Runtime class's methods.
Norm
-
March 27th, 2016, 07:01 AM
#5
Re: pass parameters from java to prolog
 Originally Posted by Norm
How is a prolog program executed? If by a command line, that commandline can be executed from java using the Runtime class's methods.
yes it is executed by a command line. what are Runtime class's methods?
-
March 27th, 2016, 07:08 AM
#6
Re: pass parameters from java to prolog
Look at the API doc for the Runtime class to see its methods etc.
http://docs.oracle.com/javase/8/docs/api/index.html
Find Runtime in the list on the lower left, click on it and its doc will show in main window.
Norm
-
March 27th, 2016, 11:29 AM
#7
Re: pass parameters from java to prolog
 Originally Posted by Norm
I read the methods.They are not benefit in this work because I use jpl to call process.i need to find out how to take answer from textbox and pass to prolog?
-
March 27th, 2016, 11:59 AM
#8
Re: pass parameters from java to prolog
how to take answer from textbox and pass to prolog?
Is the textbox a java JTextField or JTextArea component shown in a java GUI?
If not, how are you planning to use java for this problem?
I have never heard of jpl. Is it part of java SE?
Norm
-
March 27th, 2016, 12:33 PM
#9
Re: pass parameters from java to prolog
 Originally Posted by Norm
Is the textbox a java JTextField or JTextArea component shown in a java GUI?
If not, how are you planning to use java for this problem?
I have never heard of jpl. Is it part of java SE?
yes,JTextArea component shown in a java GUI.
jpl is library in java.like this import org.jpl7.*;
-
March 27th, 2016, 12:41 PM
#10
Re: pass parameters from java to prolog
Ok, please explain your problem now.
Is this what you are trying to do:
have a text area where the user can enter some data. The program can take that data and format a command line and call the prolog program with the Runtime class's methods and retrieve the response from prolog and display it in a text area.
If you have a question about jpl, you should ask it on a jpl forum. jpl is not part of standard java.
Norm
-
March 27th, 2016, 12:48 PM
#11
Re: pass parameters from java to prolog
 Originally Posted by Norm
Ok, please explain your problem now.
Is this what you are trying to do:
have a text area where the user can enter some data. The program can take that data and format a command line and call the prolog program with the Runtime class's methods and retrieve the response from prolog and display it in a text area.
yes this is my problem.how to do this?
-
March 27th, 2016, 01:10 PM
#12
Re: pass parameters from java to prolog
Something like this:
When the user enters the data and presses a button, get the data, format it for the command line, use the Runtime class's methods to call prolog. Where does prolog put its results? If it writes it to the console, use the Process class's methods to read what was written to the console and put it in the text area for the user to see.
Norm
-
March 27th, 2016, 01:19 PM
#13
Re: pass parameters from java to prolog
 Originally Posted by Norm
Something like this:
When the user enters the data and presses a button, get the data, format it for the command line, use the Runtime class's methods to call prolog. Where does prolog put its results? If it writes it to the console, use the Process class's methods to read what was written to the console and put it in the text area for the user to see.
what are exactly Runtime class's methods to call prolog and also to read what was written to the console and put it in the text area for the user to see?
-
March 27th, 2016, 01:26 PM
#14
Re: pass parameters from java to prolog
See the API doc for the Runtime class for a description of its methods.
The exec method returns a Process class object that has methods for accessing what the called program writes to the console.
Norm
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|