1
나는 동물 식별 곰팡이와 유사한 전문가 시스템을 가지고있다. 이 프로그램은 프롤로그에서 독립적으로 실행할 수 있습니다. 이제 netbeans를 사용하여 Java 기반의 GUI를 구축하고 싶습니다. 파일을 참조하는 첫 번째 쿼리를 수행하는 방법을 알고 있습니다.프롤로그가 자바에 연결
private void startDiagnose(){
Term consult_arg[] = {
new Atom("C:/Users/Adrian/Desktop/WOU/wou.pl")
};
Query consult_query =
new Query(
"consult",
consult_arg);
boolean consulted = consult_query.query();
if (!consulted){
System.err.println("Consult failed");
System.exit(1);
}
하지만 두 번째 쿼리는 어떻게 수행 할 수 있습니까? "-? go." (프롤로그에서 "go."를 입력하면 사용자 질문을 묻는 메시지가 표시되고 다음 질문을 계속하려면 사용자 응답은 (Y/N)이어야합니다)
전문가 시스템의 소스 코드는
입니다./* wou.pro
wou intelligent ambassador.
start with ?- go. */
go:- hypothesize(Major),
write('The major I suggest you to choose is: ['),
write(Major),
write(']'),
nl,
undo.
/* hypotheses to be tested */
/* education*/
hypothesize(community_health_education) :- community_health_education, !.
hypothesize(school_health_education) :- school_health_education, !.
hypothesize(physical_education) :- physical_education, !.
hypothesize(special_education) :- special_education, !.
/*social science*/
hypothesize(history) :- history, !.
hypothesize(psychological_science) :- psychological_science, !.
hypothesize(anthropology) :- anthropology, !.
hypothesize(criminal_justice) :- criminal_justice, !.
hypothesize(environmental_studies) :- environmental_studies, !.
hypothesize(geography) :- geography, !.
hypothesize(political_science) :- political_science, !.
hypothesize(english) :- english, !.
/*engineering*/
hypothesize(cs) :- cs, !.
hypothesize(information_system) :-information_system, !.
/*science*/
hypothesize(mathematics) :- mathematics, !.
hypothesize(biology) :- biology, !.
hypothesize(chemistry) :- chemistry,!.
hypothesize(physics) :- physics, !.
hypothesize(nursing) :- nursing, !.
/*business*/
hypothesize(accounting) :- accounting, !.
hypothesize(economics) :- economics, !.
/*Art*/
hypothesize(painting) :- painting, !.
hypothesize(music) :- music, !.
hypothesize(dance) :- dance, !.
/*no major*/
hypothesize(no_major).
/* major identification rules */
community_health_education :- social,
education,
verify(working_for_a_community).
school_health_education :- social,
education,
verify(working_in_a_school).
physical_education :- social,
education,
verify(physical_training).
special_education :- social,
education,
verify(helping_special_population).
history :- social,
verify(antique),
verify(ancient_story).
psychological_science :- social,
verify(tv_show_lie_to_me).
anthropology :- social,
verify(studying_human_kind).
criminal_justice :- social,
verify(go_to_law_school).
environmental_studies :- social,
verify(environment_protection).
geography :- social,
verify(studying_the_earth).
political_science :- social,
verify(working_for_the_government).
english :- social,
verify(being_a_writer).
cs :- engineeringscience,
engineering,
verify(diy_desktop),
verify(coding).
information_system :- engineeringscience,
engineering,
verify(configuring_a_system).
mathematics :- engineeringscience,
verify(successione_di_fibonacci),
verify(solving_equations).
biology :- engineeringscience,
verify(origin_of_life),
verify(being_a_biologist).
chemistry :- engineeringscience,
verify(being_a_chemist).
physics :- engineeringscience,
verify(being_a_physicist).
nursing:- engineeringscience,
verify(being_a_nurse).
accounting :- business,
verify(using_excel),
verify(being_an_accountant),
verify(auditing).
economics :- business,
verify(monetary),
verify(being_an_ecomomist).
painting :- art,
verify(drawing).
music :- art,
verify(playing_instrucment).
dance :- art,
verify(opera),
verify(want_to_be_a_dancer).
/* classification rules */
social :- verify(reading_and_writing_editorial), !.
social :- verify(writing_more_than_mathematical_logic).
education :- verify(teaching_children),!.
education :- verify(being_a_high_school_teacher).
engineeringscience :- verify(quantitative_analysis), !.
engineeringscience :- verify(natural_phenomenon),
verify(discovery).
engineering :- engineeringscience,
verify(reparing_machine), !.
engineering :- engineeringscience,
verify(fixing_electronic_components),
verify(computer_games).
business :- verify(making_a_lot_of_money), !.
business :- verify(trading).
art :- verify(creative), !.
art :- verify(emotional).
/* how to ask questions */
ask(Question) :-
write('Do you like(or good at): '),
write(Question),
write('? (y/n)'),
read(Response),
nl,
((Response == yes ; Response == y)
->
assert(yes(Question)) ;
assert(no(Question)), fail).
:- dynamic yes/1,no/1.
/* How to verify something */
verify(S) :-
(yes(S)
->
true ;
(no(S)
->
fail ;
ask(S))).
/* undo all yes/no assertions */
undo :- retract(yes(_)),fail.
undo :- retract(no(_)),fail.
undo.