SlideShare una empresa de Scribd logo
1 de 61
Challenges and applications of
RDF Shapes
About me…
HTML version: http://book.validatingrdf.com
Examples: https://github.com/labra/validatingRDFBookExamples
Contents
RDF Data Model
<http://example.com/alice> <http://schema.org/enrolledIn> <http://example.com/cs101> .
N-Triples representation
:alice :cs101
subject
schema:enrolledIn
predicate
object
http://example.com/alice http://example.com/cs101
http://schema.org/enrolledIn
RDF Graph
Basic statement = a simple triple
RDF Graph
…we can add more statements
:alice
23
Circled nodes are IRIs
Yellow boxes are literals
RDF Graph
RDF Graph
RDF Graph
RDF Graph
…and automatically merged
RDF helps information integration
RDF syntaxes
<http://example.org/alice> <http://example.org/name> "Alice" .
<http://example.org/alice> <http://example.org/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer> .
<http://example.org/alice> <http://example.org/enrolledIn> <http://example.org/cs101> .
<http://example.org/alice> <http://example.org/knows> <http://example.org/carol> .
<http://example.org/alice> <http://example.org/birthPlace> <http://example.org/Oviedo> .
<http://example.org/bob> <http://example.org/name> "Robert" .
<http://example.org/bob> <http://example.org/age> "None" .
<http://example.org/bob> <http://example.org/birthPlace> <http://example.org/Oviedo> .
<http://example.org/bob> <http://example.org/enrolledIn> <http://example.org/cs102> .
<http://example.org/carol> <http://example.org/name> "Carol" .
<http://example.org/carol> <http://example.org/enrolledIn> <http://example.org/cs101> .
<http://example.org/cs101> <http://example.org/subject> "Programming" .
<http://example.org/cs101> <http://example.org/students> <http://example.org/alice> .
<http://example.org/cs101> <http://example.org/students> <http://example.org/carol> .
<http://example.org/cs102> <http://example.org/subject> "Algebra" .
<http://example.org/cs102> <http://example.org/students> <http://example.org/bob> .
Turtle Syntax
;
,
prefix : <http://example.org/>
:alice :name "Alice" ;
:age 23 ;
:enrolledIn :cs101 ;
:knows :carol ;
:birthPlace :Oviedo .
:carol :name "Carol" ;
:enrolledIn :cs101 .
:cs101 :students :alice , :carol ;
:subject "Programming" .
:bob :name "Robert" ;
:age "None" ;
:enrolledIn :cs102 ;
:birthPlace :Oviedo .
:cs102 :students :bob ;
:subject "Algebra" . Try it: https://goo.gl/pK3Csh
Literals
:bob :name "Robert"^^xsd:string ;
:age "18"^^xsd:integer ;
:birthDate "2010-04-12"^^xsd:date .
:bob :name "Robert" ;
:age 18 ;
:birthDate "2010-04-12"^^xsd:date .
Bob knows someone whose age is 23
=
 x(:bob :knows x  x :age 23)
Blank nodes
:bob :knows _:1 .
_:1 :age 23 .
:bob :knows [
:age 23
] .
or
Language tagged strings
rdfs:langString
:spain rdfs:label "Spain"@en ;
rdfs:label "España"@es .
...and that's all?
RDF, the good parts...
RDF, the other parts
Producer Consumer
Why describe & validate RDF?
Producer Consumer
Shapes
Similar technologies
Technology Schema
Relational
Databases
DDL
XML DTD, XML Schema,
RelaxNG, Schematron
Json Json Schema
RDF ?
Fill that gap
Shapes vs Ontology
Ontology
Shapes
RDF Validation
Constraints
Instance data
Different levels
:alice rdf:type foaf:Person, schema:Person ;
:hasParent :bob .
:bob rdf:type foaf:Person ;
:gender :male .
:Person { rdf:type [ foaf:Person ] ;
:hasParent @:Person AND { :gender :male } ? ;
:hasParent @:Person AND { :gender :female } ?
}
:Person  rdf:type(foaf:Person) 
= 1 :hasParent :Male 
= 1 :hasParent :Female
Why not using SPARQL to validate?
ASK {{ SELECT ?Person {
?Person schema:name ?o .
} GROUP BY ?Person HAVING (COUNT(*)=1)
}
{ SELECT ?Person {
?Person schema:name ?o .
FILTER ( isLiteral(?o) &&
datatype(?o) = xsd:string )
} GROUP BY ?Person HAVING (COUNT(*)=1)
}
{ SELECT ?Person (COUNT(*) AS ?c1) {
?Person schema:gender ?o .
} GROUP BY ?Person HAVING (COUNT(*)=1)}
{ SELECT ?Person (COUNT(*) AS ?c2) {
?S schema:gender ?o .
FILTER ((?o = schema:Female ||
?o = schema:Male))
} GROUP BY ?Person HAVING (COUNT(*)=1)}
FILTER (?c1 = ?c2)
}
Example: Define SPARQL query to check:
There must be one schema:name which
must be a xsd:string, and one
schema:gender which must be
schema:Male or schema:Female
ShEx and SHACL
Short intro to ShEx
http://shex.io
http://shex.io/shex-semantics/ http://shex.io/shex-primer
ShEx implementations and
playgrounds
shex.js
SHaclEX
PyShEx
shex-java
Ruby-ShEx
Online demos &
playgrounds
ShEx-simple
RDFShape
ShEx-Java
ShExValidata
Wikishape
Simple example
<User>
schema:name xsd:string
schema:knows
prefix schema: <http://schema.org/>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
<User> IRI {
schema:name xsd:string ;
schema:knows @<User> *
}
Prefix declarations
as in
Turtle/SPARQL
RDF Validation using ShEx
:alice schema:name "Alice" ;
schema:knows :alice .
:bob schema:knows :alice ;
schema:name "Robert".
:carol schema:name "Carol", "Carole" .
:dave schema:name 234 .
:emily foaf:name "Emily" .
:frank schema:name "Frank" ;
schema:email <mailto:frank@example.org> ;
schema:knows :alice, :bob .
:grace schema:name "Grace" ;
schema:knows :alice, _:1 .
_:1 schema:name "Unknown" .
Try it (RDFShape): https://goo.gl/97bYdv
Try it (ShExDemo):https://goo.gl/Y8hBsW
Schema
Data
<User> IRI {
schema:name xsd:string ;
schema:knows @<User> *
}
:alice@<User>,
:bob @<User>,
:carol@<User>,
:dave @<User>,
:emily@<User>,
:frank@<User>,
:grace@<User>
Shape map







Validation process
:alice@:User, :bob@:User, :carol@:User
ShEx
Validator
Result shape map
:User {
schema:name xsd:string ;
schema:knows @:User *
}
ShEx Schema
:alice schema:name "Alice" ;
schema:knows :alice .
:bob schema:knows :alice ;
schema:name "Robert".
:carol schema:name "Carol", "Carole" .
RDF data
Shape map :alice@:User,
:bob@:User,
:carol@!:User
Input: RDF data, ShEx schema, Shape map
Output: Result shape map
Example with more ShEx features
:AdultPerson EXTRA rdf:type {
rdf:type [ schema:Person ] ;
:name xsd:string ;
:age MinInclusive 18 ;
:gender [:Male :Female] OR xsd:string ;
:address @:Address ? ;
:worksFor @:Company + ;
}
:Address CLOSED {
:addressLine xsd:string {1,3} ;
:postalCode /[0-9]{5}/ ;
:state @:State ;
:city xsd:string
}
:Company {
:name xsd:string ;
:state @:State ;
:employee @:AdultPerson * ;
}
:State /[A-Z]{2}/
:alice rdf:type :Student, schema:Person ;
:name "Alice" ;
:age 20 ;
:gender :Male ;
:address [
:addressLine "Bancroft Way" ;
:city "Berkeley" ;
:postalCode "55123" ;
:state "CA"
] ;
:worksFor [
:name "Company" ;
:state "CA" ;
:employee :alice
] . Try it: https://tinyurl.com/yd5hp9z4
SHACL
https://www.w3.org/TR/shacl/ (July 2017)
SHACL implementations
Name Parts Language -
Library
Comments
Topbraid SHACL API SHACL Core, SPARQL Java (Jena) Used by TopBraid composer
SHACL playground SHACL Core Javascript (rdflib.js) http://shacl.org/playground/
SHACLEX SHACL Core Scala (Jena, RDF4j) http://rdfshape.weso.es
pySHACL SHACL Core, SPARQL Python (rdflib) https://github.com/RDFLib/pySHAC
L
Corese SHACL SHACL Core, SPARQL Java (STTL) http://wimmics.inria.fr/corese
RDFUnit SHACL Core, SPARQL Java (Jena) https://github.com/AKSW/RDFUnit
Basic example
prefix : <http://example.org/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix schema: <http://schema.org/>
:UserShape a sh:NodeShape ;
sh:targetNode :alice, :bob, :carol ;
sh:nodeKind sh:IRI ;
sh:property :hasName,
:hasEmail .
:hasName sh:path schema:name ;
sh:minCount 1;
sh:maxCount 1;
sh:datatype xsd:string .
:hasEmail sh:path schema:email ;
sh:minCount 1;
sh:maxCount 1;
sh:nodeKind sh:IRI .
:alice schema:name "Alice Cooper" ;
schema:email <mailto:alice@mail.org> .
:bob schema:firstName "Bob" ;
schema:email <mailto:bob@mail.org> .
:carol schema:name "Carol" ;
schema:email "carol@mail.org" .
Shapes graph
Data graph


Try it. RDFShape https://goo.gl/ukY5vq
Same example with blank nodes
prefix : <http://example.org/>
prefix sh: <http://www.w3.org/ns/shacl#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix schema: <http://schema.org/>
:UserShape a sh:NodeShape ;
sh:targetNode :alice, :bob, :carol ;
sh:nodeKind sh:IRI ;
sh:property [
sh:path schema:name ;
sh:minCount 1; sh:maxCount 1;
sh:datatype xsd:string ;
] ;
sh:property [
sh:path schema:email ;
sh:minCount 1; sh:maxCount 1;
sh:nodeKind sh:IRI ;
] .
:alice schema:name "Alice Cooper" ;
schema:email <mailto:alice@mail.org> .
:bob schema:firstName "Bob" ;
schema:email <mailto:bob@mail.org> .
:carol schema:name "Carol" ;
schema:email "carol@mail.org" .
Shapes graph
Data graph


Try it. RDFShape https://goo.gl/ukY5vq
Some definitions about SHACL
Shape
target declarations
constraint components
:UserShape a sh:NodeShape ;
sh:targetNode :alice, :bob, :carol ;
sh:nodeKind sh:IRI ;
sh:property :hasName,
:hasEmail .
:hasName sh:path schema:name ;
sh:minCount 1;
sh:maxCount 1;
sh:datatype xsd:string .
. . .
Validation Report
[ a sh:ValidationReport ;
sh:conforms false ;
sh:result [
a sh:ValidationResult ;
sh:focusNode :bob ;
sh:message
"MinCount violation. Expected 1, obtained: 0" ;
sh:resultPath schema:name ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent
sh:MinCountConstraintComponent ;
sh:sourceShape :hasName
] ;
...
[ a sh:ValidationReport ;
sh:conforms true
].
SHACL processor
SHACL
Processor
Validation report
:UserShape a sh:NodeShape ;
sh:targetNode :alice, :bob, :carol ;
sh:nodeKind sh:IRI ;
sh:property :hasName,
:hasEmail .
:hasName sh:path schema:name ;
sh:minCount 1;
sh:maxCount 1;
sh:datatype xsd:string .
. . .
Shapes
graph
:alice schema:name "Alice Cooper" ;
schema:email <mailto:alice@mail.org>.
:bob schema:name "Bob" ;
schema:email <mailto:bob@mail.org> .
:carol schema:name "Carol" ;
schema:email <mailto:carol@mail.org> .
Data
Graph
[ a sh:ValidationReport ;
sh:conforms true
].
Longer example
:AdultPerson EXTRA a {
a [ schema:Person ] ;
:name xsd:string ;
:age MinInclusive 18 ;
:gender [:Male :Female] OR xsd:string ;
:address @:Address ? ;
:worksFor @:Company + ;
}
:Address CLOSED {
:addressLine xsd:string {1,3} ;
:postalCode /[0-9]{5}/ ;
:state @:State ;
:city xsd:string
}
:Company {
:name xsd:string ;
:state @:State ;
:employee @:AdultPerson * ;
}
:State /[A-Z]{2}/
:AdultPerson a sh:NodeShape ;
sh:property [
sh:path rdf:type ;
sh:qualifiedValueShape [
sh:hasValue schema:Person
];
sh:qualifiedMinCount 1 ;
sh:qualifiedMaxCount 1 ;
] ;
sh:targetNode :alice ;
sh:property [ sh:path :name ;
sh:minCount 1; sh:maxCount 1;
sh:datatype xsd:string ;
] ;
sh:property [ sh:path :gender ;
sh:minCount 1; sh:maxCount 1;
sh:in (:Male :Female);
] ;
sh:property [ sh:path :age ;
sh:maxCount 1;
sh:minInclusive 18
] ;
sh:property [ sh:path :address ;
sh:node :Address ;
sh:minCount 1 ; sh:maxCount 1
] ;
sh:property [ sh:path :worksFor ;
sh:node :Company ;
sh:minCount 1 ; sh:maxCount 1
].
:Address a sh:NodeShape ;
sh:closed true ;
sh:property [ sh:path :addressLine;
sh:datatype xsd:string ;
sh:minCount 1 ; sh:maxCount 3
] ;
sh:property [ sh:path :postalCode ;
sh:pattern "[0-9]{5}" ;
sh:minCount 1 ; sh:maxCount 3
] ;
sh:property [ sh:path :city ;
sh:datatype xsd:string ;
sh:minCount 1 ; sh:maxCount 1
] ;
sh:property [ sh:path :state ;
sh:node :State ;
] .
:Company a sh:NodeShape ;
sh:property [ sh:path :name ;
sh:datatype xsd:string
] ;
sh:property [
sh:path :state ;
sh:node :State
] ;
sh:property [ sh:path :employee ;
sh:node :AdultPerson ;
] ;.
:State a sh:NodeShape ;
sh:pattern "[A-Z]{2}" .
In ShEx
In SHACL
Its recursive!!! (not well defined SHACL)
Implementation dependent feature
Try it: https://tinyurl.com/ycl3mkzr
ShEx and SHACL compared
ShEx and SHACL compared
ShEx SHACL
Underlying philosophy Structure definition Constraint checking
Syntax Compact syntax + RDF RDF
Notion of shape Only structure Structure + target decls.
Default cardinalities {1,1} {0,*}
Shapes and inference No SHACL specific entailment
Recursion Part of the language Undefined
Repeated properties Part of the language Conjunction by default
Requires qualifiedValueShapes
Property paths Nested shapes SPARQL like
Property pair comparisons Unsupported in current version Part of the language
Extension mechanism Semantic actions SHACL-SPARQL
Validation triggering Query shape map Target declarations
Result of validation Result shape map Validation report
Shapes applications and challenges
Theoretical foundations of ShEx/SHACL
Shapes Shapes
ShEx SHACL
Generating Shapes from Data
Try it with RDFShape:
https://tinyurl.com/y8pjcbyf
Shape Expression
generated for
wd:Q51613194
Shapes
RDF data
infer
Validation usability
Shapes
RDF Stream validation
Sensor
Stream
RDF
data
Shapes
Validator
Stream
Validation
results
Ontological infrastructure
https://github.com/geneontology/go-shapes/
Control version
system (git)
Continuous
Integration
server
Ontological
infrastructure
Ontology
engineer
Triple
Store
Endpoint
SPARQL
Ontology
publication
system
Shapes library
Ontologies
Test data
Programming with shapes
Semantic architecture Ontological infrastructure
UML
Diagrams
Shapes
library
Domain
model Syncrhonization
Schema ecosystems: Wikidata
https://www.wikidata.org/wiki/EntitySchema:E2
Schema ecosystems: Solid project
Data
pod
Shape
A
Shape
C
Shape
B
App
1
App
2
App
3
"...I just can’t stop thinking about shapes.", Ruben Verborgh
https://ruben.verborgh.org/blog/2019/06/17/shaping-linked-data-apps/
Shapes ecosystem @ WESO
Producer Consumer
Shapes
Shapes ecosystem @ WESO
http://github.com/weso
Dependency map between
repositories
Data validation
RDF validation
Generic schemas: ShEx/SHACL
Converter ShEx  SHACL
RDF data validation with Shapes
https://typelevel.org/cats/
Edit/create shapes
Shapes editor
Syntax highlighting, autocomplete, etc.
Shapes playgrounds
http://rdfshape.weso.es
http://wikishape.weso.es
https://tinyurl.com/shqrban
Extract/generate shapes
http://shexer.weso.es/
Shapes visualization
Shapes programming
Code generation
from Shapes
ShEx  POJO (Java)
Shape
A
Shape
C
Shape
B
Data/schema conversions
Conclusions
Challenges and applications of RDF shapes

Más contenido relacionado

La actualidad más candente

2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
Josef Petrák
 

La actualidad más candente (20)

SHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data MudSHACL: Shaping the Big Ball of Data Mud
SHACL: Shaping the Big Ball of Data Mud
 
Two graph data models : RDF and Property Graphs
Two graph data models : RDF and Property GraphsTwo graph data models : RDF and Property Graphs
Two graph data models : RDF and Property Graphs
 
RDF Validation Future work and applications
RDF Validation Future work and applicationsRDF Validation Future work and applications
RDF Validation Future work and applications
 
SHACL Overview
SHACL OverviewSHACL Overview
SHACL Overview
 
Towards an RDF Validation Language based on Regular Expression Derivatives
Towards an RDF Validation Language based on Regular Expression DerivativesTowards an RDF Validation Language based on Regular Expression Derivatives
Towards an RDF Validation Language based on Regular Expression Derivatives
 
SPIN in Five Slides
SPIN in Five SlidesSPIN in Five Slides
SPIN in Five Slides
 
RDF data validation 2017 SHACL
RDF data validation 2017 SHACLRDF data validation 2017 SHACL
RDF data validation 2017 SHACL
 
RDF, linked data and semantic web
RDF, linked data and semantic webRDF, linked data and semantic web
RDF, linked data and semantic web
 
SHACL in Apache jena - ApacheCon2020
SHACL in Apache jena - ApacheCon2020SHACL in Apache jena - ApacheCon2020
SHACL in Apache jena - ApacheCon2020
 
Graph Data -- RDF and Property Graphs
Graph Data -- RDF and Property GraphsGraph Data -- RDF and Property Graphs
Graph Data -- RDF and Property Graphs
 
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
2011 4IZ440 Semantic Web – RDF, SPARQL, and software APIs
 
Shape Expressions: An RDF validation and transformation language
Shape Expressions: An RDF validation and transformation languageShape Expressions: An RDF validation and transformation language
Shape Expressions: An RDF validation and transformation language
 
SHACL Specification Draft
SHACL Specification DraftSHACL Specification Draft
SHACL Specification Draft
 
4 sw architectures and sparql
4 sw architectures and sparql4 sw architectures and sparql
4 sw architectures and sparql
 
RDF Tutorial - SPARQL 20091031
RDF Tutorial - SPARQL 20091031RDF Tutorial - SPARQL 20091031
RDF Tutorial - SPARQL 20091031
 
RDF SHACL, Annotations, and Data Frames
RDF SHACL, Annotations, and Data FramesRDF SHACL, Annotations, and Data Frames
RDF SHACL, Annotations, and Data Frames
 
What's New in RDF 1.1?
What's New in RDF 1.1?What's New in RDF 1.1?
What's New in RDF 1.1?
 
SWT Lecture Session 3 - SPARQL
SWT Lecture Session 3 - SPARQLSWT Lecture Session 3 - SPARQL
SWT Lecture Session 3 - SPARQL
 
SWT Lecture Session 2 - RDF
SWT Lecture Session 2 - RDFSWT Lecture Session 2 - RDF
SWT Lecture Session 2 - RDF
 
Semantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorialSemantic web meetup – sparql tutorial
Semantic web meetup – sparql tutorial
 

Similar a Challenges and applications of RDF shapes

Similar a Challenges and applications of RDF shapes (20)

Part04_SHACL By Example presentation.pptx
Part04_SHACL By Example presentation.pptxPart04_SHACL By Example presentation.pptx
Part04_SHACL By Example presentation.pptx
 
Creating Web APIs with JSON-LD and RDF
Creating Web APIs with JSON-LD and RDFCreating Web APIs with JSON-LD and RDF
Creating Web APIs with JSON-LD and RDF
 
Graph and RDF databases
Graph and RDF databasesGraph and RDF databases
Graph and RDF databases
 
2016-02 Graphs - PG+RDF
2016-02 Graphs - PG+RDF2016-02 Graphs - PG+RDF
2016-02 Graphs - PG+RDF
 
HyperGraphQL
HyperGraphQLHyperGraphQL
HyperGraphQL
 
Graph databases & data integration v2
Graph databases & data integration v2Graph databases & data integration v2
Graph databases & data integration v2
 
Sparql a simple knowledge query
Sparql  a simple knowledge querySparql  a simple knowledge query
Sparql a simple knowledge query
 
Optimizing SPARQL Queries with SHACL.pdf
Optimizing SPARQL Queries with SHACL.pdfOptimizing SPARQL Queries with SHACL.pdf
Optimizing SPARQL Queries with SHACL.pdf
 
NoSQL and Triple Stores
NoSQL and Triple StoresNoSQL and Triple Stores
NoSQL and Triple Stores
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Sparql service-description
Sparql service-descriptionSparql service-description
Sparql service-description
 
From SQL to SPARQL
From SQL to SPARQLFrom SQL to SPARQL
From SQL to SPARQL
 
Self-Enforcing Access Control for Encrypted RDF
Self-Enforcing Access Control for Encrypted RDFSelf-Enforcing Access Control for Encrypted RDF
Self-Enforcing Access Control for Encrypted RDF
 
What’s in a structured value?
What’s in a structured value?What’s in a structured value?
What’s in a structured value?
 
Semantic Web(Web 3.0) SPARQL
Semantic Web(Web 3.0) SPARQLSemantic Web(Web 3.0) SPARQL
Semantic Web(Web 3.0) SPARQL
 
Introduction to RDF Data Model
Introduction to RDF Data ModelIntroduction to RDF Data Model
Introduction to RDF Data Model
 
Semantic Web introduction
Semantic Web introductionSemantic Web introduction
Semantic Web introduction
 
Transforming Your Data with GraphDB: GraphDB Fundamentals, Jan 2018
Transforming Your Data with GraphDB: GraphDB Fundamentals, Jan 2018Transforming Your Data with GraphDB: GraphDB Fundamentals, Jan 2018
Transforming Your Data with GraphDB: GraphDB Fundamentals, Jan 2018
 
SWT Lecture Session 10 R2RML Part 1
SWT Lecture Session 10 R2RML Part 1SWT Lecture Session 10 R2RML Part 1
SWT Lecture Session 10 R2RML Part 1
 
A Little SPARQL in your Analytics
A Little SPARQL in your AnalyticsA Little SPARQL in your Analytics
A Little SPARQL in your Analytics
 

Más de Jose Emilio Labra Gayo

Más de Jose Emilio Labra Gayo (20)

Publicaciones de investigación
Publicaciones de investigaciónPublicaciones de investigación
Publicaciones de investigación
 
Introducción a la investigación/doctorado
Introducción a la investigación/doctoradoIntroducción a la investigación/doctorado
Introducción a la investigación/doctorado
 
Legislative data portals and linked data quality
Legislative data portals and linked data qualityLegislative data portals and linked data quality
Legislative data portals and linked data quality
 
Wikidata
WikidataWikidata
Wikidata
 
Legislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologiesLegislative document content extraction based on Semantic Web technologies
Legislative document content extraction based on Semantic Web technologies
 
Introducción a la Web Semántica
Introducción a la Web SemánticaIntroducción a la Web Semántica
Introducción a la Web Semántica
 
2017 Tendencias en informática
2017 Tendencias en informática2017 Tendencias en informática
2017 Tendencias en informática
 
19 javascript servidor
19 javascript servidor19 javascript servidor
19 javascript servidor
 
Como publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazadosComo publicar datos: hacia los datos abiertos enlazados
Como publicar datos: hacia los datos abiertos enlazados
 
16 Alternativas XML
16 Alternativas XML16 Alternativas XML
16 Alternativas XML
 
XSLT
XSLTXSLT
XSLT
 
XPath
XPathXPath
XPath
 
Arquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el ServidorArquitectura de la Web y Computación en el Servidor
Arquitectura de la Web y Computación en el Servidor
 
RDF data model
RDF data modelRDF data model
RDF data model
 
Máster en Ingeniería Web
Máster en Ingeniería WebMáster en Ingeniería Web
Máster en Ingeniería Web
 
2016 temuco tecnologias_websemantica
2016 temuco tecnologias_websemantica2016 temuco tecnologias_websemantica
2016 temuco tecnologias_websemantica
 
2015 bogota datos_enlazados
2015 bogota datos_enlazados2015 bogota datos_enlazados
2015 bogota datos_enlazados
 
17 computacion servidor
17 computacion servidor17 computacion servidor
17 computacion servidor
 
Tecnologias Web Semantica
Tecnologias Web SemanticaTecnologias Web Semantica
Tecnologias Web Semantica
 
6 Principios de Programación Orientada a Objetos
6 Principios de Programación Orientada a Objetos6 Principios de Programación Orientada a Objetos
6 Principios de Programación Orientada a Objetos
 

Último

₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
Diya Sharma
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
shivangimorya083
 
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
anilsa9823
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Sheetaleventcompany
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
soniya singh
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
ellan12
 

Último (20)

Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...Pune Airport ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready...
Pune Airport ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready...
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night StandHot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
Hot Call Girls |Delhi |Hauz Khas ☎ 9711199171 Book Your One night Stand
 
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
WhatsApp 📞 8448380779 ✅Call Girls In Mamura Sector 66 ( Noida)
 
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
INDIVIDUAL ASSIGNMENT #3 CBG, PRESENTATION.
 
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Rohini 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)How is AI changing journalism? (v. April 2024)
How is AI changing journalism? (v. April 2024)
 
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Lucknow Lucknow best sexual service Online
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
Call Girls Service Chandigarh Lucky ❤️ 7710465962 Independent Call Girls In C...
 
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
Call Girls In Pratap Nagar Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl ServiceRussian Call girl in Ajman +971563133746 Ajman Call girl Service
Russian Call girl in Ajman +971563133746 Ajman Call girl Service
 
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call GirlVIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
VIP 7001035870 Find & Meet Hyderabad Call Girls LB Nagar high-profile Call Girl
 
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...Nanded City ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready ...
Nanded City ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready ...
 
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptxAWS Community DAY Albertini-Ellan Cloud Security (1).pptx
AWS Community DAY Albertini-Ellan Cloud Security (1).pptx
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service AvailableCall Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
Call Girls Ludhiana Just Call 98765-12871 Top Class Call Girl Service Available
 
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
DDoS In Oceania and the Pacific, presented by Dave Phelan at NZNOG 2024
 

Challenges and applications of RDF shapes

  • 2. About me… HTML version: http://book.validatingrdf.com Examples: https://github.com/labra/validatingRDFBookExamples
  • 4. RDF Data Model <http://example.com/alice> <http://schema.org/enrolledIn> <http://example.com/cs101> . N-Triples representation :alice :cs101 subject schema:enrolledIn predicate object http://example.com/alice http://example.com/cs101 http://schema.org/enrolledIn
  • 5. RDF Graph Basic statement = a simple triple
  • 6. RDF Graph …we can add more statements :alice 23 Circled nodes are IRIs Yellow boxes are literals
  • 10. RDF Graph …and automatically merged RDF helps information integration
  • 11. RDF syntaxes <http://example.org/alice> <http://example.org/name> "Alice" . <http://example.org/alice> <http://example.org/age> "23"^^<http://www.w3.org/2001/XMLSchema#integer> . <http://example.org/alice> <http://example.org/enrolledIn> <http://example.org/cs101> . <http://example.org/alice> <http://example.org/knows> <http://example.org/carol> . <http://example.org/alice> <http://example.org/birthPlace> <http://example.org/Oviedo> . <http://example.org/bob> <http://example.org/name> "Robert" . <http://example.org/bob> <http://example.org/age> "None" . <http://example.org/bob> <http://example.org/birthPlace> <http://example.org/Oviedo> . <http://example.org/bob> <http://example.org/enrolledIn> <http://example.org/cs102> . <http://example.org/carol> <http://example.org/name> "Carol" . <http://example.org/carol> <http://example.org/enrolledIn> <http://example.org/cs101> . <http://example.org/cs101> <http://example.org/subject> "Programming" . <http://example.org/cs101> <http://example.org/students> <http://example.org/alice> . <http://example.org/cs101> <http://example.org/students> <http://example.org/carol> . <http://example.org/cs102> <http://example.org/subject> "Algebra" . <http://example.org/cs102> <http://example.org/students> <http://example.org/bob> .
  • 12. Turtle Syntax ; , prefix : <http://example.org/> :alice :name "Alice" ; :age 23 ; :enrolledIn :cs101 ; :knows :carol ; :birthPlace :Oviedo . :carol :name "Carol" ; :enrolledIn :cs101 . :cs101 :students :alice , :carol ; :subject "Programming" . :bob :name "Robert" ; :age "None" ; :enrolledIn :cs102 ; :birthPlace :Oviedo . :cs102 :students :bob ; :subject "Algebra" . Try it: https://goo.gl/pK3Csh
  • 13. Literals :bob :name "Robert"^^xsd:string ; :age "18"^^xsd:integer ; :birthDate "2010-04-12"^^xsd:date . :bob :name "Robert" ; :age 18 ; :birthDate "2010-04-12"^^xsd:date .
  • 14. Bob knows someone whose age is 23 =  x(:bob :knows x  x :age 23) Blank nodes :bob :knows _:1 . _:1 :age 23 . :bob :knows [ :age 23 ] . or
  • 15. Language tagged strings rdfs:langString :spain rdfs:label "Spain"@en ; rdfs:label "España"@es .
  • 17. RDF, the good parts...
  • 18. RDF, the other parts Producer Consumer
  • 19. Why describe & validate RDF? Producer Consumer Shapes
  • 20. Similar technologies Technology Schema Relational Databases DDL XML DTD, XML Schema, RelaxNG, Schematron Json Json Schema RDF ? Fill that gap
  • 21. Shapes vs Ontology Ontology Shapes RDF Validation Constraints Instance data Different levels :alice rdf:type foaf:Person, schema:Person ; :hasParent :bob . :bob rdf:type foaf:Person ; :gender :male . :Person { rdf:type [ foaf:Person ] ; :hasParent @:Person AND { :gender :male } ? ; :hasParent @:Person AND { :gender :female } ? } :Person  rdf:type(foaf:Person)  = 1 :hasParent :Male  = 1 :hasParent :Female
  • 22. Why not using SPARQL to validate? ASK {{ SELECT ?Person { ?Person schema:name ?o . } GROUP BY ?Person HAVING (COUNT(*)=1) } { SELECT ?Person { ?Person schema:name ?o . FILTER ( isLiteral(?o) && datatype(?o) = xsd:string ) } GROUP BY ?Person HAVING (COUNT(*)=1) } { SELECT ?Person (COUNT(*) AS ?c1) { ?Person schema:gender ?o . } GROUP BY ?Person HAVING (COUNT(*)=1)} { SELECT ?Person (COUNT(*) AS ?c2) { ?S schema:gender ?o . FILTER ((?o = schema:Female || ?o = schema:Male)) } GROUP BY ?Person HAVING (COUNT(*)=1)} FILTER (?c1 = ?c2) } Example: Define SPARQL query to check: There must be one schema:name which must be a xsd:string, and one schema:gender which must be schema:Male or schema:Female
  • 24. Short intro to ShEx http://shex.io http://shex.io/shex-semantics/ http://shex.io/shex-primer
  • 25. ShEx implementations and playgrounds shex.js SHaclEX PyShEx shex-java Ruby-ShEx Online demos & playgrounds ShEx-simple RDFShape ShEx-Java ShExValidata Wikishape
  • 26. Simple example <User> schema:name xsd:string schema:knows prefix schema: <http://schema.org/> prefix xsd: <http://www.w3.org/2001/XMLSchema#> <User> IRI { schema:name xsd:string ; schema:knows @<User> * } Prefix declarations as in Turtle/SPARQL
  • 27. RDF Validation using ShEx :alice schema:name "Alice" ; schema:knows :alice . :bob schema:knows :alice ; schema:name "Robert". :carol schema:name "Carol", "Carole" . :dave schema:name 234 . :emily foaf:name "Emily" . :frank schema:name "Frank" ; schema:email <mailto:frank@example.org> ; schema:knows :alice, :bob . :grace schema:name "Grace" ; schema:knows :alice, _:1 . _:1 schema:name "Unknown" . Try it (RDFShape): https://goo.gl/97bYdv Try it (ShExDemo):https://goo.gl/Y8hBsW Schema Data <User> IRI { schema:name xsd:string ; schema:knows @<User> * } :alice@<User>, :bob @<User>, :carol@<User>, :dave @<User>, :emily@<User>, :frank@<User>, :grace@<User> Shape map       
  • 28. Validation process :alice@:User, :bob@:User, :carol@:User ShEx Validator Result shape map :User { schema:name xsd:string ; schema:knows @:User * } ShEx Schema :alice schema:name "Alice" ; schema:knows :alice . :bob schema:knows :alice ; schema:name "Robert". :carol schema:name "Carol", "Carole" . RDF data Shape map :alice@:User, :bob@:User, :carol@!:User Input: RDF data, ShEx schema, Shape map Output: Result shape map
  • 29. Example with more ShEx features :AdultPerson EXTRA rdf:type { rdf:type [ schema:Person ] ; :name xsd:string ; :age MinInclusive 18 ; :gender [:Male :Female] OR xsd:string ; :address @:Address ? ; :worksFor @:Company + ; } :Address CLOSED { :addressLine xsd:string {1,3} ; :postalCode /[0-9]{5}/ ; :state @:State ; :city xsd:string } :Company { :name xsd:string ; :state @:State ; :employee @:AdultPerson * ; } :State /[A-Z]{2}/ :alice rdf:type :Student, schema:Person ; :name "Alice" ; :age 20 ; :gender :Male ; :address [ :addressLine "Bancroft Way" ; :city "Berkeley" ; :postalCode "55123" ; :state "CA" ] ; :worksFor [ :name "Company" ; :state "CA" ; :employee :alice ] . Try it: https://tinyurl.com/yd5hp9z4
  • 31. SHACL implementations Name Parts Language - Library Comments Topbraid SHACL API SHACL Core, SPARQL Java (Jena) Used by TopBraid composer SHACL playground SHACL Core Javascript (rdflib.js) http://shacl.org/playground/ SHACLEX SHACL Core Scala (Jena, RDF4j) http://rdfshape.weso.es pySHACL SHACL Core, SPARQL Python (rdflib) https://github.com/RDFLib/pySHAC L Corese SHACL SHACL Core, SPARQL Java (STTL) http://wimmics.inria.fr/corese RDFUnit SHACL Core, SPARQL Java (Jena) https://github.com/AKSW/RDFUnit
  • 32. Basic example prefix : <http://example.org/> prefix sh: <http://www.w3.org/ns/shacl#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix schema: <http://schema.org/> :UserShape a sh:NodeShape ; sh:targetNode :alice, :bob, :carol ; sh:nodeKind sh:IRI ; sh:property :hasName, :hasEmail . :hasName sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string . :hasEmail sh:path schema:email ; sh:minCount 1; sh:maxCount 1; sh:nodeKind sh:IRI . :alice schema:name "Alice Cooper" ; schema:email <mailto:alice@mail.org> . :bob schema:firstName "Bob" ; schema:email <mailto:bob@mail.org> . :carol schema:name "Carol" ; schema:email "carol@mail.org" . Shapes graph Data graph   Try it. RDFShape https://goo.gl/ukY5vq
  • 33. Same example with blank nodes prefix : <http://example.org/> prefix sh: <http://www.w3.org/ns/shacl#> prefix xsd: <http://www.w3.org/2001/XMLSchema#> prefix schema: <http://schema.org/> :UserShape a sh:NodeShape ; sh:targetNode :alice, :bob, :carol ; sh:nodeKind sh:IRI ; sh:property [ sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string ; ] ; sh:property [ sh:path schema:email ; sh:minCount 1; sh:maxCount 1; sh:nodeKind sh:IRI ; ] . :alice schema:name "Alice Cooper" ; schema:email <mailto:alice@mail.org> . :bob schema:firstName "Bob" ; schema:email <mailto:bob@mail.org> . :carol schema:name "Carol" ; schema:email "carol@mail.org" . Shapes graph Data graph   Try it. RDFShape https://goo.gl/ukY5vq
  • 34. Some definitions about SHACL Shape target declarations constraint components :UserShape a sh:NodeShape ; sh:targetNode :alice, :bob, :carol ; sh:nodeKind sh:IRI ; sh:property :hasName, :hasEmail . :hasName sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string . . . .
  • 35. Validation Report [ a sh:ValidationReport ; sh:conforms false ; sh:result [ a sh:ValidationResult ; sh:focusNode :bob ; sh:message "MinCount violation. Expected 1, obtained: 0" ; sh:resultPath schema:name ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:MinCountConstraintComponent ; sh:sourceShape :hasName ] ; ... [ a sh:ValidationReport ; sh:conforms true ].
  • 36. SHACL processor SHACL Processor Validation report :UserShape a sh:NodeShape ; sh:targetNode :alice, :bob, :carol ; sh:nodeKind sh:IRI ; sh:property :hasName, :hasEmail . :hasName sh:path schema:name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string . . . . Shapes graph :alice schema:name "Alice Cooper" ; schema:email <mailto:alice@mail.org>. :bob schema:name "Bob" ; schema:email <mailto:bob@mail.org> . :carol schema:name "Carol" ; schema:email <mailto:carol@mail.org> . Data Graph [ a sh:ValidationReport ; sh:conforms true ].
  • 37. Longer example :AdultPerson EXTRA a { a [ schema:Person ] ; :name xsd:string ; :age MinInclusive 18 ; :gender [:Male :Female] OR xsd:string ; :address @:Address ? ; :worksFor @:Company + ; } :Address CLOSED { :addressLine xsd:string {1,3} ; :postalCode /[0-9]{5}/ ; :state @:State ; :city xsd:string } :Company { :name xsd:string ; :state @:State ; :employee @:AdultPerson * ; } :State /[A-Z]{2}/ :AdultPerson a sh:NodeShape ; sh:property [ sh:path rdf:type ; sh:qualifiedValueShape [ sh:hasValue schema:Person ]; sh:qualifiedMinCount 1 ; sh:qualifiedMaxCount 1 ; ] ; sh:targetNode :alice ; sh:property [ sh:path :name ; sh:minCount 1; sh:maxCount 1; sh:datatype xsd:string ; ] ; sh:property [ sh:path :gender ; sh:minCount 1; sh:maxCount 1; sh:in (:Male :Female); ] ; sh:property [ sh:path :age ; sh:maxCount 1; sh:minInclusive 18 ] ; sh:property [ sh:path :address ; sh:node :Address ; sh:minCount 1 ; sh:maxCount 1 ] ; sh:property [ sh:path :worksFor ; sh:node :Company ; sh:minCount 1 ; sh:maxCount 1 ]. :Address a sh:NodeShape ; sh:closed true ; sh:property [ sh:path :addressLine; sh:datatype xsd:string ; sh:minCount 1 ; sh:maxCount 3 ] ; sh:property [ sh:path :postalCode ; sh:pattern "[0-9]{5}" ; sh:minCount 1 ; sh:maxCount 3 ] ; sh:property [ sh:path :city ; sh:datatype xsd:string ; sh:minCount 1 ; sh:maxCount 1 ] ; sh:property [ sh:path :state ; sh:node :State ; ] . :Company a sh:NodeShape ; sh:property [ sh:path :name ; sh:datatype xsd:string ] ; sh:property [ sh:path :state ; sh:node :State ] ; sh:property [ sh:path :employee ; sh:node :AdultPerson ; ] ;. :State a sh:NodeShape ; sh:pattern "[A-Z]{2}" . In ShEx In SHACL Its recursive!!! (not well defined SHACL) Implementation dependent feature Try it: https://tinyurl.com/ycl3mkzr
  • 38. ShEx and SHACL compared
  • 39. ShEx and SHACL compared ShEx SHACL Underlying philosophy Structure definition Constraint checking Syntax Compact syntax + RDF RDF Notion of shape Only structure Structure + target decls. Default cardinalities {1,1} {0,*} Shapes and inference No SHACL specific entailment Recursion Part of the language Undefined Repeated properties Part of the language Conjunction by default Requires qualifiedValueShapes Property paths Nested shapes SPARQL like Property pair comparisons Unsupported in current version Part of the language Extension mechanism Semantic actions SHACL-SPARQL Validation triggering Query shape map Target declarations Result of validation Result shape map Validation report
  • 41. Theoretical foundations of ShEx/SHACL Shapes Shapes ShEx SHACL
  • 42. Generating Shapes from Data Try it with RDFShape: https://tinyurl.com/y8pjcbyf Shape Expression generated for wd:Q51613194 Shapes RDF data infer
  • 45. Ontological infrastructure https://github.com/geneontology/go-shapes/ Control version system (git) Continuous Integration server Ontological infrastructure Ontology engineer Triple Store Endpoint SPARQL Ontology publication system Shapes library Ontologies Test data
  • 46. Programming with shapes Semantic architecture Ontological infrastructure UML Diagrams Shapes library Domain model Syncrhonization
  • 48. Schema ecosystems: Solid project Data pod Shape A Shape C Shape B App 1 App 2 App 3 "...I just can’t stop thinking about shapes.", Ruben Verborgh https://ruben.verborgh.org/blog/2019/06/17/shaping-linked-data-apps/
  • 49. Shapes ecosystem @ WESO Producer Consumer Shapes
  • 50. Shapes ecosystem @ WESO http://github.com/weso
  • 52. Data validation RDF validation Generic schemas: ShEx/SHACL Converter ShEx  SHACL
  • 53. RDF data validation with Shapes https://typelevel.org/cats/
  • 54. Edit/create shapes Shapes editor Syntax highlighting, autocomplete, etc.
  • 58. Shapes programming Code generation from Shapes ShEx  POJO (Java) Shape A Shape C Shape B

Notas del editor

  1. ShEx: 20 lines of code SHACL: 60 lines of code