78
Craigiebuckler, Aberdeen, AB15 8QH, UK Protégé training Gary Polhill

Craigiebuckler, Aberdeen, AB15 8QH, UK Protégé training Gary Polhill

Embed Size (px)

Citation preview

Craigiebuckler, Aberdeen, AB15 8QH, UK

Protégé training

Gary Polhill

Overview

• Obtaining, installing & community

• Creating and loading ontologies

• Creating classes, properties, restrictions & individuals

• Using the reasoner

• Diagramming

Overview

• Obtaining, installing & community

• Creating and loading ontologies

• Creating classes, properties, restrictions & individuals

• Using the reasoner

• Diagramming

Obtaining

• Protégé [Ontology development tool]– http://protege.stanford.edu/download/download.html – Version 3.1 beta

• Graphviz [Diagram support tool]– http://www.graphviz.org/Download.php– Version 2.2.1

• Racer [DL reasoner]– http://www.racer-systems.com/products/download/education.phtml

– Version 1-8-0– Version 1-7-24?

Licences (Protégé and Graphviz)

• Protégé– Mozilla Public Licence

• http://www.mozilla.org/MPL/– You are licensed to “use, reproduce, modify,

display, perform, sublicense, and distribute” it• Graphviz– Common Public Licence

• http://www.graphviz.org/Download.php– You are licensed to “reproduce, prepare

derivative works of, publicly display, publicly perform, distribute and sublicense” it

Racer licence

• Racer 1-8-0– Educational proprietary licence

• http://www.racer-systems.com/products/download/edu-license.phtml

– Requires registration– Install and use one copy on one computer– Limited time (180 days, possibly negotiable…)

• 990EUR cost for single workstation non-network licence– In publications for which Racer is used, name:

• RacerPro Software• Racer Systems GmbH & Co. KG -- licensor• http://www.racer-systems.com/ -- licensor website

• Racer 1-7-24– Not available any more, and not supported– Non-commercial licence

Possible alternative to Racer: FaCT

• FaCT– http://www.cs.man.ac.uk/~horrocks/FaCT/

• Released under GNU GPL• Lisp based• Description logic reasoner for SHF & SHIQ• Requires Tomcat to talk to Protégé– Use FaCT DIG Servlet version

• Doesn’t talk to Protégé very well!– Some loss of functionality

Installation of Protégé

• Run the install_protege.exe script• Follow the installation wizard• Accept all default options, except:

ChooseComponents

Everything

Basic+OWL might be OK (not tested)

Installation of Graphviz & Racer

• Graphviz– Run graphviz-2.2.1.exe– Accept all the default options– Never need to run it

• Racer 1.7.24– Doesn’t really need installing…– Extract the executable from the zip file

• racer-1-7-24-windows.zip– Copy it to the Desktop

• … or somewhere you will remember– Run it when you need it

Racer: Exercise

• Check that you can run Racer– Copy it from the CD to the computer

• You need to have write permission to the folder that Racer lives in

– Double click it to run

Port number for

HTTP service

Exit by closing

the window

Running Protégé

• Start > Programs > Protege_3.1_beta > Protege

• Command tool interface opens with diagnostic messages

• GUI opens with utility to open recent projects or create a new one

Protégé community

• Various mailing lists– http://protege.stanford.edu/community/lists.html– protege.discussion/general

• High volume, for general Protégé usage queries, not OWL

– protege.owl• High volume, for OWL specific Protégé usage queries

– protege.beta• Low volume, announces new beta releases of Protégé

– protege.users/announce• Low volume, announces new full releases and

conferences, etc.

Overview

• Obtaining, installing & community

• Creating and loading ontologies

• Creating classes, properties, restrictions & individuals

• Using the reasoner

• Diagramming

Create a new project wizard

OWL Files

OWL DL

1 2

3 4

Create from existing sources

Project components

• A Protégé project has two parts– Project file (with .pprj suffix)

• Contains details about the settings for the use of Protégé

• Can be version specific (i.e. a .pprj file for version 3.1 may not open in version 3.0 and vice versa)

– OWL file (with .owl suffix)• The ontology

• You can create a Protégé project from an existing OWL file by checking the ‘Create from existing sources’ box in step 1

Loading an ontology

• Select recently used projects from window at startup

• File > Open Project…

• File > Open Recent Project > project

• If you tell Windows that .pprj files belong to Protégé– Double click the .pprj file from Explorer

Protégé: Exercise

• Start Protégé

• Create a new project– Not from an existing source– OWL Files– Don’t import any ontologies– Default namespace– OWL-DL

Overview

• Obtaining, installing & community

• Creating and loading ontologies

• Creating classes, properties, restrictions & individuals

• Using the reasoner

• Diagramming

Working in Protégé

• Creating anything is called an assertion

• Think of it as creating some axioms

• You need to be clear about what each kind of assertion means

Creating classes

CreateSubclass of…

CreateSibling

Class of…

Tools > Quick OWL > Create multiple classes(Wizard)

…selected

class

Classes tab

Class name

Hierarchy

Conditions Disjoints

Properties

Metadata

Comment

Classes: Naming Conventions

• No mandatory conventions…• Class names begin with uppercase• Separate words in class names using

CamelStyle or Using_Underscores• Regexp for ASCII characters– [A-Za-z£$_][-A-Za-z0-9£$_.]*

• Unicode characters can also be used– Edit > Insert Unicode Characters…– Protégé’s default font doesn’t have very many

Classes: Meanings

• Individuals can belong to many classes• Classes can have many superclasses• Classes are not assumed to be disjoint

– You can make them disjoint– By doing so you assert that

• No individuals belong to classes A and B

• Subclass means necessary implication– If A and B are classes, and A is a subclass of B you

assert that• All individuals belonging to A belong to B• (…and all individuals not belonging to B don’t belong to A)• Note that if B is disjoint with C, then no individual

belonging to A can belong to C.

A B

BA

C

Classes: Exercise

• Create the following class hierarchy– Man & Woman should be disjoint

Different kinds of property

• Datatype property– String, Integer, etc.

• Object property– Relates one class of objects (domain) to

another (range)

• Annotation property– For different kinds of metadata– Can be object or datatype!

Creating Properties

Properties tab

Datatype propertyObject property

Subproperty

Annotation datatype and object properties

Properties tab (object properties)

Property hierarchyMultiple super-properties

Domain Range

Inverse

Property Characteristics

Metadata

CommentName

Properties tab (datatype property)

• As per object, except…

Datatype properties can’t be symmetric, transitive, or have an inverseYou can specify a set of values the property can take

Range is a datatype

Creating properties from the Classes tab

Create new datatype property(domain this class)Create newobject property(domain this class)Add this class to domain of existing property

Properties: Naming Conventions

• Again, no strict naming conventions• Lower case initial letter• Begin with ‘has’ or ‘is’

– Facilitates English Prose Tooltip Generator (see later)– … but not worth it if too awkward

• Same ASCII regexp as Classes• If different classes have a similar property name

(e.g. age)– Use class domain in property name if a union domain is

not appropriate• E.g. if range is a different type• hasPersonAge (10, 34, 57), hasHistoryAge (Victorian)

Properties: Meanings 1• Domain & Range

– Be careful…• These do not stipulate restrictions!• Any individual asserted or inferred to be on the ‘left hand side’ of

the property will be inferred to be a member of the domain class• Any individual asserted or inferred to be on the ‘right hand side’

of the property will be inferred to be a member of the range class– Multiple classes for the domain and range are interpreted to be

a union class– OWL class expressions can be used for the range of a

property (e.g. intersection of two classes)– OWL allows this for domains, too, but not in Protégé

• Subproperty– If property P is a subproperty of Q, and P(x, y) is asserted or

inferred, then Q(x, y) may be asserted or inferred– Datatype properties may not be subproperties of object

properties, and vice versa

Properties: Meanings 2

• Property Characteristics– Inverse

• If P is the inverse of Q and P(x, y), then Q(x, y)– Symmetric

• If P is symmetric and P(x, y), then P(y, x)– Transitive

• If P is transitive and P(x, y) and P(y, z) then P(x, z)• A transitive property must have a transitive inverse

– Functional• Aka feature or single valued property• The right hand side may only be one individual• If more than one individual is found they are inferred to be the same• A transitive property cannot be functional

– Inverse functional• The left hand side may only be one individual• If more than one individual is found they are inferred to be the same• An inverse functional property has a functional inverse (and vice versa)

Other information about Properties

• Annotation properties– Metadata– Can be applied to Classes, Properties (datatype or

object), and Individuals– Restrictions in OWL-DL

• Property value must be a literal, URI, or individual• Cannot be used in property axioms (e.g. cannot be

subproperty or have a subproperty)• Cannot have a domain or range

• Classes as property range– Not possible in OWL-DL – OWL-Full only– A rare requirement

Properties: Exercise

• Create datatype properties– hasAge (integer)– hasSex (“Male” or “Female”)

• Create object properties – hasAncestor, hasParent, hasMother, hasFather– isAncestorOf, isParentOf, isMotherOf, isFatherOf– hasSpouse, hasHusband, hasWife

• Ensure property characteristics are appropriately set– Domain and range– Subproperty– Inverse– Transitive, Symmetric, Functional, Inverse Functional

Creating Restrictions

Select property and create restriction

Right click property and select restriction to create

Create expression

Create restriction on any property

Create Restriction Window

Property to be restricted

Restriction expression tool

Type of restriction

Restriction expression

Keep this guy happy!

Different kinds of restriction

• Quantifier restriction (Object property)– Existential

• “At least one” “some” “some values from”• e.g. (Husband class) ∃ hasWife Woman

– Universal• “Only” “all values from”• e.g. (Person class) ∀ hasFather Man

• hasValue restriction (Datatype property)– e.g. (Man class) hasSex ∋ “Male”

• Cardinality restriction (Object property)– Exact cardinality– Minimum cardinality– Maximum cardinality

Other kinds of restriction

• Union classes– e.g. hasDifficultChildren (Toddler ⊔ Teenager)

• Intersection classes– e.g. hasSingleParent (Parent ⊓ Divorcee)

• Negation– e.g. Bachelor class: ¬(∃ hasWife Woman)

• Expressions can have arbitrary complexity– … but probably a good idea to keep it simple

• Use intermediate classes

Restrictions: Meanings 1

• A restriction actually defines an anonymous class– When used to describe classes, they define an anonymous

superclass• Existential restrictions

– Beware the Open World Assumption!• Only says that at least one of the relationships an individual has is

with a member of the specified class …• … so the individual could have that relationship also with a

member of a different class• Universal restrictions

– Beware!• Only says that all relationships an individual has must be with

members of the specific class …• … includes individuals who have NO relationship of this kind with

ANY individual– Often used with existential restrictions (closure axiom)

Restrictions: Meanings 2

• hasValue restrictions– Can be used with object properties to point to a specific

individual• e.g. hasAncestor ∋ Adam• OWL-Full?

• Cardinality restrictions– Pertain to the number of relationships an individual

must participate in– Relies on counting distinct individuals

• OWL does not make the Unique Name Assumption• … but Racer does!

– Potentially, individuals will be inferred to be the same

Restrictions: Exercise

• Man and Woman Classes– hasSex ∋ “Male”, hasSex ∋ “Female” respectively

• Spouse class– Has at least one spouse

• Parent class– Is parent of at least one person

• Father class– Is father of at least one person

• Husband class– Has wife at least one woman

• Similarly for Mother and Wife classes• Try out the English Prose Tooltip Generator

– Move the mouse over one of the classes you have given restrictions to in the class hierarchy

Primitive and Defined Classes

• Primitive classes (aka partial classes)– Have necessary conditions only

• If an individual is a member of the class it must satisfy these conditions

• NOT if an individual satisfies these conditions then it is a member of the class

– Necessary conditions are conjunctive• Defined classes (aka complete classes)– Also have necessary and sufficient conditions

• These allow class membership to be inferred– Multiple sets of necessary and sufficient

conditions are permitted (disjunctive)

Creating Defined Classes 1Necessary conditions moved to Necessary and Sufficient slot

Select “Convert to defined class”

Right-click the class to be defined

Creating Defined Classes 2

• You can also click and drag necessary conditions to the necessary and sufficient slot

• Create multiple necessary and sufficient conditions by right-clicking the “NECESSARY & SUFFICIENT” slot header

Right click

Create new necessary and

sufficient block

Defined classes: Exercise

• Decide which classes created so far can be converted to defined classes

• Convert them

Creating Individuals

• Forms tab– Allows you to edit the form widgets used to

enter the individuals’ data• Individuals tab– Used to enter the data– Select the class on to create an individual of

from the hierarchy on the left hand pane– Press the create individual icon (purple

diamond with a plus sign) from the centre pane– Enter the individual’s data on the right hand

pane

Creating individuals

Select class

Click here

Enter details

Individuals: Exercise

• Experiment with the Person entry form• Create some instances of Person– Try creating instances that will test the

inference engine: e.g.• Domain and range• Functional properties

• Create an instance of OWL: Thing– Useful to check what happens to it when using

reasoner

Overview

• Obtaining, installing & community

• Creating and loading ontologies

• Creating classes, properties, restrictions & individuals

• Using the reasoner

• Diagramming

Three uses for the reasoner

• Checking the consistency of the ontology• Classifying the taxonomy– Uses defined classes to determine new class

hierarchy• Logically consistent with ontology

• Classifying individuals– Deciding which classes individuals belong to

• ONE enhancement request…

–WHY?

Reasoner prerequisites

• OWL-DL or OWL-Lite sublanguage• Racer needs to be in a writable directory• Port numbers configured correctly

– Watch out for clashes with other software (unlikely)– Racer can be configured to use different ports on the command

line• -p <TCP port>• -http <HTTP port>

– This is the one Protégé needs to know about

• The reasoner does not have to be on the same machine– Can connect to one over the web

• The reasoner needs to be running!– Double-click racer.exe to start Racer

Determining OWL sublanguageOWL menu

Determine/Convert OWL Sublanguage…OWL Full cannot be used with the reasoner (decidability not guaranteed), but is more expressive

Checking reasoner port number 1OWL menu

Preferences…

Checking reasoner port number 2

Address:port where Protégé expects to find the reasoner

Address:port where Racer expects to talk to Protege

Checking consistency

Check consistency… also under OWL menu

Click here

Checking consistency: result

Husband and Wife are inconsistent in this ontology when Spouse is disjoint from Woman

If no inconsistent concepts are found, then your ontology is OK

Checking the consistency of one class

Right-click the class

Select Check concept consistency… from the menu

Protégé built-in ontology checks

• Run ontology tests… is also an option in the OWL menu

• See Test settings… under OWL menu to choose the tests to run

• Does not require reasoner

Click here (bug icon)

Classifying thetaxonomy

Click here(also available under OWL menu)

Inferred hierarchy (changes in blue)

Inferred conditions tab

Summary of results

Asserted hierarchy

Classifying individualsClick here (also under OWL menu)

Inferred class members tab

Membership of each class viewable next to each class as (asserted / inferred)

Finding members of a single class

Select “Compute individuals belonging to class…”

Right-click the class

Results returned in pop-up window

Reasoner: Exercise

• Try the following– Check consistency– Check consistency of a single class– Classify taxonomy– Run ontology tests

• Remember this doesn’t require the reasoner– Classify individuals– Find members of a class

• Are the results as you expect?– What changes would you make to your

ontology?

Overview

• Obtaining, installing & community

• Creating and loading ontologies

• Creating classes, properties, restrictions & individuals

• Using the reasoner

• Diagramming

Diagramming

• Protégé has plug-ins– Diagramming tools are instances of this– Details of plug-ins stored in .pprj file– You tell Protégé which plug-ins to use by configuring

your project

• OWLViz and Ontoviz are diagramming plug-ins– Require graphviz (from graphviz.org)– If a project using either is loaded into Protégé without

graphviz installed, then you get error messages• These can be ignored…• … but be aware when passing .pprj and .owl files on to

others

Adding tabs for diagramming 1

Project > Configure …

Adding tabs for diagramming 2

Tab Widgets tab

Click the check boxes for OWLViz and Ontoviz

OWLViz tab

• Lets you view and interact with the asserted and inferred class hierarchies

Click on a class…

…Disjoint classes shown with ¬

Export to image

Show or hide classes

Diagram asserted or inferred model

Ontoviz tab• Diagram classes and relationships

• Select classes• Click the add

classes icon• Choose diagram

components• Click the “Op”

icon for options– Including save

image to file• Saved in

project workingdirectory

• Click the drawicon

Ontoviz tab diagram components

• sub: sub-classes– Includes anonymous classes

• Which aren’t shown very nicely (font limitations?)

• sup: super-classes• slx: no idea!• isx: no idea!• slt: give a table of the class’s properties

– Limited number of rows by default• Can be changed in the options

• sle: draw relationships between classes• ins: show instances

– Asserted instances only• sys: system classes?

Diagramming individuals with Ontoviz

• Select the class you want individuals diagrammed

• Click the I+ icon to get the instance browser (right)

• Select the instances• Click add• Then select

diagramming options as for classes

Diagramming individuals: result

Query view

Right-click an instance

Select “Show in Query View”

Result of query view

• Allows you to explore relationships between individuals

Diagramming: Exercise

• Create an inferred class hierarchy diagram using OWLViz and save it to a file

• Create a diagram of some of the classes in your ontology and relationships between them

• Create a diagram of individuals in your ontology

• Have a go with query view

Summary

Ground covered

• Installing Protégé and associated software• Running Protégé and Racer• Creating a new ontology• Creating classes, properties, restrictions and

instances– What each of these mean!

• Using the reasoner– Check consistency, classify taxonomy & individuals

• Diagramming tools• Should suffice for Grampian & Odra ontologies

Other things to look at• Version control

– See under Project menu• Dublin Core metadata

– Contains various annotation properties• e.g. creator, etc.

– Widely used• See metadata tab and new project creation wizard

– Should we have an ‘evidence’ metadatum in the CAVES project?

• Importing ontologies– Searching for ontologies

• Swoogle: http://swoogle.umbc.edu/index.php• Publishing ontologies and defining namespaces• Protégé OWL Pizza Tutorial

– On the CD

Final exercise/homework

• Choose some of the following classes of people to define– YAPPIE: Young Affluent Parent– OINK: One Income No Kids– DINKY: Dual Income No Kids Yet– DUMP: Destitute Unemployed Mature Person– SITCOM: Single Income, Two Kids, Outrageous Mortgage– SINK: Single, Independent, No Kids– KIPPERS: Kids in Parents’ Pockets Eroding Retirement Savings– SILKY: Single Income Loads of Kids– WOOPIE: Well Off Older Person– SKIPPIE: School Kid with Income and Purchasing Power– TIREDS: Thirtysomething Radical Educated Dropout

• You may need to add supporting classes to your ontology…