Lab: OWL 1

From info216

Topics

  • Basic OWL ontology programming with RDFlib and owlrl.
  • RDFS is relevant too.
  • WebVOWL visualisation.

Useful materials

Readings:

Vocabularies and terms:

  • OWL (sameAs, equivalentClass, equivalentProperty, differentFrom, disjointWith, inverseOf)
  • OWL (SymmetricProperty, AsymmetricProperty, ReflexiveProperty, IrreflexiveProperty, TransitiveProperty, FunctionalProperty, InverseFunctionalProperty, AllDifferent)

Tasks

Task. Write OWL triples that corresponds to the following text. Try to continue your example from labs 1 and 2, or extend the triples at the bottom of this page. OWL terms can be imported from rdflib in the same way as RDF and RDFS terms.

  • Donald Trump and Robert Mueller are two different persons.
  • Actually, all the names mentioned in connection with the Muelle investigation refer to different people.
  • All these people are foaf:Persons as well as schema:Persons (they are http://xmlns.com/foaf/0.1/Person and http://schema.org/Person).
  • Tax evation is a kind of bank and tax fraud.
  • The Donald Trump involved in the Mueller investigation is dbpedia:Donald_Trump and not dbpedia:Donald_Trump_Jr. .
    • Tip: rdflib's Turtle parser does not like URLs with punctuation marks written "prefix style" (dbpedia:Donald_Trump_Jr.), but it will accept the full URL written in angle brackets (<http://dbpedia.org/resource/Donald_Trump_Jr.>)
  • Congress, FBI and the Mueller investigation are foaf:Organizations.
  • Nothing can be both a person and an organization.
  • Leading an organization is a way of being involved in an organization.
  • Being a campaign manager or an advisor for is a way of supporting someone.
  • Donald Trump is a politician and a Republican.
  • A Republican politician is both a politician and a Republican.

Task.

g.add((ex.Paul_Manafort, ex.hasBusinessPartner, ex.Rick_Gates))
g.add((ex.Michael_Flynn, ex.adviserTo, ex.Donald_Trump))
g.add((ex.Rick_Gates_Lying, ex.wasLyingTo, ex.FBI))
g.add((ex.Donald_Trump, ex.presidentOf, ex.USA))
g.add((ex.USA, ex.hasPresident, ex.Donald_Trump))

Look through the predicates (properties) above and add new triples for each one that describes them as any of the following: a reflexive, irreflexive, symmetric, asymmetric, transitive, functional, or an inverse functional property. e.g

g.add((ex.wasLyingTo, RDF.type, OWL.IrreflexiveProperty))

Task. Serialize the ontology and look at the results. Create an owlrl closure as below to infer additional triples and serialize it again. Can you spot the many inferences?

DeductiveClosure(OWLRL_Semantics).expand(graph)

Task. Finally write the ontology to a XML file, and visualise it using http://vowl.visualdataweb.org/webvowl.html. The purpose of WebVOWL is to visualise classes and their properties, so the individuals may not show.

Tip: When you save OWL files as XML, the extension .owl-xml can be used.

Most likely, your ontology is still quite disconnected. Add rdfs:subClassOf, rdfs:domain, and rdfs:range triples to turn it into a more connected graph that represents the domain. Calculate owlrl closures to see the effects of your triples as you add them.

Triples you can use in the first task

@prefix ex: <http://example/org#> .

ex:Mueller_Investigation ex:involved ex:George_Papadopoulos,
        ex:Michael_Cohen,
        ex:Michael_Flynn,
        ex:Paul_Manafort,
        ex:Rick_Gates,
        ex:Roger_Stone ;
    ex:leadBy ex:Robert_Mueller .

ex:Michael_Cohen ex:attorneyFor ex:Donald_Trump ;
    ex:pleadedGuilty ex:Michael_Cohens_Lying .

ex:Michael_Cohens_Lying a ex:Lying ;
    ex:wasLyingAbout ex:Trump_RealEstateDeal ;
    ex:wasLyingTo ex:Congress .

ex:Michael_Flynn ex:adviserTo ex:Donald_Trump ;
    ex:negotiatedAgreement ex:PleaAgreement ;
    ex:pleadedGuilty ex:Michael_Flynns_Lying .

ex:Michael_Flynns_Lying a ex:Lying ;
    ex:wasLyingTo ex:FBI .

ex:Paul_Manafort ex:campaignManager ex:Donald_Trump ;
    ex:chargedWith ex:ForeignLobbying,
        ex:MoneyLaundering,
        ex:TaxEvasion ;
    ex:convictedFor ex:BankAndTaxFraud ;
    ex:hasBusinessPartner ex:Rick_Gates ;
    ex:negotiatedAgreement ex:PleaAgreement ;
    ex:pleadedGuilty ex:Conspiracy ;
    ex:sentencedTo ex:Prison .

ex:Rick_Gates_Lying a ex:Lying ;
    ex:wasLyingTo ex:FBI .

ex:Rick_Gates ex:chargedWith ex:ForeignLobbying,
        ex:MoneyLaundering,
        ex:TaxEvasion ;
    ex:pleadedGuilty ex:Conspiracy,
        ex:Rick_Gates_Lying .

If you have more time

Task. Inspect your ontology with Webprotégé.

  • Register as a new user and log in.
  • Create a new project and use Create from existing sources to upload your OWL/XML file.
  • Explore how to edit and extend your ontology using Protégé.

You can also download Protégé Desktop for free and run it on your local machine. The stand-alone version is even more powerful with lots of plug-ins.