-
Notifications
You must be signed in to change notification settings - Fork 0
Using Eurosentiment LRP resources.
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.
Within the sample provide, you only need to instantiate a lib.clients.ResourceClient
, passing the resource URL and your user token in the constructor, and then performs calls to its request method. You must pass a dictionary with NIF format, and will receive another dictionary (also NIF) 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 lib/sparql_queries
. These included queries are built at runtime based on a provided language and domain.
An example of resource call can be found in the lib/positive_words_matcher.rb
class:
#...
@resource_client = ResourceClient.new(RESOURCES_URL, TOKEN)
#...
#...
query = sparql(POSITIVE_ENTRIES, language, domain)
input = {"query"=> query,
"format"=> "application/json"}
resources_result = @resource_client.request(input)
#...