anuzzolese / oke-challenge

19 stars 8 forks source link

Specs of the integration with GERBIL #27

Open giusepperizzo opened 9 years ago

giusepperizzo commented 9 years ago

hello, in the specs for the integration with GERBIL we noticed a couple of things we'd like to draw your attention on: 1) << curl -d "@smt" >> generates an error. Example: curl -H "Content-Type:application/x-turtle" -H "Accept:application/x-turtle" -d "@smt" http://nerd.eurecom.fr/api/adel Basically, the @ is a reserved character (curl expects a file name afterward) and it should be escaped; 2) the POST should be better specified, either as: a- form based "(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type application/x-www-form-urlencoded." which means the body content in the form key1=value1&key2=value2 b- multipart content-type multipart/mixed

Finally, just to avoid any potential issues when tested by GERBIL, would you mind to share the sample Java client that will trigger the queries toward the contending entries?

MichaelRoeder commented 9 years ago

Hi Guiseppe,

1) Yes, you are right and I am sorry, that the example caused this confusion. I encountered the same problem while typing the command. Because I did not know how this has to be escaped for cURL and I did not had the time to search for a solution, I added the comment, that this example won't work. It was just created to show how the body of the request (and the response) should look like. Sorry for this misunderstanding. Maybe there is someone who knows cURL better and could give a hint regarding the escaping?

If you want to test the communication between your system and GERBIL, I would recommend to use this GERBIL instance: http://139.18.2.164:1235/gerbil , since it has exactly the same version as the one that will be used for the challenge. Simply open the configuration page, choose the task, skip the "Annotator" drop down menu and add a name and the URL of your annotator into the two fields below. Press the "Add another annotator" button and wait while GERBIL tests the connection to your annotator by sending a simple request. After that you can choose one of the OKE example or GS sample datasets and start an experiment.

If your system is not callable from the online instance of GERBIL, you can checkout the OKEChallenge branch of the GERBIL project and test the communication locally. I can add a description of the steps you will have to take to get it running, if you want to test it that way.

2) This looks interesting. Where do you have found the definition of these two types of POST requests?

Here is the java code of the client:

        // create NIF document
        String nifDocument = nifCreator.getDocumentAsNIFString(document);
        HttpEntity entity = null;
        try {
            entity = new StringEntity(nifDocument, "UTF-8");
        } catch (UnsupportedEncodingException e) {
           ...
        }
        // send NIF document
        HttpPost request = new HttpPost(url);
        request.setEntity(entity);
        // will be application/x-turtle
        request.addHeader("Content-Type", nifCreator.getHttpContentType()); 
        // will be application/x-turtle
        request.addHeader("Accept", nifParser.getHttpContentType());

As you can see, the NIF data is added as a simple String and, thus, your system should be able to get it as a String.

We are using an apache HTTP client.

    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.3.5</version>

The complete code can be found here: https://github.com/AKSW/gerbil/blob/OKEChallenge/src/main/java/org/aksw/gerbil/annotator/impl/nif/NIFBasedAnnotatorWebservice.java

rtroncy commented 9 years ago

@MichaelRoeder You can escape the '@' sign by simply adding a backslash '\'. Therefore, your solutions are:

MichaelRoeder commented 9 years ago

Thank you for these helpful hints! :)

With this command, my local example is working:

curl -H "Content-Type:application/x-turtle" -H "Accept:application/x-turtle"
-d "<http://www.ontologydesignpatterns.org/data/oke-challenge/task-1/sentence-1#char=0,146>
              a                     <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#RFC5147String> , <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#String> , <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#Context> ;
              <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#beginIndex>        \"0\"^^<http://www.w3.org/2001/XMLSchema#nonNegativeInteger> ;
              <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#endIndex>          \"146\"^^<http://www.w3.org/2001/XMLSchema#nonNegativeInteger> ;
              <http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#isString>          \"Florence May Harding studied at a school in Sydney, and with Douglas Robert Dundas , but in effect had no formal training in either botany or art.\" ." 
http://your-systems-URL

Please note that you will have to remove the linebreaks from the command.

giusepperizzo commented 9 years ago

Thanks. Looking at the Java coding the curl should look like:

curl -i -X POST -H "Content-Type:application/x-turtle" -H "Accept:application/x-turtle" --data-binary @nif.ttl http://of/the/contending/entry

where in nif.ttl we can include the prefixes.

MichaelRoeder commented 9 years ago

Yes, this works and is more similar to the request created by GERBIL.

Thanks. I created a pull request containing the changes.