我下載了tuprolog,我無法獲得以下查詢的結果,而我在PROL ide中得到答案..有人可以幫忙嗎?在tuProlog中執行查詢時出錯
verb(admit-1).
verb(work-4).
nsubjpass(admit-1, patient-2).
agent(admit-1, doctor-3).
nsubj(work-4, who-5).
aux(work-4, be-6).
rcmod(doctor-3, work-4).
prep_in(work-4, clinic-7).
aggregation('part of').
aggregation('belongs to').
aggregation('subdivision of').
aggregation('have').
aggregation('contain').
aggregation('comprise').
aggregation('include').
aggregation('define').
aggregation('consist of').
aggregation('compose of').
aggregation('denote by').
aggregation('identify by').
aggregation('make up of').
aggregation('record with').
attribute('have').
attribute('contain').
attribute('comprise').
attribute('include').
attribute('define').
attribute('consist of').
attribute('compose of').
attribute('denote by').
attribute('identify by').
attribute('make up of').
attribute('record with').
generalization('be').
generalization('kind of').
generalization('type of').
generalization('classify into').
generalization('consider').
object(X) :- noun(X).
relation(X) :- verb(X).
rel(X,Y) :- nsubjpass(X,Y).
rel(X,Y) :- agent(X,Y).
rel(X,Y) :- nsubj(X,Y).
rel(X,Y) :- aux(X,Y).
rel(X,Y) :- rcmod(X,Y).
rel(X,Y) :- prep_in(X,Y).
associatedWith(X,Y) :- rel(X,Y).
associatedWith(X,Y,Z) :- verb(Y),associatedWith(X,Y), associatedWith(Y,Z).
associatedWith(X,Y,Z) :- verb(X),associatedWith(X,Y), associatedWith(X,Z).
rel_aggregation(X,Y,R):-rel(X,Y).aggregation(R).
?- associatedWith(X,Y,Z).
我需要處理這些類型的關係,並得到輸出在Java中再次處理
誰能告訴我如何整合序言和Java?
編輯: 我通過實現代碼
這個代碼適用於associatedWith(X,Y)得到這個錯誤tuprolog。即有2個參數,但不起作用,當我給與3關聯與(X,Y,Z)。做什麼..請幫助我得到這個例外
java.lang.ClassCastException: alice.tuprolog.Var cannot be cast to alice.tuprolog.Struct
at alice.tuprolog.lib.BasicLibrary.agent_2(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at alice.tuprolog.PrimitiveInfo.evalAsPredicate(Unknown Source)
at alice.tuprolog.StateGoalEvaluation.doJob(Unknown Source)
at alice.tuprolog.Engine.run(Unknown Source)
at alice.tuprolog.EngineManager.solve(Unknown Source)
at alice.tuprolog.Prolog.solve(Unknown Source)
at javaapplication9.Main.main(Main.java:26)
Exception in thread "main" alice.tuprolog.NoSolutionException
at alice.tuprolog.SolveInfo.getSolution(Unknown Source)
at javaapplication9.Main.main(Main.java:28)
Java Result: 1
此代碼適用於associatedWith(X,Y)。即有2個參數,但不起作用,當我給與3關聯與(X,Y,Z)。該怎麼辦..請幫助 – karthi 2010-09-18 13:31:04
已在我的主要問題中添加了例外..請說說做 – karthi 2010-09-18 13:39:28