SlideShare uma empresa Scribd logo
1 de 24
MS.AMBREEN
SEMANTIC WEB
TOPIC CONTINUED FROM
LECTURE#8
LECTURE#9
BASIC SPARQL QUERY
PROGRAMMING SKILLS
 A typical query includes the following structure, some parts are optional:
 Declear prefix shortcuts (optional)
 PREFIX foo: <...>
 Query result clause
 SELECT ...
 Define the dataset (optional)
 FROM <...>
 Query pattern
 WHERE {
 ...
 }
 Query modifiers (optional):
 Group BY ...
 HAVING
 ORDER BY
 LIMIT
 OFFSET
 VALUES
QUERY STRUCTURE IN SPARQL
 rdf: http://xmlns.com/foaf/0.1/
 rdfs: http://www.w3.org/2000/01/rdf-schema#
 owl: http://www.w3.org/2002/07/owl#
 xsd: http://www.w3.org/2001/XMLSchema#
 dc: http://purl.org/dc/elements/1.1/
 foaf: http://xmlns.com/foaf/0.1/
 obo: <http://purl.obolibrary.org/obo/>
COMMON PREFIXES
 Similar to its use in SQL, SELECT in SPARQL allows you to
define which variables you want values returned and output.
Like SQL you can list these individually or use an asterisk (*)
to specify values for each variable. E.g.
 SELECT ?a ?text
 SELECT *
 If you don't want duplicates you can append DISTINCT after
SELECT. e.g.,
 SELECT DISTINCT ?country
HOW TO SELECT?
 The WHERE clause defines where you want to find values for
the variables defined in the SELECT clause.
HOW TO PROGRAM INSIDE WHERE?
 The basic unit is a triple, which is made up of three components,
a subject, a predicate and an object. Each of the three
components can take one of two forms:
 put a ? prior to the variable name, e.g., ?a.
 a Universal Resource Identifier (URI).
 Note: A prefix for the namespace of the URI can be utilized.
 These triples can then be concatenated together using a full-stop
(.). Eventually, an interconnected graph of nodes joined by
relationships is built up.
 A semi-colon (;) can be used after each triple to replace the
subject for the next triple if it is the same. In this way, you only
need to define the predicate and object. e.g.,
 ?x rdf:type mebase:User ;
foaf:homepage ?homepage ;
foaf:mbox ?mbox
TRIPLE REPRESENTATIONS.
 The UNION clause:
return results to match at least one of multiple patterns
 The OPTIONAL clause is also often used.
 The FILTER clause filters the results based on certain
conditions.
CLAUSES
A solution sequence modifier is one of:
 Order modifier: put the solutions in order
 Projection modifier: choose certain variables
 Distinct modifier: ensure solutions in the sequence are unique
 Reduced modifier: permit elimination of some non-distinct
solutions
 Offset modifier: control where the solutions start from in the
overall sequence of solutions
 Limit modifier: restrict the number of solutions
HOW TO USE MODIFERS?
 This section provides many examples on how to query the RDF
triple store:
 Example #1: Find all class-containing ontology graphs:
 This example is aimed to find all ontologies in our RDF triple
store. Typically every single ontology includes at least one
class. This SPARQL script searches those ontology graphs in
the RDF triple store that contains at least one class.
SPARQL EXAMPLES TO QUERY RDF
TRIPLE STORE
 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT
distinct ?graph_uri WHERE { GRAPH ?graph_uri { ?s rdf:type
owl:Class } . }
BELOW IS THE SPARQL SCRIPT:
 Example #2: Find subclasses of an ontology term:
 This example is aimed to find all subclasses of an ontology
term.
 PREFIX obo-term: <http://purl.obolibrary.org/obo/> SELECT
DISTINCT ?x ?label FROM
<http://purl.obolibrary.org/obo/merged/OAE> WHERE { ?x
rdfs:subClassOf obo-term:OAE_0000001. ?x rdfs:label ?label. }
BELOW IS THE SPARQL SCRIPT:
 Example #3: Find the number of all class (or object,
annotation, or datatype property) terms of an ontology:
 This example is aimed to find the number of all class terms of
an ontology.
 SELECT count(?s) as ?VO_class_count FROM
<http://purl.obolibrary.org/obo/merged/VO> WHERE { ?s a
owl:Class . ?s rdfs:label ?label . FILTER regex( ?s, "VO_" ) }
BELOW IS THE SPARQL SCRIPT:
 Example #4: Retrieve definition and authors of all classes in
an ontology:
 This example is aimed to retrieve the definitions of all classes
that have definitions in an ontology.
 PREFIX obo-term: <http://purl.obolibrary.org/obo/> SELECT
?s ?label ?definition ?author FROM
<http://purl.obolibrary.org/obo/merged/VO> WHERE { ?s a
owl:Class . ?s rdfs:label ?label . ?s obo-term:IAO_0000115
?definition . ?s obo-term:IAO_0000117 ?author . }
BELOW IS THE SPARQL SCRIPT:
 Example #5: Retrieve general annotations of an ontology:
 This example is aimed to retrieve general annotation
descriptions of the ontology. The result will return different
types of annotations such as "creator", "description"s, etc.
 PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT
DISTINCT ?p, ?o FROM
<http://purl.obolibrary.org/obo/merged/OAE> WHERE{ ?s a
owl:Ontology . ?s ?p ?o .}
BELOW IS THE SPARQL SCRIPT
 Example #5: Query on axiom: Find vaccines containing egg
protein allergen:
 The above examples are mostly based on ontology annotation
properties. How to perform SPARQL queries based on logical
axioms with object properties (or relations)? Here we provide
some example.
 PREFIX has_vaccine_allergen:
<http://purl.obolibrary.org/obo/VO_0000531> PREFIX
chicken_egg_protein_allergen:
<http://purl.obolibrary.org/obo/VO_0000912> SELECT
distinct ?vaccine_label ?vaccine FROM
<http://purl.obolibrary.org/obo/merged/VO> WHERE {
?vaccine rdfs:label ?vaccine_label . ?vaccine rdfs:subClassOf
?vaccine_restriction . ?vaccine_restriction owl:onProperty
has_vaccine_allergen:; owl:someValuesFrom
chicken_egg_protein_allergen: . }
BELOW IS ONE SUCH SPARQL SCRIPT:
 Prefix obo: <http://purl.obolibrary.org/obo/> SELECT distinct
?label ?s From <http://purl.obolibrary.org/obo/merged/VO>
Where { ?s rdfs:label ?label . ?s rdfs:subClassOf ?s1 . ?s1
owl:onProperty obo:VO_0000531; owl:someValuesFrom
obo:VO_0000912 . }
NOTE THAT THE FOLLOWING CODE HAS
THE SAME EFFECT AS THE TOP CODE:
 The difference between the above two sets of SPARQL codes
is that the first one looks easier to read.

Mais conteúdo relacionado

Mais procurados (19)

SPARQL Tutorial
SPARQL TutorialSPARQL Tutorial
SPARQL Tutorial
 
SPARQL in a nutshell
SPARQL in a nutshellSPARQL in a nutshell
SPARQL in a nutshell
 
RDF Validation Future work and applications
RDF Validation Future work and applicationsRDF Validation Future work and applications
RDF Validation Future work and applications
 
Jena Programming
Jena ProgrammingJena Programming
Jena Programming
 
SPARQL Cheat Sheet
SPARQL Cheat SheetSPARQL Cheat Sheet
SPARQL Cheat Sheet
 
SPARQL-DL - Theory & Practice
SPARQL-DL - Theory & PracticeSPARQL-DL - Theory & Practice
SPARQL-DL - Theory & Practice
 
SPARQL 1.1 Status
SPARQL 1.1 StatusSPARQL 1.1 Status
SPARQL 1.1 Status
 
XSLT and XPath - without the pain!
XSLT and XPath - without the pain!XSLT and XPath - without the pain!
XSLT and XPath - without the pain!
 
Reflection
ReflectionReflection
Reflection
 
070517 Jena
070517 Jena070517 Jena
070517 Jena
 
ShEx by Example
ShEx by ExampleShEx by Example
ShEx by Example
 
An Introduction to SPARQL
An Introduction to SPARQLAn Introduction to SPARQL
An Introduction to SPARQL
 
Learning XSLT
Learning XSLTLearning XSLT
Learning XSLT
 
Clonedigger-Python
Clonedigger-PythonClonedigger-Python
Clonedigger-Python
 
BioSD Tutorial 2014 Editition
BioSD Tutorial 2014 EdititionBioSD Tutorial 2014 Editition
BioSD Tutorial 2014 Editition
 
Chapter 5 Class File
Chapter 5 Class FileChapter 5 Class File
Chapter 5 Class File
 
Solr Introduction
Solr IntroductionSolr Introduction
Solr Introduction
 
WebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPediaWebTech Tutorial Querying DBPedia
WebTech Tutorial Querying DBPedia
 
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
 

Semelhante a Semantic Web

Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLEmanuele Della Valle
 
What;s Coming In SPARQL2?
What;s Coming In SPARQL2?What;s Coming In SPARQL2?
What;s Coming In SPARQL2?LeeFeigenbaum
 
SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)Thomas Francart
 
The Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQLThe Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQLMyungjin Lee
 
SPARQL Query Forms
SPARQL Query FormsSPARQL Query Forms
SPARQL Query FormsLeigh Dodds
 
Aidan's PhD Viva
Aidan's PhD VivaAidan's PhD Viva
Aidan's PhD VivaAidan Hogan
 
Re-using Media on the Web: Media fragment re-mixing and playout
Re-using Media on the Web: Media fragment re-mixing and playoutRe-using Media on the Web: Media fragment re-mixing and playout
Re-using Media on the Web: Media fragment re-mixing and playoutMediaMixerCommunity
 
BioSamples Database Linked Data, SWAT4LS Tutorial
BioSamples Database Linked Data, SWAT4LS TutorialBioSamples Database Linked Data, SWAT4LS Tutorial
BioSamples Database Linked Data, SWAT4LS TutorialRothamsted Research, UK
 
Joy Nelson - Workshop on BIBFRAME, RDF and SPAQL
Joy Nelson - Workshop on BIBFRAME, RDF and SPAQLJoy Nelson - Workshop on BIBFRAME, RDF and SPAQL
Joy Nelson - Workshop on BIBFRAME, RDF and SPAQLKohaGruppoItaliano
 
SPARQLing Services
SPARQLing ServicesSPARQLing Services
SPARQLing ServicesLeigh Dodds
 
Understanding the firebird optimizer
Understanding the firebird optimizerUnderstanding the firebird optimizer
Understanding the firebird optimizerMarius Adrian Popa
 
Querying XML: XPath and XQuery
Querying XML: XPath and XQueryQuerying XML: XPath and XQuery
Querying XML: XPath and XQueryKatrien Verbert
 
AAT LOD Microthesauri
AAT LOD MicrothesauriAAT LOD Microthesauri
AAT LOD MicrothesauriMarcia Zeng
 
Towards ubiquitous OWL computing: Simplifying programmatic authoring of and q...
Towards ubiquitous OWL computing: Simplifying programmatic authoring of and q...Towards ubiquitous OWL computing: Simplifying programmatic authoring of and q...
Towards ubiquitous OWL computing: Simplifying programmatic authoring of and q...Hilmar Lapp
 
A Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic WebA Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic WebShamod Lacoul
 

Semelhante a Semantic Web (20)

Querying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQLQuerying the Semantic Web with SPARQL
Querying the Semantic Web with SPARQL
 
What;s Coming In SPARQL2?
What;s Coming In SPARQL2?What;s Coming In SPARQL2?
What;s Coming In SPARQL2?
 
SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)SPARQL introduction and training (130+ slides with exercices)
SPARQL introduction and training (130+ slides with exercices)
 
Sparql
SparqlSparql
Sparql
 
The Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQLThe Semantic Web #10 - SPARQL
The Semantic Web #10 - SPARQL
 
Introduction to SPARQL
Introduction to SPARQLIntroduction to SPARQL
Introduction to SPARQL
 
Querying Bio2RDF data
Querying Bio2RDF dataQuerying Bio2RDF data
Querying Bio2RDF data
 
SPARQL Query Forms
SPARQL Query FormsSPARQL Query Forms
SPARQL Query Forms
 
Aidan's PhD Viva
Aidan's PhD VivaAidan's PhD Viva
Aidan's PhD Viva
 
Data in RDF
Data in RDFData in RDF
Data in RDF
 
Re-using Media on the Web: Media fragment re-mixing and playout
Re-using Media on the Web: Media fragment re-mixing and playoutRe-using Media on the Web: Media fragment re-mixing and playout
Re-using Media on the Web: Media fragment re-mixing and playout
 
BioSamples Database Linked Data, SWAT4LS Tutorial
BioSamples Database Linked Data, SWAT4LS TutorialBioSamples Database Linked Data, SWAT4LS Tutorial
BioSamples Database Linked Data, SWAT4LS Tutorial
 
Joy Nelson - Workshop on BIBFRAME, RDF and SPAQL
Joy Nelson - Workshop on BIBFRAME, RDF and SPAQLJoy Nelson - Workshop on BIBFRAME, RDF and SPAQL
Joy Nelson - Workshop on BIBFRAME, RDF and SPAQL
 
SPARQLing Services
SPARQLing ServicesSPARQLing Services
SPARQLing Services
 
Introduction to Bio SPARQL
Introduction to Bio SPARQL Introduction to Bio SPARQL
Introduction to Bio SPARQL
 
Understanding the firebird optimizer
Understanding the firebird optimizerUnderstanding the firebird optimizer
Understanding the firebird optimizer
 
Querying XML: XPath and XQuery
Querying XML: XPath and XQueryQuerying XML: XPath and XQuery
Querying XML: XPath and XQuery
 
AAT LOD Microthesauri
AAT LOD MicrothesauriAAT LOD Microthesauri
AAT LOD Microthesauri
 
Towards ubiquitous OWL computing: Simplifying programmatic authoring of and q...
Towards ubiquitous OWL computing: Simplifying programmatic authoring of and q...Towards ubiquitous OWL computing: Simplifying programmatic authoring of and q...
Towards ubiquitous OWL computing: Simplifying programmatic authoring of and q...
 
A Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic WebA Hands On Overview Of The Semantic Web
A Hands On Overview Of The Semantic Web
 

Mais de amberkhan59

Mais de amberkhan59 (7)

Semantic Web
Semantic WebSemantic Web
Semantic Web
 
Sorting and Its Types
Sorting and Its TypesSorting and Its Types
Sorting and Its Types
 
Lec#04
Lec#04Lec#04
Lec#04
 
Lec#03
Lec#03Lec#03
Lec#03
 
Lec#02
Lec#02Lec#02
Lec#02
 
Lecture#1
Lecture#1Lecture#1
Lecture#1
 
Ict lec#9
Ict lec#9Ict lec#9
Ict lec#9
 

Último

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 

Último (20)

Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 

Semantic Web

  • 4.  A typical query includes the following structure, some parts are optional:  Declear prefix shortcuts (optional)  PREFIX foo: <...>  Query result clause  SELECT ...  Define the dataset (optional)  FROM <...>  Query pattern  WHERE {  ...  }  Query modifiers (optional):  Group BY ...  HAVING  ORDER BY  LIMIT  OFFSET  VALUES QUERY STRUCTURE IN SPARQL
  • 5.  rdf: http://xmlns.com/foaf/0.1/  rdfs: http://www.w3.org/2000/01/rdf-schema#  owl: http://www.w3.org/2002/07/owl#  xsd: http://www.w3.org/2001/XMLSchema#  dc: http://purl.org/dc/elements/1.1/  foaf: http://xmlns.com/foaf/0.1/  obo: <http://purl.obolibrary.org/obo/> COMMON PREFIXES
  • 6.  Similar to its use in SQL, SELECT in SPARQL allows you to define which variables you want values returned and output. Like SQL you can list these individually or use an asterisk (*) to specify values for each variable. E.g.  SELECT ?a ?text  SELECT *  If you don't want duplicates you can append DISTINCT after SELECT. e.g.,  SELECT DISTINCT ?country HOW TO SELECT?
  • 7.  The WHERE clause defines where you want to find values for the variables defined in the SELECT clause. HOW TO PROGRAM INSIDE WHERE?
  • 8.  The basic unit is a triple, which is made up of three components, a subject, a predicate and an object. Each of the three components can take one of two forms:  put a ? prior to the variable name, e.g., ?a.  a Universal Resource Identifier (URI).  Note: A prefix for the namespace of the URI can be utilized.  These triples can then be concatenated together using a full-stop (.). Eventually, an interconnected graph of nodes joined by relationships is built up.  A semi-colon (;) can be used after each triple to replace the subject for the next triple if it is the same. In this way, you only need to define the predicate and object. e.g.,  ?x rdf:type mebase:User ; foaf:homepage ?homepage ; foaf:mbox ?mbox TRIPLE REPRESENTATIONS.
  • 9.  The UNION clause: return results to match at least one of multiple patterns  The OPTIONAL clause is also often used.  The FILTER clause filters the results based on certain conditions. CLAUSES
  • 10. A solution sequence modifier is one of:  Order modifier: put the solutions in order  Projection modifier: choose certain variables  Distinct modifier: ensure solutions in the sequence are unique  Reduced modifier: permit elimination of some non-distinct solutions  Offset modifier: control where the solutions start from in the overall sequence of solutions  Limit modifier: restrict the number of solutions HOW TO USE MODIFERS?
  • 11.  This section provides many examples on how to query the RDF triple store:  Example #1: Find all class-containing ontology graphs:  This example is aimed to find all ontologies in our RDF triple store. Typically every single ontology includes at least one class. This SPARQL script searches those ontology graphs in the RDF triple store that contains at least one class. SPARQL EXAMPLES TO QUERY RDF TRIPLE STORE
  • 12.  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT distinct ?graph_uri WHERE { GRAPH ?graph_uri { ?s rdf:type owl:Class } . } BELOW IS THE SPARQL SCRIPT:
  • 13.  Example #2: Find subclasses of an ontology term:  This example is aimed to find all subclasses of an ontology term.
  • 14.  PREFIX obo-term: <http://purl.obolibrary.org/obo/> SELECT DISTINCT ?x ?label FROM <http://purl.obolibrary.org/obo/merged/OAE> WHERE { ?x rdfs:subClassOf obo-term:OAE_0000001. ?x rdfs:label ?label. } BELOW IS THE SPARQL SCRIPT:
  • 15.  Example #3: Find the number of all class (or object, annotation, or datatype property) terms of an ontology:  This example is aimed to find the number of all class terms of an ontology.
  • 16.  SELECT count(?s) as ?VO_class_count FROM <http://purl.obolibrary.org/obo/merged/VO> WHERE { ?s a owl:Class . ?s rdfs:label ?label . FILTER regex( ?s, "VO_" ) } BELOW IS THE SPARQL SCRIPT:
  • 17.  Example #4: Retrieve definition and authors of all classes in an ontology:  This example is aimed to retrieve the definitions of all classes that have definitions in an ontology.
  • 18.  PREFIX obo-term: <http://purl.obolibrary.org/obo/> SELECT ?s ?label ?definition ?author FROM <http://purl.obolibrary.org/obo/merged/VO> WHERE { ?s a owl:Class . ?s rdfs:label ?label . ?s obo-term:IAO_0000115 ?definition . ?s obo-term:IAO_0000117 ?author . } BELOW IS THE SPARQL SCRIPT:
  • 19.  Example #5: Retrieve general annotations of an ontology:  This example is aimed to retrieve general annotation descriptions of the ontology. The result will return different types of annotations such as "creator", "description"s, etc.
  • 20.  PREFIX owl: <http://www.w3.org/2002/07/owl#> SELECT DISTINCT ?p, ?o FROM <http://purl.obolibrary.org/obo/merged/OAE> WHERE{ ?s a owl:Ontology . ?s ?p ?o .} BELOW IS THE SPARQL SCRIPT
  • 21.  Example #5: Query on axiom: Find vaccines containing egg protein allergen:  The above examples are mostly based on ontology annotation properties. How to perform SPARQL queries based on logical axioms with object properties (or relations)? Here we provide some example.
  • 22.  PREFIX has_vaccine_allergen: <http://purl.obolibrary.org/obo/VO_0000531> PREFIX chicken_egg_protein_allergen: <http://purl.obolibrary.org/obo/VO_0000912> SELECT distinct ?vaccine_label ?vaccine FROM <http://purl.obolibrary.org/obo/merged/VO> WHERE { ?vaccine rdfs:label ?vaccine_label . ?vaccine rdfs:subClassOf ?vaccine_restriction . ?vaccine_restriction owl:onProperty has_vaccine_allergen:; owl:someValuesFrom chicken_egg_protein_allergen: . } BELOW IS ONE SUCH SPARQL SCRIPT:
  • 23.  Prefix obo: <http://purl.obolibrary.org/obo/> SELECT distinct ?label ?s From <http://purl.obolibrary.org/obo/merged/VO> Where { ?s rdfs:label ?label . ?s rdfs:subClassOf ?s1 . ?s1 owl:onProperty obo:VO_0000531; owl:someValuesFrom obo:VO_0000912 . } NOTE THAT THE FOLLOWING CODE HAS THE SAME EFFECT AS THE TOP CODE:
  • 24.  The difference between the above two sets of SPARQL codes is that the first one looks easier to read.