Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create skeleton for adding indirect existentials in materialize #1215

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions docs/examples/hubcap.owl
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2/"
xml:base="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2/"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:xml="http://www.w3.org/XML/1998/namespace"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2"/>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#has_part -->
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are very ugly IRIs, maybe run a string replace on the file to replace

http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2

with something like

http://example.org/ontology


<owl:ObjectProperty rdf:about="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#has_part">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#TransitiveProperty"/>
</owl:ObjectProperty>



<!--
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
-->




<!-- http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#car -->

<owl:Class rdf:about="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#car">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#has_part"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#wheel"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>



<!-- http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#convertible -->

<owl:Class rdf:about="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#convertible">
<rdfs:subClassOf rdf:resource="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#car"/>
</owl:Class>



<!-- http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#hubcap -->

<owl:Class rdf:about="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#hubcap"/>



<!-- http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#wheel -->

<owl:Class rdf:about="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#wheel">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#has_part"/>
<owl:someValuesFrom rdf:resource="http://www.semanticweb.org/vinicius/ontologies/2024/7/untitled-ontology-2#hubcap"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
</rdf:RDF>



<!-- Generated by the OWL API (version 4.5.29.2024-05-13T12:11:03Z) https://github.com/owlcs/owlapi -->

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public MaterializeCommand() {
o.addOption("o", "output", true, "save reasoned ontology to a file");
o.addOption("t", "term", true, "a property to materialize");
o.addOption("T", "term-file", true, "load properties from a file");
o.addOption(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

option should be "false" by default

"c", "include-indirect", true, "if true include redundant existential restrictions");
options = o;
}

Expand Down Expand Up @@ -131,6 +133,8 @@ public CommandState execute(CommandState state, String[] args) throws Exception
}
}

boolean includeIndirect = CommandLineHelper.getBooleanValue(line, "include-indirect", false);

Set<IRI> terms = CommandLineHelper.getTerms(ioHelper, line, true);
Set<OWLObjectProperty> properties = new HashSet<>();
for (IRI term : terms) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public static void materialize(
* @param options A map of options for the operation
* @param reasonOverImportsClosure if true will first perform materialization over all ontologies
* in the import closure
* @param includeIndirect if true include redundant existential restrictions
* @throws OWLOntologyCreationException on ontology problem
* @throws OntologyLogicException on logic problem
*/
Expand All @@ -87,12 +88,37 @@ public static void materialize(
Map<String, String> options,
boolean reasonOverImportsClosure)
throws OntologyLogicException, OWLOntologyCreationException {
materialize(ontology, reasonerFactory, properties, options, reasonOverImportsClosure, false);
}

/**
* Replace EquivalentClass axioms with weaker SubClassOf axioms.
*
* @param ontology The OWLOntology to relax
* @param reasonerFactory reasoner factory for the reasoner that is to be wrapped
* @param properties object properties whose existentials are to be materialized (null
* materializes all)
* @param options A map of options for the operation
* @param reasonOverImportsClosure if true will first perform materialization over all ontologies
* in the import closure
* @throws OWLOntologyCreationException on ontology problem
* @throws OntologyLogicException on logic problem
*/
public static void materialize(
OWLOntology ontology,
OWLReasonerFactory reasonerFactory,
Set<OWLObjectProperty> properties,
Map<String, String> options,
boolean reasonOverImportsClosure,
boolean includeIndirect)
throws OntologyLogicException, OWLOntologyCreationException {

if (reasonOverImportsClosure) {
logger.info("Materializing imported ontologies...");
for (OWLOntology importedOntology : ontology.getImportsClosure()) {
if (!importedOntology.equals(ontology)) {
materialize(importedOntology, reasonerFactory, properties, options, false);
materialize(
importedOntology, reasonerFactory, properties, options, false, includeIndirect);
}
}
}
Expand Down Expand Up @@ -143,7 +169,7 @@ public static void materialize(
logger.debug("Excluding classes not in main ontology: " + c);
continue;
}
Set<OWLClassExpression> sces = emr.getSuperClassExpressions(c, true);
Set<OWLClassExpression> sces = emr.getSuperClassExpressions(c, !includeIndirect);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok this seems to make sense! Needs someone from gene ontology reasoner time to check.. @balhoff @cmungall

if (!emr.isSatisfiable(c)) {
logger.error("Ontology is not coherent! Unsatisfiable: " + c);
throw new IncoherentTBoxException(Collections.singleton(c));
Expand Down
Loading