我想通过JPL使用DCG语法获得prolog解决方案,其中一个存储在外部文件中,但是当我从类中调用方法getSolution
时,从prolog中获取异常:
org.jpl7.PrologException: PrologException: error(existence_error(procedure,
'/'(zdanie, 3)), context(':'(system, '/'('$c_call_prolog', 0)), _1))
Prolog课程:
package kck.project.Parser;
import org.jpl7.*;
import java.io.File;
import java.util.Map;
public class Prolog {
public Prolog() {
if (JPL.init()) {
Query q1 = new Query("consult('//files/students/s407201/my documents/kck-cp1250.pl').");
System.out.print(q1.hasSolution());
}
}
public String getSolution(String sentence) {
String sentenceToParse = sentence.replace(' ', ',');
Map<String, Term> solution = null;
Query q4 = new Query("zdanie(X,[" + sentenceToParse + "],[]).");
while (q4.hasMoreSolutions()) {
solution = q4.nextSolution();
}
return solution.get("X").toString();
}
}