Lab Solutions: Difference between revisions

From info216
(Added proposed solution for Lab 11 - OWL)
No edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Here we will present suggested solutions after each lab. ''The page will be updated as the course progresses''
Here we will present suggested solutions after each lab. ''The page will be updated as the course progresses''


<!--
=Getting started (Lab 1)=
=Getting started (Lab 1)=


Line 334: Line 335:
       OPTIONAL{
       OPTIONAL{
         ?s ns1:pardoned ?pardon .
         ?s ns1:pardoned ?pardon .
         FILTER (?pardon = ns1:true)
         FILTER (?pardon = true)
       }
       }
}
}
Line 1,647: Line 1,648:


</syntaxhighlight>
</syntaxhighlight>
=OWL 2 (Lab 12)=
<syntaxhighlight lang="Python">
@prefix : <http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#> .
@prefix dc: <http://purl.org/dc/terms#> .
@prefix io: <http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#> .
@prefix dbr: <http://dbpedia.org/resource/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix prov: <http://www.w3.org/ns/prov#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#> .
<http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology> rdf:type owl:Ontology .
#################################################################
#    Object Properties
#################################################################
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#indictedIn
io:indictedIn rdf:type owl:ObjectProperty ;
              rdfs:subPropertyOf io:involvedIn ;
              rdfs:domain io:InvestigatedPerson ;
              rdfs:range io:Investigation .
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#investigating
io:investigating rdf:type owl:ObjectProperty ;
                rdfs:subPropertyOf io:involvedIn ;
                rdfs:domain io:Investigator ;
                rdfs:range io:Investigation .
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#involvedIn
io:involvedIn rdf:type owl:ObjectProperty ;
              rdfs:domain foaf:Person ;
              rdfs:range io:Investigation .
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#leading
io:leading rdf:type owl:ObjectProperty ;
          rdfs:subPropertyOf io:investigating ;
          rdfs:domain io:InvestigationLeader ;
          rdfs:range io:Investigation .
#################################################################
#    Data properties
#################################################################
###  http://purl.org/dc/elements/1.1/description
<http://purl.org/dc/elements/1.1/description> rdf:type owl:DatatypeProperty ;
                                              rdfs:domain io:Investigation ;
                                              rdfs:range xsd:string .
###  http://www.w3.org/ns/prov#endedAtTime
prov:endedAtTime rdf:type owl:DatatypeProperty ,
                          owl:FunctionalProperty ;
                rdfs:domain io:Investigation ;
                rdfs:range xsd:dateTime .
###  http://www.w3.org/ns/prov#startedAtTime
prov:startedAtTime rdf:type owl:DatatypeProperty ,
                            owl:FunctionalProperty ;
                  rdfs:domain io:Investigation ;
                  rdfs:range xsd:dateTime .
###  http://xmlns.com/foaf/0.1/name
foaf:name rdf:type owl:DatatypeProperty ;
          rdfs:domain foaf:Person ;
          rdfs:range xsd:string .
###  http://xmlns.com/foaf/0.1/title
foaf:title rdf:type owl:DatatypeProperty ;
          rdfs:domain io:Investigation ;
          rdfs:range xsd:string .
#################################################################
#    Classes
#################################################################
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#InvestigatedPerson
io:InvestigatedPerson rdf:type owl:Class ;
                      rdfs:subClassOf io:Person ;
                      owl:disjointWith io:Investigator .
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#Investigation
io:Investigation rdf:type owl:Class .
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#InvestigationLeader
io:InvestigationLeader rdf:type owl:Class ;
                      rdfs:subClassOf io:Investigator .
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#Investigator
io:Investigator rdf:type owl:Class ;
                rdfs:subClassOf io:Person .
###  http://www.semanticweb.org/bruker/ontologies/2023/2/InvestigationOntology#Person
io:Person rdf:type owl:Class ;
          rdfs:subClassOf foaf:Person .
###  http://xmlns.com/foaf/0.1/Person
foaf:Person rdf:type owl:Class .
#################################################################
#    Individuals
#################################################################
###  http://dbpedia.org/resource/Donald_Trump
dbr:Donald_Trump rdf:type owl:NamedIndividual ;
                foaf:name "Donald Trump" .
###  http://dbpedia.org/resource/Elizabeth_Prelogar
dbr:Elizabeth_Prelogar rdf:type owl:NamedIndividual ;
                      io:investigating <http://dbpedia.org/resource/Special_Counsel_investigation_(2017–2019)> ;
                      foaf:name "Elizabeth Prelogar" .
###  http://dbpedia.org/resource/Michael_Flynn
dbr:Michael_Flynn rdf:type owl:NamedIndividual ;
                  foaf:name "Michael Flynn" .
###  http://dbpedia.org/resource/Paul_Manafort
dbr:Paul_Manafort rdf:type owl:NamedIndividual ;
                  io:indictedIn <http://dbpedia.org/resource/Special_Counsel_investigation_(2017–2019)> ;
                  foaf:name "Paul Manafort" .
###  http://dbpedia.org/resource/Robert_Mueller
dbr:Robert_Mueller rdf:type owl:NamedIndividual ;
                  io:leading <http://dbpedia.org/resource/Special_Counsel_investigation_(2017–2019)> ;
                  foaf:name "Robert Mueller" .
###  http://dbpedia.org/resource/Roger_Stone
dbr:Roger_Stone rdf:type owl:NamedIndividual ;
                foaf:name "Roger Stone" .
###  http://dbpedia.org/resource/Special_Counsel_investigation_(2017–2019)
<http://dbpedia.org/resource/Special_Counsel_investigation_(2017–2019)> rdf:type owl:NamedIndividual ;
                                                                        foaf:title "Mueller Investigation" .
#################################################################
#    General axioms
#################################################################
[ rdf:type owl:AllDifferent ;
  owl:distinctMembers ( dbr:Donald_Trump
                        dbr:Elizabeth_Prelogar
                        dbr:Michael_Flynn
                        dbr:Paul_Manafort
                        dbr:Robert_Mueller
                        dbr:Roger_Stone
                      )
] .
###  Generated by the OWL API (version 4.5.25.2023-02-15T19:15:49Z) https://github.com/owlcs/owlapi
</syntaxhighlight>
=Using Graph Embeddings (Lab 13)=
https://colab.research.google.com/drive/1WkRJUeUBVF5yVv7o0pOKfsd4pqG6369k
=Training Graph Embeddings (Lab 14)=
https://colab.research.google.com/drive/1jKpzlQ7gYTVzgphJsrK5iuMpFhkrY96q
-->

Latest revision as of 10:56, 20 January 2025

Here we will present suggested solutions after each lab. The page will be updated as the course progresses