Skip to content

Commit

Permalink
Merge pull request #26 from mrnolte/playground
Browse files Browse the repository at this point in the history
Playground
  • Loading branch information
mrnolte authored May 14, 2024
2 parents b21e3d9 + ec774da commit 8bcce22
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 12 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Documentation
on:
push:
paths:
- 'owl/**'
- 'docs/**'
- '.github/**'
workflow_dispatch:
workflow_run:
workflows: ["Evaluation"]
types:
- completed

jobs:
vocabulary:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: SOMA Vocabulary
runs-on: ubuntu-latest
defaults:
Expand Down Expand Up @@ -36,6 +37,7 @@ jobs:
path: ./SOMA-vocabulary.pdf

handbook:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
name: NEEM Handbook
runs-on: ubuntu-latest

Expand Down
8 changes: 4 additions & 4 deletions docs/vocab/SOMA-vocabulary.tex
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
\usepackage{pythontex}
\usepackage{multicol}
\usepackage{microtype} % Improves spacing
\usepackage{fancyhdr}
\usepackage{fancyhdr}
\fancyhead[L]{\rightmark}
\fancyhead[R]{\leftmark}
\fancyhead[R]{\leftmark}

\pagestyle{fancy}
\pagestyle{fancy}
\newcommand{\appendixstyle}[2]{\textbf{#1}\markboth{#1}{#1}\ {#2}}

\begin{document}
Expand All @@ -18,7 +18,7 @@
from owl_reader import OWLReader

OWL_FILES=[
"https://raw.githubusercontent.com/ease-crc/soma/master/owl/SOMA.owl"
"https://ease-crc.github.io/soma/owl/current/SOMA.owl"
]

reader = OWLReader(OWL_FILES)
Expand Down
4 changes: 3 additions & 1 deletion docs/vocab/owl_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, iri_list):
self.class_objects = []

def get_classes(self):
'''
'''
Gets the classes defined in the ontology their corresponding
superclass, label and comment
'''
Expand Down Expand Up @@ -54,6 +54,8 @@ def _create_class_objects(self):
return objects

def set_class_info(self, target_class):
class_obj = getattr(getattr(self.namespace, target_class)
print(f"Class_obj {class_obj}")

comment = getattr(getattr(self.namespace, target_class), "comment")
if(comment):
Expand Down
2 changes: 1 addition & 1 deletion owl/USD.owl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:xformOp="https://ease-crc.org/ont/USD#xformOp:">
<owl:Ontology rdf:about="https://ease-crc.org/ont/USD.owl">
<owl:imports rdf:resource="http://www.ontologydesignpatterns.org/ont/dul/DUL.owl"/>
<owl:imports rdf:resource="http://www.ease-crc.org/ont/DUL.owl"/>
<rdfs:comment rdf:datatype="http://www.w3.org/2001/XMLSchema#string">The purpose of the USD ontology is to establish a graph model of the USD language, and to support translation from USD to a KG representation of scene graphs. To this end, the core vocabulary of USD is defined in terms of an upper-level ontology. In addition, a set of re-usable built-in schemata that are used in the USD language to describe prims are defined. In order to fasciliate translation, the ontological model attempts to replicate the structure of USD as closely as possible while in addition entailing semantics of USD entities.</rdfs:comment>
<rdfs:label>USD Ontology</rdfs:label>
<owl:versionInfo rdf:datatype="http://www.w3.org/2001/XMLSchema#string">0.1</owl:versionInfo>
Expand Down
35 changes: 35 additions & 0 deletions scripts/java/src/main/java/main/GuardingXmlCatalogIriMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package main;

import org.protege.xmlcatalog.CatalogUtilities;
import org.protege.xmlcatalog.XMLCatalog;
import org.protege.xmlcatalog.entry.Entry;
import org.protege.xmlcatalog.redirect.UriRedirectVisitor;
import org.semanticweb.owlapi.model.IRI;
import org.semanticweb.owlapi.model.OWLOntologyIRIMapper;

import java.io.File;
import java.io.IOException;

public class GuardingXmlCatalogIriMapper implements OWLOntologyIRIMapper {
private final XMLCatalog catalog;

public GuardingXmlCatalogIriMapper(File f) throws IOException {
this(CatalogUtilities.parseDocument(f.toURI().toURL()));
}

public GuardingXmlCatalogIriMapper(XMLCatalog catalog) {
this.catalog = catalog;
}

public IRI getDocumentIRI(IRI original) {
UriRedirectVisitor visitor = new UriRedirectVisitor(original.toURI());

for (Entry subEntry : catalog.getEntries()) {
subEntry.accept(visitor);
if (visitor.getRedirect() != null) {
return IRI.create(visitor.getRedirect());
}
}
throw new RuntimeException("You are trying to load an ontology from an online source, but we decided to self-host them, e.g, DUL. The ontology you are trying to load is: " + original);
}
}
6 changes: 5 additions & 1 deletion scripts/java/src/main/java/main/OntologyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ public OntologyManager(final OntologyConfig config) throws OWLOntologyCreationEx

@SuppressWarnings("OverlyBroadThrowsClause")
private void loadCatalog(final Path ontologyDirectory) throws IOException {
final OWLOntologyIRIMapper xmlCatalogIriMapper = new XMLCatalogIRIMapper(
// use this if you want to prohibit ontologies being loaded from online
final OWLOntologyIRIMapper xmlCatalogIriMapper = new GuardingXmlCatalogIriMapper(
ontologyDirectory.resolve(XML_CATALOG_PATH).toFile());
// use this if you want to allow to load ontologies from online
// final OWLOntologyIRIMapper xmlCatalogIriMapper = new XMLCatalogIRIMapper(
// ontologyDirectory.resolve(XML_CATALOG_PATH).toFile());
ontologyManager.getIRIMappers().add(xmlCatalogIriMapper);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void run() throws OWLOntologyStorageException {
if (ontologyConfig.format() == null) {
ontology.saveOntology();
} else {
LOGGER.info("Using format {}", ontologyConfig.format());
ontology.saveOntology(ontologyConfig.format());
}
}
Expand Down

0 comments on commit 8bcce22

Please sign in to comment.