SlideShare a Scribd company logo
1 of 23
Download to read offline
Developing for the
Semantic Web
by Timea Turdean
21.11.2015
#devfest15
Vienna
SEMANTIC WEB
&
LINKED DATA
2 http://dbpedia.org/resource/Sir_Tim_Berners_Lee
Triple
http://example.org/myProject/Triple
the form of
subject–predicate–object
expressions
<?s ?p ?o>
World Wide Web Consortium
(w3.org)
English computer scientists
RDF
http://dbpedia.org/resource/Resource_Description_Framework
http://www.w3.
org/2004/02/skos/core#de
finition
http://www.w3.org/1999/02/22-rdf-
syntax-ns#type http://example.org/Timea-
Custom-
Scheme/contained_in
http://example.org/Timea-
Custom-
Scheme/knows_to_use
3
Place your screenshot here
4Web
Application
http://preview.poolparty.biz/sparqlingCocktails/cocktails
5FEATURES &
FUNCTIONALITY
● Tap into your Linked Data endpoint
● Query Linked Data
● Display your Linked Data
● Display OPEN Linked Data
● The power of Linked Data
● BONUS *An improved search
Tap into your
Linked Data
endpoint
▸ data contains:
6 ▸ data is available
through a
SPARQL
endpoint
Tap into your
Linked Data
endpoint
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.
org/2004/02/skos/core#Concept> .
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/2004/02/skos/core#prefLabel> "Brandy"@en .
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/2004/02/skos/core#altLabel> "Grape spirit"@en .
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/2004/02/skos/core#definition> "Brandy (from brandywine, derived from
Dutch brandewijnu2014"burnt wine") is a spirit produced by distilling wine. Brandy
generally contains 35u201360% alcohol by volume and is typically taken as an after-
dinner drink. Some brandies are aged in wooden casks, some are coloured with caramel
colouring to imitate the effect of aging, and some brandies are produced using a
combination of both aging and colouring."@en .
<http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83>
<http://www.w3.org/2004/02/skos/core#narrower> <http://vocabulary.semantic-web.
at/cocktails/16b625c5-3930-4cf8-a75b-b25e72f2bfb6> .
<http://vocabulary.semantic-web.at/cocktails/16b625c5-3930-4cf8-a75b-b25e72f2bfb6>
<http://www.w3.org/2004/02/skos/core#prefLabel> "Calvados"@en .
7
SPARQL
8 SELECT * WHERE
{
?s ?p ?o
}
SELECT * WHERE
{
?s ?p ?o
}
Query
Linked Data
▸ Give me all Alcoholic Beverages:
PREFIX skos:<http://www.w3.org/2004/02/skos/core#>
SELECT ?label WHERE {
<http://vocabulary.semantic-web.
at/cocktails/f3000285-36b0-4ffe-af90-
740c2dd8fff5> skos:narrower ?o .
?o skos:prefLabel ?label .
}
▸ Results:
"Brandy"@en
"Fortified wine"@en
"Gin"@en
"Liqueur"@en
"Rum"@en
"Schnapps"@en
"Tequila"@en
"Vodka"@en
"Whisky"@en
"Wine"@en
9
Tap into your
Linked Data
endpoint
public class SPARQLendpointConnection extends HttpClient {
URL sparqlEndpointURL = null;
NameValuePair queryParam = new NameValuePair( "query", "QUERY");
List<NameValuePair> urlParams = new ArrayList() ;
List<Header> headers = new ArrayList<>() ;
public SPARQLendpointConnection (URL sparqlEndpointURL) {
this.sparqlEndpointURL = sparqlEndpointURL ;
this.addQueryParameter( "query", "QUERY");
this .addQueryParameter( "content-type" , "application/json" );
super .getParams().setParameter( "http.protocol.version" , HttpVersion. HTTP_1_1);
super .getParams().setParameter( "http.protocol.content-charset" , "UTF-8");
}
public void addQueryParameter (String key , String value) {
if (value.equals( "QUERY")) {
this.queryParam = new NameValuePair(key , value);
} else {
this.urlParams.add(new NameValuePair(key , value));
}
} [...]
}
10
Display your
Linked Data
public class SPARQLendpointConnection extends HttpClient {
public TupleQueryResult runAndParseSelectQuery (String query) throws IOException {
InputStream in = null;
TupleQueryResult tqr = null;
try {
in = IOUtils. toInputStream(runSelectQuery(query)) ;
tqr = QueryResultIO. parse(in, TupleQueryResultFormat. JSON);
return tqr;
} catch (QueryResultParseException | TupleQueryResultHandlerException |
UnsupportedQueryResultFormatException ex) {
throw new IOException(ex) ;
} finally {
if (in != null) {
in.close() ;
}
}
}
}
11
Display your
Linked Data
public class SPARQLendpointConnection extends HttpClient {
public String runSelectQuery (String query) throws IOException {
PostMethod post = new PostMethod( this.sparqlEndpointURL .toString()) ;
NameValuePair[] params = this.urlParams.toArray(new NameValuePair[ this.urlParams.
size() + 1]);
params[(params. length - 1)] = new NameValuePair( queryParam .getName() , query);
post.setRequestBody(params) ;
for (Header h : this.headers) { post.addRequestHeader(h) ; }
int statusCode ;
String response ;
try {
statusCode = super.executeMethod(post) ;
response = post.getResponseBodyAsString() ;
if (statusCode != HttpStatus. SC_OK) {
System. out.println(statusCode) ;
}} finally {
post.releaseConnection() ;
}
return response;
}}
12
Tap into your
Linked Data
endpoint
import org.apache.commons.httpclient.* ;
import org.apache.commons.httpclient.methods.PostMethod ;
13
org.apache.commons.httpclient.jar
commons.io.jar
import org.apache.commons.io.IOUtils ;
sesame-query.jar
import org.openrdf.query.TupleQueryResult ;
import org.openrdf.query.TupleQueryResultHandlerException ;
sesame-queryresultio-api.jar; sesame-queryresultio-sparqljson.jar
import org.openrdf.query.resultio.QueryResultIO ;
import org.openrdf.query.resultio.QueryResultParseException ;
import org.openrdf.query.resultio.TupleQueryResultFormat ;
import org.openrdf.query.resultio.UnsupportedQueryResultFormatException ;
Display your
Linked Data
public void test() throws Exception {
String value = "";
SPARQLendpointConnection myConncetion = new SPARQLendpointConnection( new URL("http:
//vocabulary.semantic-web.at/PoolParty/sparql/cocktails" ));
TupleQueryResult tqr = myConnection.runAndParseSelectQuery(
"PREFIX skos:<http://www.w3.org/2004/02/skos/core#> n" +
"SELECT ?label WHERE { n" +
"<http://vocabulary.semantic-web.at/cocktails/f3000285-36b0-4ffe-af90-740c2dd8fff5>
skos:narrower ?p . n" +
"?p skos:prefLabel ?label n" +
"}");
BindingSet bs = null;
try {
while (tqr.hasNext()) {
bs = tqr.next() ;
value = bs.getValue( "label").toString() ;
System.out.println(bs.getValue( "label"));
}} finally {
tqr.close() ;
}}
14
Display your
Linked Data
"Brandy"@en
"Fortified wine"@en
"Gin"@en
"Liqueur"@en
"Rum"@en
"Schnapps"@en
"Tequila"@en
"Vodka"@en
"Whisky"@en
"Wine"@en
15 RESULTS
Display your
Linked Data
private ModelAndView mavChooseIngredients;
mavChooseIngredients = new ModelAndView( "cocktails/index" );
mavChooseIngredients .addObject( "myMenu", this.retrieveMainAlcoholicBeverages()) ;
[..]
public List<BindingSet> retrieveMainAlcoholicBeverages () throws
IOException , QueryEvaluationException {
return QueryResults. asList(myConnection .runAndParseSelectQuery(
"PREFIX skos:<http://www.w3.org/2004/02/skos/core#> n" +
"SELECT ?label WHERE { n" +
"<http://vocabulary.semantic-web.at/cocktails/f3000285-36b0-4ffe-af90-
740c2dd8fff5> skos:narrower ?p . n" +
"?p skos:prefLabel ?label n" +
"}"
));
}
16
Display your
Linked Data
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core " %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions " %>
[...]
<c:forEach items="${myMenu}" var="bindingSet ">
<li class="entity">
${bindingSet.getValue( 'label').stringValue() }
</li>
</c:forEach>
17 index.jsp
Display OPEN
Linked Data
DBpedia SPARQL endpoint:
▸ http://dbpedia.org/sparql
SELECT * WHERE {
<http://dbpedia.org/resource/Negroni>
<http://dbpedia.org/ontology/abstract>
?abstract
}
18
The POWER
of
Linked data
▸ easy change of data
▸ cost efficient
▸ graph algorithms
19
Place your screenshot here
20An improved SEARCH
Faceted search
http://preview.poolparty.biz/sparqlingCocktails/search
Thank you!
21
Connect
Timea Turdean
Technical Consultant, Semantic Web Company
▸ timea.turdean@gmail.com
▸ http://at.linkedin.com/in/timeaturdean
▸ http://timeaturdean.com
22
© Semantic Web Company - http://www.semantic-web.at/ and http://www.poolparty.biz/
▸ LD2014 picture slide3- http://data.dws.informatik.uni-
mannheim.de/lodcloud/2014/
▸ Linked Data principles: http://www.w3.
org/DesignIssues/LinkedData.html
▸ Introduction to Semantic Web: http://timeaturdean.
com/introduction-semantic-web/
23Resources

More Related Content

What's hot

Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...Red Hat Developers
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Andres Almiray
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Andres Almiray
 
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
FluentLeniumで困った話
FluentLeniumで困った話FluentLeniumで困った話
FluentLeniumで困った話Yuuki Ooguro
 
Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv IT Booze
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyAlessandro Cucci
 
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...탑크리에듀(구로디지털단지역3번출구 2분거리)
 
How to cheat jb detector and detect cheating
How to cheat jb detector and detect cheatingHow to cheat jb detector and detect cheating
How to cheat jb detector and detect cheatingHokila Jan
 
Test Driven Documentation with Spring Rest Docs
Test Driven Documentation with Spring Rest DocsTest Driven Documentation with Spring Rest Docs
Test Driven Documentation with Spring Rest DocsRoman Tsypuk
 
Functional tests with TYPO3
Functional tests with TYPO3Functional tests with TYPO3
Functional tests with TYPO3cpsitgmbh
 
Hypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTHypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTSofiia Vynnytska
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8WindowsPhoneRocks
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIRPeter Elst
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long jaxconf
 
Taking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingTaking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingJulien Pivotto
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to TestZsolt Fabok
 

What's hot (20)

Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
Jupyter Notebooks for machine learning on Kubernetes & OpenShift | DevNation ...
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
 
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
#11.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_국비지원학원,재직자/실업자교육학원,스프링교육,마이바...
 
VRaptor 4 - JavaOne
VRaptor 4 - JavaOneVRaptor 4 - JavaOne
VRaptor 4 - JavaOne
 
AssertJ quick introduction
AssertJ quick introductionAssertJ quick introduction
AssertJ quick introduction
 
FluentLeniumで困った話
FluentLeniumで困った話FluentLeniumで困った話
FluentLeniumで困った話
 
Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv Overview of Google spreadsheet API for Java by Nazar Kostiv
Overview of Google spreadsheet API for Java by Nazar Kostiv
 
Rest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemyRest API using Flask & SqlAlchemy
Rest API using Flask & SqlAlchemy
 
9.Spring DI_4
9.Spring DI_49.Spring DI_4
9.Spring DI_4
 
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
#29.스프링프레임워크 & 마이바티스 (Spring Framework, MyBatis)_스프링프레임워크 강좌, 재직자환급교육,실업자국비지원...
 
How to cheat jb detector and detect cheating
How to cheat jb detector and detect cheatingHow to cheat jb detector and detect cheating
How to cheat jb detector and detect cheating
 
Test Driven Documentation with Spring Rest Docs
Test Driven Documentation with Spring Rest DocsTest Driven Documentation with Spring Rest Docs
Test Driven Documentation with Spring Rest Docs
 
Functional tests with TYPO3
Functional tests with TYPO3Functional tests with TYPO3
Functional tests with TYPO3
 
Hypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data RESTHypermedia-driven Web Services with Spring Data REST
Hypermedia-driven Web Services with Spring Data REST
 
10 sharing files and data in windows phone 8
10   sharing files and data in windows phone 810   sharing files and data in windows phone 8
10 sharing files and data in windows phone 8
 
SQLite in Adobe AIR
SQLite in Adobe AIRSQLite in Adobe AIR
SQLite in Adobe AIR
 
Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long Multi Client Development with Spring - Josh Long
Multi Client Development with Spring - Josh Long
 
Taking advantage of Prometheus relabeling
Taking advantage of Prometheus relabelingTaking advantage of Prometheus relabeling
Taking advantage of Prometheus relabeling
 
[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test[xp2013] Narrow Down What to Test
[xp2013] Narrow Down What to Test
 

Viewers also liked

Intro to Semantic Web
Intro to Semantic WebIntro to Semantic Web
Intro to Semantic WebTimea Turdean
 
Overcoming impostor syndrome
Overcoming impostor syndromeOvercoming impostor syndrome
Overcoming impostor syndromeTimea Turdean
 
RDF Analytics... SPARQL and Beyond
RDF Analytics... SPARQL and BeyondRDF Analytics... SPARQL and Beyond
RDF Analytics... SPARQL and BeyondFadi Maali
 
Self-service Linked Government Data
Self-service Linked Government DataSelf-service Linked Government Data
Self-service Linked Government DataFadi Maali
 
Estimating value through the lens of cost of delay
Estimating value through the lens of cost of delayEstimating value through the lens of cost of delay
Estimating value through the lens of cost of delayagilebydesign
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Springsdeeg
 

Viewers also liked (7)

Intro to Semantic Web
Intro to Semantic WebIntro to Semantic Web
Intro to Semantic Web
 
Intro to AngularJS
Intro to AngularJSIntro to AngularJS
Intro to AngularJS
 
Overcoming impostor syndrome
Overcoming impostor syndromeOvercoming impostor syndrome
Overcoming impostor syndrome
 
RDF Analytics... SPARQL and Beyond
RDF Analytics... SPARQL and BeyondRDF Analytics... SPARQL and Beyond
RDF Analytics... SPARQL and Beyond
 
Self-service Linked Government Data
Self-service Linked Government DataSelf-service Linked Government Data
Self-service Linked Government Data
 
Estimating value through the lens of cost of delay
Estimating value through the lens of cost of delayEstimating value through the lens of cost of delay
Estimating value through the lens of cost of delay
 
Building a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / SpringBuilding a Secure App with Google Polymer and Java / Spring
Building a Secure App with Google Polymer and Java / Spring
 

Similar to SPARQLing cocktails

WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaKatrien Verbert
 
03 form-data
03 form-data03 form-data
03 form-datasnopteck
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web servicesnbuddharaju
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
SWT Lecture Session 4 - SW architectures and SPARQL
SWT Lecture Session 4 - SW architectures and SPARQLSWT Lecture Session 4 - SW architectures and SPARQL
SWT Lecture Session 4 - SW architectures and SPARQLMariano Rodriguez-Muro
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotationjavatwo2011
 
China Science Challenge
China Science ChallengeChina Science Challenge
China Science Challengeremko caprio
 
SgCodeJam24 Workshop
SgCodeJam24 WorkshopSgCodeJam24 Workshop
SgCodeJam24 Workshopremko caprio
 
JavaScript straight from the Oracle Database
JavaScript straight from the Oracle DatabaseJavaScript straight from the Oracle Database
JavaScript straight from the Oracle DatabaseDimitri Gielis
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jerseyb_kathir
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!DataArt
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Claire Townend Gee
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginsearchbox-com
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scalarostislav
 
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話Takehito Tanabe
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web developmentJohannes Brodwall
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauSpiffy
 

Similar to SPARQLing cocktails (20)

WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPedia
 
03 form-data
03 form-data03 form-data
03 form-data
 
4 sw architectures and sparql
4 sw architectures and sparql4 sw architectures and sparql
4 sw architectures and sparql
 
Overview of RESTful web services
Overview of RESTful web servicesOverview of RESTful web services
Overview of RESTful web services
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
URLProtocol
URLProtocolURLProtocol
URLProtocol
 
SWT Lecture Session 4 - SW architectures and SPARQL
SWT Lecture Session 4 - SW architectures and SPARQLSWT Lecture Session 4 - SW architectures and SPARQL
SWT Lecture Session 4 - SW architectures and SPARQL
 
比XML更好用的Java Annotation
比XML更好用的Java Annotation比XML更好用的Java Annotation
比XML更好用的Java Annotation
 
China Science Challenge
China Science ChallengeChina Science Challenge
China Science Challenge
 
SgCodeJam24 Workshop
SgCodeJam24 WorkshopSgCodeJam24 Workshop
SgCodeJam24 Workshop
 
JavaScript straight from the Oracle Database
JavaScript straight from the Oracle DatabaseJavaScript straight from the Oracle Database
JavaScript straight from the Oracle Database
 
Developing RESTful WebServices using Jersey
Developing RESTful WebServices using JerseyDeveloping RESTful WebServices using Jersey
Developing RESTful WebServices using Jersey
 
Тарас Олексин - Sculpt! Your! Tests!
Тарас Олексин  - Sculpt! Your! Tests!Тарас Олексин  - Sculpt! Your! Tests!
Тарас Олексин - Sculpt! Your! Tests!
 
Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0Swift LA Meetup at eHarmony- What's New in Swift 2.0
Swift LA Meetup at eHarmony- What's New in Swift 2.0
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Tutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component pluginTutorial on developing a Solr search component plugin
Tutorial on developing a Solr search component plugin
 
Summer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and ScalaSummer - The HTML5 Library for Java and Scala
Summer - The HTML5 Library for Java and Scala
 
XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話XamarinとAWSをつないでみた話
XamarinとAWSをつないでみた話
 
Bare-knuckle web development
Bare-knuckle web developmentBare-knuckle web development
Bare-knuckle web development
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 

Recently uploaded

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 

Recently uploaded (20)

Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 

SPARQLing cocktails

  • 1. Developing for the Semantic Web by Timea Turdean 21.11.2015 #devfest15 Vienna
  • 2. SEMANTIC WEB & LINKED DATA 2 http://dbpedia.org/resource/Sir_Tim_Berners_Lee Triple http://example.org/myProject/Triple the form of subject–predicate–object expressions <?s ?p ?o> World Wide Web Consortium (w3.org) English computer scientists RDF http://dbpedia.org/resource/Resource_Description_Framework http://www.w3. org/2004/02/skos/core#de finition http://www.w3.org/1999/02/22-rdf- syntax-ns#type http://example.org/Timea- Custom- Scheme/contained_in http://example.org/Timea- Custom- Scheme/knows_to_use
  • 3. 3
  • 4. Place your screenshot here 4Web Application http://preview.poolparty.biz/sparqlingCocktails/cocktails
  • 5. 5FEATURES & FUNCTIONALITY ● Tap into your Linked Data endpoint ● Query Linked Data ● Display your Linked Data ● Display OPEN Linked Data ● The power of Linked Data ● BONUS *An improved search
  • 6. Tap into your Linked Data endpoint ▸ data contains: 6 ▸ data is available through a SPARQL endpoint
  • 7. Tap into your Linked Data endpoint <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3. org/2004/02/skos/core#Concept> . <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/2004/02/skos/core#prefLabel> "Brandy"@en . <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/2004/02/skos/core#altLabel> "Grape spirit"@en . <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/2004/02/skos/core#definition> "Brandy (from brandywine, derived from Dutch brandewijnu2014"burnt wine") is a spirit produced by distilling wine. Brandy generally contains 35u201360% alcohol by volume and is typically taken as an after- dinner drink. Some brandies are aged in wooden casks, some are coloured with caramel colouring to imitate the effect of aging, and some brandies are produced using a combination of both aging and colouring."@en . <http://vocabulary.semantic-web.at/cocktails/8f09ee6f-d5b9-4b8a-aa17-b0665fae4e83> <http://www.w3.org/2004/02/skos/core#narrower> <http://vocabulary.semantic-web. at/cocktails/16b625c5-3930-4cf8-a75b-b25e72f2bfb6> . <http://vocabulary.semantic-web.at/cocktails/16b625c5-3930-4cf8-a75b-b25e72f2bfb6> <http://www.w3.org/2004/02/skos/core#prefLabel> "Calvados"@en . 7
  • 8. SPARQL 8 SELECT * WHERE { ?s ?p ?o } SELECT * WHERE { ?s ?p ?o }
  • 9. Query Linked Data ▸ Give me all Alcoholic Beverages: PREFIX skos:<http://www.w3.org/2004/02/skos/core#> SELECT ?label WHERE { <http://vocabulary.semantic-web. at/cocktails/f3000285-36b0-4ffe-af90- 740c2dd8fff5> skos:narrower ?o . ?o skos:prefLabel ?label . } ▸ Results: "Brandy"@en "Fortified wine"@en "Gin"@en "Liqueur"@en "Rum"@en "Schnapps"@en "Tequila"@en "Vodka"@en "Whisky"@en "Wine"@en 9
  • 10. Tap into your Linked Data endpoint public class SPARQLendpointConnection extends HttpClient { URL sparqlEndpointURL = null; NameValuePair queryParam = new NameValuePair( "query", "QUERY"); List<NameValuePair> urlParams = new ArrayList() ; List<Header> headers = new ArrayList<>() ; public SPARQLendpointConnection (URL sparqlEndpointURL) { this.sparqlEndpointURL = sparqlEndpointURL ; this.addQueryParameter( "query", "QUERY"); this .addQueryParameter( "content-type" , "application/json" ); super .getParams().setParameter( "http.protocol.version" , HttpVersion. HTTP_1_1); super .getParams().setParameter( "http.protocol.content-charset" , "UTF-8"); } public void addQueryParameter (String key , String value) { if (value.equals( "QUERY")) { this.queryParam = new NameValuePair(key , value); } else { this.urlParams.add(new NameValuePair(key , value)); } } [...] } 10
  • 11. Display your Linked Data public class SPARQLendpointConnection extends HttpClient { public TupleQueryResult runAndParseSelectQuery (String query) throws IOException { InputStream in = null; TupleQueryResult tqr = null; try { in = IOUtils. toInputStream(runSelectQuery(query)) ; tqr = QueryResultIO. parse(in, TupleQueryResultFormat. JSON); return tqr; } catch (QueryResultParseException | TupleQueryResultHandlerException | UnsupportedQueryResultFormatException ex) { throw new IOException(ex) ; } finally { if (in != null) { in.close() ; } } } } 11
  • 12. Display your Linked Data public class SPARQLendpointConnection extends HttpClient { public String runSelectQuery (String query) throws IOException { PostMethod post = new PostMethod( this.sparqlEndpointURL .toString()) ; NameValuePair[] params = this.urlParams.toArray(new NameValuePair[ this.urlParams. size() + 1]); params[(params. length - 1)] = new NameValuePair( queryParam .getName() , query); post.setRequestBody(params) ; for (Header h : this.headers) { post.addRequestHeader(h) ; } int statusCode ; String response ; try { statusCode = super.executeMethod(post) ; response = post.getResponseBodyAsString() ; if (statusCode != HttpStatus. SC_OK) { System. out.println(statusCode) ; }} finally { post.releaseConnection() ; } return response; }} 12
  • 13. Tap into your Linked Data endpoint import org.apache.commons.httpclient.* ; import org.apache.commons.httpclient.methods.PostMethod ; 13 org.apache.commons.httpclient.jar commons.io.jar import org.apache.commons.io.IOUtils ; sesame-query.jar import org.openrdf.query.TupleQueryResult ; import org.openrdf.query.TupleQueryResultHandlerException ; sesame-queryresultio-api.jar; sesame-queryresultio-sparqljson.jar import org.openrdf.query.resultio.QueryResultIO ; import org.openrdf.query.resultio.QueryResultParseException ; import org.openrdf.query.resultio.TupleQueryResultFormat ; import org.openrdf.query.resultio.UnsupportedQueryResultFormatException ;
  • 14. Display your Linked Data public void test() throws Exception { String value = ""; SPARQLendpointConnection myConncetion = new SPARQLendpointConnection( new URL("http: //vocabulary.semantic-web.at/PoolParty/sparql/cocktails" )); TupleQueryResult tqr = myConnection.runAndParseSelectQuery( "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> n" + "SELECT ?label WHERE { n" + "<http://vocabulary.semantic-web.at/cocktails/f3000285-36b0-4ffe-af90-740c2dd8fff5> skos:narrower ?p . n" + "?p skos:prefLabel ?label n" + "}"); BindingSet bs = null; try { while (tqr.hasNext()) { bs = tqr.next() ; value = bs.getValue( "label").toString() ; System.out.println(bs.getValue( "label")); }} finally { tqr.close() ; }} 14
  • 15. Display your Linked Data "Brandy"@en "Fortified wine"@en "Gin"@en "Liqueur"@en "Rum"@en "Schnapps"@en "Tequila"@en "Vodka"@en "Whisky"@en "Wine"@en 15 RESULTS
  • 16. Display your Linked Data private ModelAndView mavChooseIngredients; mavChooseIngredients = new ModelAndView( "cocktails/index" ); mavChooseIngredients .addObject( "myMenu", this.retrieveMainAlcoholicBeverages()) ; [..] public List<BindingSet> retrieveMainAlcoholicBeverages () throws IOException , QueryEvaluationException { return QueryResults. asList(myConnection .runAndParseSelectQuery( "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> n" + "SELECT ?label WHERE { n" + "<http://vocabulary.semantic-web.at/cocktails/f3000285-36b0-4ffe-af90- 740c2dd8fff5> skos:narrower ?p . n" + "?p skos:prefLabel ?label n" + "}" )); } 16
  • 17. Display your Linked Data <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core " %> <%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions " %> [...] <c:forEach items="${myMenu}" var="bindingSet "> <li class="entity"> ${bindingSet.getValue( 'label').stringValue() } </li> </c:forEach> 17 index.jsp
  • 18. Display OPEN Linked Data DBpedia SPARQL endpoint: ▸ http://dbpedia.org/sparql SELECT * WHERE { <http://dbpedia.org/resource/Negroni> <http://dbpedia.org/ontology/abstract> ?abstract } 18
  • 19. The POWER of Linked data ▸ easy change of data ▸ cost efficient ▸ graph algorithms 19
  • 20. Place your screenshot here 20An improved SEARCH Faceted search http://preview.poolparty.biz/sparqlingCocktails/search
  • 22. Connect Timea Turdean Technical Consultant, Semantic Web Company ▸ timea.turdean@gmail.com ▸ http://at.linkedin.com/in/timeaturdean ▸ http://timeaturdean.com 22 © Semantic Web Company - http://www.semantic-web.at/ and http://www.poolparty.biz/
  • 23. ▸ LD2014 picture slide3- http://data.dws.informatik.uni- mannheim.de/lodcloud/2014/ ▸ Linked Data principles: http://www.w3. org/DesignIssues/LinkedData.html ▸ Introduction to Semantic Web: http://timeaturdean. com/introduction-semantic-web/ 23Resources