Lab: OWL 1: Difference between revisions
No edit summary |
(→Tasks) |
||
Line 22: | Line 22: | ||
* Tax evation is a kind of bank and tax fraud. | * 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.'' . | * 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:Organization''s. | * Congress, FBI and the Mueller investigation are ''foaf:Organization''s. | ||
* Nothing can be both a person and an organization. | * Nothing can be both a person and an organization. | ||
Line 28: | Line 29: | ||
* Donald Trump is a politician and a Republican. | * Donald Trump is a politician and a Republican. | ||
* A Republican politician is both a politician and a Republican. | * A Republican politician is both a politician and a Republican. | ||
'''Task 2''' | '''Task 2''' | ||
<syntaxhighlight> | <syntaxhighlight> | ||
g.add((ex:Paul_Manafort, ex:hasBusinessPartner ex:Rick_Gates)) | g.add((ex:Paul_Manafort, ex:hasBusinessPartner, ex:Rick_Gates)) | ||
g.add((ex:Michael_Flynn ex:adviserTo ex:Donald_Trump)) | g.add((ex:Michael_Flynn, ex:adviserTo, ex:Donald_Trump)) | ||
g.add((ex:Rick_Gates_Lying ex:wasLyingTo ex:FBI)) | g.add((ex:Rick_Gates_Lying, ex:wasLyingTo, ex:FBI)) | ||
g.add((ex:Donald_Trump ex:presidentOf ex:USA)) | g.add((ex:Donald_Trump, ex:presidentOf, ex:USA)) | ||
g.add((ex:USA ex: | g.add((ex:USA, ex:hasPresident, ex:Donald_Trump)) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
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. | 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 | e.g | ||
<syntaxhighlight> | <syntaxhighlight> |
Revision as of 16:10, 12 March 2023
Topics
Basic OWL ontology programming with RDFlib and owlrl.
WebVOWL visualisation.
RDF and RDFS might be relevant too.
Classes/Vocabularies
Vocabulary:
- OWL (sameAs, equivalentClass, equivalentProperty, differentFrom, disjointWith, inverseOf)
- OWL (SymmetricProperty, AsymmetricProperty, ReflexiveProperty, IrreflexiveProperty, TransitiveProperty, FunctionalProperty, InverseFunctionalProperty, AllDifferent)
Tasks
Task 1
Write OWL triples that corresponds to the following text. .If you can, try to build on your example from labs 1 and 2, or extend the triples at the bottom of the 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 2
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 3
Print/Serialize the ontology. Then use owlrl as below to infer additional triples. Can you spot the many inferences?
DeductiveClosure(OWLRL_Semantics).expand(graph)
Finally write the ontology to a XML file, and visualise it using https://service.tib.eu/webvowl/. The purpose of WebVOWL is to visualise classes and their properties, so the individuals may not show.
Useful Reading
Triples you can extend for the tasks
Turtle
@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 .