tags:

views:

30

answers:

0

Hi,

I've got this in a Prolog file:

:- module(test,[main/0, api_trial/2]
:- use_module(library(prologbeans)).

main:-
  register_query(assert_trial(Age,Res), api_trial(Age,Res)),
  start.

person('John',10,'London').
person('Adam',10,'Manchester').

api_trial(Age,Res) :-
    findall((P,Age,Add),person(P,Age,Add),Res).

In Java, I do the following query (after importing the correct classes etc):

  public void trial() {
    try{
      Bindings bindings = new Bindings().bind("Age",10);
      QueryAnswer answer = session.executeQuery("assert_trial(Age,Res)", bindings);
      Term result = answer.getValue("Res");
      System.out.println("Answer returned " + result);
    } catch (IOException e) {
      e.printStackTrace();
    } catch (IllegalCharacterSetException e) {
      e.printStackTrace();
   }
}

Basically, my problem is that the format it returns the query in Java. In Prolog, it's normal:

Res = [('John',10,'London'),('Adam',10,'Manchester')] ?

In Java, I get:

Answer returned [,(John,,(10,London)),,(Adam,,(10,Manchester))]

The formatting is messed up. How can I overcome this problem? Any help would be much appreciated.

Thanks.