SlideShare a Scribd company logo
1 of 6
HOW TO DEVELOP A NEW SERVICE USING THE
EXISTING SERVICE APIs
Three simple steps to develop your own sentiment analysis service using
our language resources and/or services:
1. Sign up on
the project
website
http://portal.eurosentiment.eu/accoun
ts/signin/
2. Obtain an
access token
e.g., 78cab860-d17d-4afa-b1ac-
d6ff84e942d7
3. Sign in with
your
credentials
Fill in a form with the
following fields:
 name
 surname
 e-mail
 type of user
 ...
List the available services and resources:
Resource: http://140.203.155.231:8890/sparql/{resource_id},
where “resource_id” is a code, e.g., c1eb1886-b3a1-4435-9284-fa1ecd9a8d55
Service: http://217.26.90.243:8080/EuroSentimentServices/services/server/access/{service_id},
where “service_id” is code, e.g., 11eb1886-b3a1-4435-9284-fa1ecd9a8d55
Note that all the HTTP methods are POST and all the input parameters are in JSON formats.
Click on the selected service that you want to use to see more info (for instance, input parameters).
e.g., {"input": “The hotel was fantastic. The restaurant was cheap and the room was comfortable."}
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.WebResource.Builder;
public class Services_Client {
public String postClient(String service, String req){
String results = "";
try {
Client client = Client.create();
WebResource webResource = client.resource(service);
Builder b = webResource.header("x-eurosentiment-token", "78cab860-d17d-4afa-b1ac-d6ff84e942d7");
ClientResponse response = b.post(ClientResponse.class, req);
results = response.getEntity(String.class);
} catch (Exception e) {
e.printStackTrace();
}
return results;
}
}
Consume an EUROSENTIMENT service via REST APIs
Suppose that we have chosen the S/E analyzer service from the previous list, which performs sentiment
and emotion analysis on a text. The service performs sentiment analysis with automatic language
detection (for English, Italian, German, Spanish, Catalan, Portuguese) and domain detection (e.g. for hotel
and electronics).
The following shows the Java code for implementing a simple REST client. In order to make a request to
EuroSentiment LRP, you must include a new HTTP header field, named x-eurosentiment-token, with the
value of your access-token (e.g., 78cab860-d17d-4afa-b1ac-d6ff84e942d7), as shown below.
Note: in the code above we use Jersey APIs: https://jersey.java.net/download.html
Use the created REST client
At this point, in the “main” class you have to put the text that you want to analyze, i.e., “The hotel was fantastic. The
restaurant was cheap and the room was comfortable”, in JSON format.
Input:
JSONObject j = new JSONObject();
j.put("input", "The hotel was fantastic. The restaurant was cheap and the room was comfortable");
Perform the request to the REST endpoint of the S/E analyzer service that has id, e.g., “sesse0328”.
Call:
String results = Client.postClient(http://217.26.90.243:8080/EuroSentimentServices/services/server/access/sesse0308, j.toString());
{
"@context": "http://eurosentiment.eu/contexts/basecontext.jsonld",
"dc:language": "en",
"domain": "es:Hotel",
"analysis": [ {
"@id":"ex:Analysis",
"@type": [
"marl:SentimentAnalysis",
"onyx:EmotionAnalysis" ],
"marl:minPolarityValue": 0,
"marl:maxPolarityValue": 100,
"onyx:usesEmotionModel": "es:EmotionModel" } ],
"entries": [ {
"nif:isString": "The hotel was fantastic",
"dc:language": "en",
"domain": "es:Hotel",
"opinions": [ {
"@id": "_:Opinion1",
"marl:hasPolarity": "marl:Positive",
"marl:PolarityValue":100,
"marl:describesObject":"hotel" } ],
"emotions": [ ],
"strings": [ {
"nif:anchorOf":"hotel",
"entities": [ "hotel" ] } ] },
The results of the request are shown in JSON and are ready to be used in every service that you will want to implement!
Output:
{
"nif:isString": " The restaurant was cheap and the room was comfortable",
"dc:language": "en",
"domain": "es:Hotel",
"opinions": [ {
"@id": "_:Opinion1",
"marl:hasPolarity": "marl:Positive",
"marl:PolarityValue": 100,
"marl:describesObject": "restaurant" },
{
"@id": "_:Opinion2",
"marl:hasPolarity": "marl:Positive",
"marl:PolarityValue": 100,
"marl:describesObject": "room" } ],
"emotions": [ ],
"strings": [ {
"nif:anchorOf": "restaurant",
"entities": [
"restaurant" ] },
{
"nif:anchorOf": "room",
"entities": [
"room" ] } ] } ]}
public void service_test(){
Services_Client client = new Services_Client();
JSONObject j = new JSONObject();
j.put("input","The hotel was fantastic. The restaurant was cheap and the room was comfortable!");
String results =
client.postClient(“http://217.26.90.243:8080/EuroSentimentServices/services/server/access/sesse0308",
j.toString());
}
Conclusions
The following code is the method resulting from the previous steps; a simple piece of Java code to
consume the S/E analyzer service. You can use this code for accessing every EuroSentiment service by
simply changing the id of the URL.
Now, you can create your own services, using the pre-existing services in the EuroSentiment Language
Resource Pool (LRP)!
Moreover, you can register your own services on the EuroSentiment LRP platform, to:
• Increase visibility and recognition of your services
• Increase ROI of your services
• Increase the value of your services

More Related Content

Similar to Eurosentiment - Developing a new service

Insight User Conference Bootcamp - Use the Engagement Tracking and Metrics A...
Insight User Conference Bootcamp - Use the Engagement Tracking  and Metrics A...Insight User Conference Bootcamp - Use the Engagement Tracking  and Metrics A...
Insight User Conference Bootcamp - Use the Engagement Tracking and Metrics A...SparkPost
 
SDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - JapanSDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - Japantristansokol
 
Evolve Your Schemas in a Better Way! A Deep Dive into Avro Schema Compatibili...
Evolve Your Schemas in a Better Way! A Deep Dive into Avro Schema Compatibili...Evolve Your Schemas in a Better Way! A Deep Dive into Avro Schema Compatibili...
Evolve Your Schemas in a Better Way! A Deep Dive into Avro Schema Compatibili...HostedbyConfluent
 
Novedades de la API - Leandro Bertalot
Novedades de la API - Leandro BertalotNovedades de la API - Leandro Bertalot
Novedades de la API - Leandro Bertalotfsolari
 
how to use openstack api
how to use openstack apihow to use openstack api
how to use openstack apiLiang Bo
 
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, EverAltitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, EverFastly
 
#CNX14 - Dive Deep into the ExactTarget Fuel APIs
#CNX14 - Dive Deep into the ExactTarget Fuel APIs#CNX14 - Dive Deep into the ExactTarget Fuel APIs
#CNX14 - Dive Deep into the ExactTarget Fuel APIsSalesforce Marketing Cloud
 
An introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMAn introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMontimesuite
 
AWS User Group Singapore / Amazon Lex -- JAWSDAYS 2017
AWS User Group Singapore / Amazon Lex -- JAWSDAYS 2017AWS User Group Singapore / Amazon Lex -- JAWSDAYS 2017
AWS User Group Singapore / Amazon Lex -- JAWSDAYS 2017Alex Smith
 
Discover Data That Matters- Deep dive into WSO2 Analytics
Discover Data That Matters- Deep dive into WSO2 AnalyticsDiscover Data That Matters- Deep dive into WSO2 Analytics
Discover Data That Matters- Deep dive into WSO2 AnalyticsSriskandarajah Suhothayan
 
Canopy unconference preso
Canopy unconference presoCanopy unconference preso
Canopy unconference presogregulator
 
Serious Sencha - Data Layer and Server-Side REST Interface
Serious Sencha - Data Layer and Server-Side REST InterfaceSerious Sencha - Data Layer and Server-Side REST Interface
Serious Sencha - Data Layer and Server-Side REST InterfaceKlaus Hofeditz
 
Tadhack madrid June 2014: Joris Swinnen and WebRTC Nederland "Invite my colle...
Tadhack madrid June 2014: Joris Swinnen and WebRTC Nederland "Invite my colle...Tadhack madrid June 2014: Joris Swinnen and WebRTC Nederland "Invite my colle...
Tadhack madrid June 2014: Joris Swinnen and WebRTC Nederland "Invite my colle...Bart Uelen
 
Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service
Araport Workshop Tutorial 2: Authentication and the Agave Profiles ServiceAraport Workshop Tutorial 2: Authentication and the Agave Profiles Service
Araport Workshop Tutorial 2: Authentication and the Agave Profiles Servicestevemock
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés RianchoCODE BLUE
 

Similar to Eurosentiment - Developing a new service (20)

SignalR
SignalRSignalR
SignalR
 
Insight User Conference Bootcamp - Use the Engagement Tracking and Metrics A...
Insight User Conference Bootcamp - Use the Engagement Tracking  and Metrics A...Insight User Conference Bootcamp - Use the Engagement Tracking  and Metrics A...
Insight User Conference Bootcamp - Use the Engagement Tracking and Metrics A...
 
SDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - JapanSDKs, the good the bad the ugly - Japan
SDKs, the good the bad the ugly - Japan
 
Evolve Your Schemas in a Better Way! A Deep Dive into Avro Schema Compatibili...
Evolve Your Schemas in a Better Way! A Deep Dive into Avro Schema Compatibili...Evolve Your Schemas in a Better Way! A Deep Dive into Avro Schema Compatibili...
Evolve Your Schemas in a Better Way! A Deep Dive into Avro Schema Compatibili...
 
Novedades de la API - Leandro Bertalot
Novedades de la API - Leandro BertalotNovedades de la API - Leandro Bertalot
Novedades de la API - Leandro Bertalot
 
how to use openstack api
how to use openstack apihow to use openstack api
how to use openstack api
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, EverAltitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
Altitude NY 2018: Leveraging Log Streaming to Build the Best Dashboards, Ever
 
#CNX14 - Dive Deep into the ExactTarget Fuel APIs
#CNX14 - Dive Deep into the ExactTarget Fuel APIs#CNX14 - Dive Deep into the ExactTarget Fuel APIs
#CNX14 - Dive Deep into the ExactTarget Fuel APIs
 
An introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBMAn introduction to the API for OnTime for IBM
An introduction to the API for OnTime for IBM
 
AWS User Group Singapore / Amazon Lex -- JAWSDAYS 2017
AWS User Group Singapore / Amazon Lex -- JAWSDAYS 2017AWS User Group Singapore / Amazon Lex -- JAWSDAYS 2017
AWS User Group Singapore / Amazon Lex -- JAWSDAYS 2017
 
Discover Data That Matters- Deep dive into WSO2 Analytics
Discover Data That Matters- Deep dive into WSO2 AnalyticsDiscover Data That Matters- Deep dive into WSO2 Analytics
Discover Data That Matters- Deep dive into WSO2 Analytics
 
Canopy unconference preso
Canopy unconference presoCanopy unconference preso
Canopy unconference preso
 
Life on Clouds: a forensics overview
Life on Clouds: a forensics overviewLife on Clouds: a forensics overview
Life on Clouds: a forensics overview
 
Serious Sencha - Data Layer and Server-Side REST Interface
Serious Sencha - Data Layer and Server-Side REST InterfaceSerious Sencha - Data Layer and Server-Side REST Interface
Serious Sencha - Data Layer and Server-Side REST Interface
 
Tadhack madrid June 2014: Joris Swinnen and WebRTC Nederland "Invite my colle...
Tadhack madrid June 2014: Joris Swinnen and WebRTC Nederland "Invite my colle...Tadhack madrid June 2014: Joris Swinnen and WebRTC Nederland "Invite my colle...
Tadhack madrid June 2014: Joris Swinnen and WebRTC Nederland "Invite my colle...
 
shiv_chandra_pathak
shiv_chandra_pathakshiv_chandra_pathak
shiv_chandra_pathak
 
Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service
Araport Workshop Tutorial 2: Authentication and the Agave Profiles ServiceAraport Workshop Tutorial 2: Authentication and the Agave Profiles Service
Araport Workshop Tutorial 2: Authentication and the Agave Profiles Service
 
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
[CB16] Esoteric Web Application Vulnerabilities by Andrés Riancho
 
OneTeam Media Server
OneTeam Media ServerOneTeam Media Server
OneTeam Media Server
 

Recently uploaded

WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Eraconfluent
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AIAGATSoftware
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Novo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNovo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNeo4j
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2
 

Recently uploaded (20)

WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & InnovationWSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
WSO2CON 2024 - OSU & WSO2: A Decade Journey in Integration & Innovation
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
BusinessGPT - Security and Governance for Generative AI
BusinessGPT  - Security and Governance for Generative AIBusinessGPT  - Security and Governance for Generative AI
BusinessGPT - Security and Governance for Generative AI
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Novo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMsNovo Nordisk: When Knowledge Graphs meet LLMs
Novo Nordisk: When Knowledge Graphs meet LLMs
 
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
WSO2CON 2024 - Unlocking the Identity: Embracing CIAM 2.0 for a Competitive A...
 
WSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital BusinessesWSO2CON 2024 - Software Engineering for Digital Businesses
WSO2CON 2024 - Software Engineering for Digital Businesses
 
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open SourceWSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
WSO2CON 2024 - Freedom First—Unleashing Developer Potential with Open Source
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in Uganda
 
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
WSO2Con2024 - Simplified Integration: Unveiling the Latest Features in WSO2 L...
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 

Eurosentiment - Developing a new service

  • 1. HOW TO DEVELOP A NEW SERVICE USING THE EXISTING SERVICE APIs
  • 2. Three simple steps to develop your own sentiment analysis service using our language resources and/or services: 1. Sign up on the project website http://portal.eurosentiment.eu/accoun ts/signin/ 2. Obtain an access token e.g., 78cab860-d17d-4afa-b1ac- d6ff84e942d7 3. Sign in with your credentials Fill in a form with the following fields:  name  surname  e-mail  type of user  ...
  • 3. List the available services and resources: Resource: http://140.203.155.231:8890/sparql/{resource_id}, where “resource_id” is a code, e.g., c1eb1886-b3a1-4435-9284-fa1ecd9a8d55 Service: http://217.26.90.243:8080/EuroSentimentServices/services/server/access/{service_id}, where “service_id” is code, e.g., 11eb1886-b3a1-4435-9284-fa1ecd9a8d55 Note that all the HTTP methods are POST and all the input parameters are in JSON formats. Click on the selected service that you want to use to see more info (for instance, input parameters). e.g., {"input": “The hotel was fantastic. The restaurant was cheap and the room was comfortable."}
  • 4. import com.sun.jersey.api.client.Client; import com.sun.jersey.api.client.ClientResponse; import com.sun.jersey.api.client.WebResource; import com.sun.jersey.api.client.WebResource.Builder; public class Services_Client { public String postClient(String service, String req){ String results = ""; try { Client client = Client.create(); WebResource webResource = client.resource(service); Builder b = webResource.header("x-eurosentiment-token", "78cab860-d17d-4afa-b1ac-d6ff84e942d7"); ClientResponse response = b.post(ClientResponse.class, req); results = response.getEntity(String.class); } catch (Exception e) { e.printStackTrace(); } return results; } } Consume an EUROSENTIMENT service via REST APIs Suppose that we have chosen the S/E analyzer service from the previous list, which performs sentiment and emotion analysis on a text. The service performs sentiment analysis with automatic language detection (for English, Italian, German, Spanish, Catalan, Portuguese) and domain detection (e.g. for hotel and electronics). The following shows the Java code for implementing a simple REST client. In order to make a request to EuroSentiment LRP, you must include a new HTTP header field, named x-eurosentiment-token, with the value of your access-token (e.g., 78cab860-d17d-4afa-b1ac-d6ff84e942d7), as shown below. Note: in the code above we use Jersey APIs: https://jersey.java.net/download.html
  • 5. Use the created REST client At this point, in the “main” class you have to put the text that you want to analyze, i.e., “The hotel was fantastic. The restaurant was cheap and the room was comfortable”, in JSON format. Input: JSONObject j = new JSONObject(); j.put("input", "The hotel was fantastic. The restaurant was cheap and the room was comfortable"); Perform the request to the REST endpoint of the S/E analyzer service that has id, e.g., “sesse0328”. Call: String results = Client.postClient(http://217.26.90.243:8080/EuroSentimentServices/services/server/access/sesse0308, j.toString()); { "@context": "http://eurosentiment.eu/contexts/basecontext.jsonld", "dc:language": "en", "domain": "es:Hotel", "analysis": [ { "@id":"ex:Analysis", "@type": [ "marl:SentimentAnalysis", "onyx:EmotionAnalysis" ], "marl:minPolarityValue": 0, "marl:maxPolarityValue": 100, "onyx:usesEmotionModel": "es:EmotionModel" } ], "entries": [ { "nif:isString": "The hotel was fantastic", "dc:language": "en", "domain": "es:Hotel", "opinions": [ { "@id": "_:Opinion1", "marl:hasPolarity": "marl:Positive", "marl:PolarityValue":100, "marl:describesObject":"hotel" } ], "emotions": [ ], "strings": [ { "nif:anchorOf":"hotel", "entities": [ "hotel" ] } ] }, The results of the request are shown in JSON and are ready to be used in every service that you will want to implement! Output: { "nif:isString": " The restaurant was cheap and the room was comfortable", "dc:language": "en", "domain": "es:Hotel", "opinions": [ { "@id": "_:Opinion1", "marl:hasPolarity": "marl:Positive", "marl:PolarityValue": 100, "marl:describesObject": "restaurant" }, { "@id": "_:Opinion2", "marl:hasPolarity": "marl:Positive", "marl:PolarityValue": 100, "marl:describesObject": "room" } ], "emotions": [ ], "strings": [ { "nif:anchorOf": "restaurant", "entities": [ "restaurant" ] }, { "nif:anchorOf": "room", "entities": [ "room" ] } ] } ]}
  • 6. public void service_test(){ Services_Client client = new Services_Client(); JSONObject j = new JSONObject(); j.put("input","The hotel was fantastic. The restaurant was cheap and the room was comfortable!"); String results = client.postClient(“http://217.26.90.243:8080/EuroSentimentServices/services/server/access/sesse0308", j.toString()); } Conclusions The following code is the method resulting from the previous steps; a simple piece of Java code to consume the S/E analyzer service. You can use this code for accessing every EuroSentiment service by simply changing the id of the URL. Now, you can create your own services, using the pre-existing services in the EuroSentiment Language Resource Pool (LRP)! Moreover, you can register your own services on the EuroSentiment LRP platform, to: • Increase visibility and recognition of your services • Increase ROI of your services • Increase the value of your services