Ontology-based
modelling and querying
The purpose of this lab is to give you with the
basics of ontology modelling using Protégé tool. The main goal is to design the ‘family’ ontology,
create individuals and infer new relations.
1.
Classes and subclasses
The first step is to design classes and
subclasses of family ontology according to the following figure (Fig.1):
Fig. 1 : Family ontology
Remark: to declare a class C as subclass of two
classes A and B, you have to add A and B in asserted condition box (with Logic
View)
2. Class properties
1.
Datatype
properties (Fig. 2): create the properties
name, age and nationality of a person in properties tab which are single
properties (functional)
Fig. 2: DataType properties
b.
A
person is parent of another person
i.
Create the object property isParentOf with Person as domain and range
i.
Create the object property isFatherOf which is sub property of isParentOf with domain Male and range Person
i.
Create the object property isMotherOf which is sub property of isParentOf with domain Female and range Person
i.
Create the object property isSiblingOf with domain Person and range Person
i.
Create the object property isBrotherOf which is sub property of isSiblingOf with domain Male and range Person
i.
Create the object property isSisterOf which is sub property of isSiblingOf with domain Female and range Person
i.
Create the object property isChildOf with domain Person and range Person
i.
Create the object property isSonOf which is sub property of isChildOf with domain Male and range Person
i.
Create the object property isDaughterOf which is sub property of isChildOf with domain Female and range Person
Fig. 3 : Object property
3.
Class and properties restrictions
NECESSARY AND
SUFFICIENT CONDITION :
·
An
uncle has the restriction : is
brother of a parent
Fig. 4 : Sister class restriction
DISJOINTS CLASSES:
(in Disjoint boxes)
·
Male
and Female are disjoints
4.
Assign types to properties
·
iMarriedWith and isSiblingOf properties are symmetric
1.
create
individuals to Male class :
1.
configure
the inference engine, menu : OWL/Preferences/Reasoner URL ->
http://localhost:8081
In the next Lab (Lab 3), we will
see how to express these kinds of restrictions using a rule language. Indeed,
inference rules will solve this problem.
Part
2: SPARQL queries
1.
How
old is Peter?
2.
Who
are Sylvie’s parents?
3.
The
women over 30 years?
4.
What
are the instances of Person?
Example of a SPARQL
query:
PREFIX ns: <...#>
SELECT <variable>
WHERE{
<triplet>.
<triplet>.
<fonction>.
}
Prefix defines the used namespaces.
? is used to denotes variables (example ?age)
Details about SPARQL
can be found at: http://jena.sourceforge.net/ARQ/Tutorial/
Part
3: query dbpedia.org
Open the public SPARQL endpoint: http://dbpedia.org/snorql/ and test the
following query to get information related to the resource http://dbpedia.org/resource/Thomas_Edison
SELECT
?property ?hasValue ?isValueOf
WHERE
{
{
<http://dbpedia.org/resource/Thomas_Edison> ?property ?hasValue }
UNION
{ ?isValueOf ?property <http://dbpedia.org/resource/Thomas_Edison>
}
}
Based on the dbpedia page of Thomas
Edison http://dbpedia.org/page/Thomas_Edison,
the results of the previous query and using the following public SPARQL
endpoint: http://dbpedia.org/snorql/,
specify and test the following queries:
1.
On
what date was Thomas Edison Born?
2.
What
date did Edison Die?
Other queries:
1.
US
Presidents born in XXth Century
Note: use ?President rdf:type <http://dbpedia.org/class/yago/PresidentsOfTheUnitedStates>.
2.
US
Presidents born in XXth Century and if available their death date.
3.
List
the American recipients of MacArthur Fellowships.