Skip to content

Using Eurosentiment LRP resources.

Mario Muñoz edited this page Jun 26, 2014 · 9 revisions

Consuming an Eurosentiment language resource is quite similar to consuming a service. You will also need an authentication token and sending it within your request, although the implementation provided with this example takes care of it. For more information about using the authentication token, please review the token sections in Using Eurosentiment LRP services.

Consuming a language resource.

Within the sample provide, you only need to instantiate a samples/ResourceClient, passing the resource URL and your user token in the constructor, and then performs calls to its request method. You must pass instances of the NifInput class, and will receive NifOutput instances as a response (or an Exception if something goes wrong). You can check the details and the URLs of the available resources in the LRPMA.

Input for consuming resources contains a SparQL query for retrieving the specific resources subset. There are two kinds of predefined SparQL queries inside samples/SparqlQueryFactory. These included queries are built on execution time based on a provided language and domain.

NifInput and NifOutput are just wrappers for JSON data that must follow the NIF standard. An example of service call can be found in the samples/PositiveWordsMatcher.java class:

//...
this.resourceClient =  new ResourceClient(this.resourcesUrl, this.token);
//

//...
String query = SparqlQueryFactory.getSparql(SparqlQueryFactory.POSITIVE_ENTRIES, language, domainName);
NifInput input = new NifInput("{'query':'" + query + "', " +
                              "'format':'application/json'}");
NifOutput wordsResults = this.resourceClient.request(input);
//

Clone this wiki locally