use of alice.tuprolog.SolveInfo in project Osmand by osmandapp.
the class AbstractPrologCommandPlayer method execute.
@Override
public List<String> execute(List<Struct> listCmd) {
Struct list = new Struct(listCmd.toArray(new Term[listCmd.size()]));
// $NON-NLS-1$
Var result = new Var("RESULT");
List<String> files = new ArrayList<String>();
if (prologSystem == null) {
return files;
}
if (log.isInfoEnabled()) {
log.info("Query speak files " + listCmd);
}
SolveInfo res = prologSystem.solve(new Struct(P_RESOLVE, list, result));
if (res.isSuccess()) {
try {
prologSystem.solveEnd();
Term solution = res.getVarValue(result.getName());
Iterator<?> listIterator = ((Struct) solution).listIterator();
while (listIterator.hasNext()) {
Object term = listIterator.next();
if (term instanceof Struct) {
files.add(((Struct) term).getName());
}
}
} catch (NoSolutionException e) {
}
}
if (log.isInfoEnabled()) {
log.info("Speak files " + files);
}
return files;
}
use of alice.tuprolog.SolveInfo in project Osmand by osmandapp.
the class AbstractPrologCommandPlayer method solveSimplePredicate.
protected Term solveSimplePredicate(String predicate) {
Term val = null;
// $NON-NLS-1$
Var v = new Var("MyVariable");
SolveInfo s = prologSystem.solve(new Struct(predicate, v));
if (s.isSuccess()) {
prologSystem.solveEnd();
try {
val = s.getVarValue(v.getName());
} catch (NoSolutionException e) {
}
}
return val;
}