Permalink
Browse files

Object Property Taxonomy

Includes necessary stage, state, computation, converters to OWL API and tests. Constructed in ObjectPropertyTaxonomyComputationFactory by a simple transitive reduction. Cannot be updated incrementally, so no cleaning is needed.
  • Loading branch information...
aifargonos committed Jun 21, 2016
1 parent 11227a3 commit 64aa2a23580358ed4270f3e9a1e79722f43219f0
Showing with 2,855 additions and 319 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 elk-cli/src/main/java/org/semanticweb/elk/cli/Main.java
  3. +2 −2 elk-cli/src/test/java/org/semanticweb/elk/cli/CLIDiffClassificationCorrectnessTest.java
  4. +72 −0 ...cli/src/test/java/org/semanticweb/elk/cli/CLIDiffObjectPropertyClassificationCorrectnessTest.java
  5. +1 −1 elk-cli/src/test/java/org/semanticweb/elk/cli/util/ComputeExpectedTaxonomies.java
  6. +63 −4 elk-ore-parent/elk-ore/src/main/java/org/semanticweb/elk/ore/OreTaxonomyPrinter.java
  7. +29 −0 elk-owlapi/src/main/java/org/semanticweb/elk/owlapi/ElkConverter.java
  8. +114 −22 elk-owlapi/src/main/java/org/semanticweb/elk/owlapi/ElkReasoner.java
  9. +2 −2 elk-owlapi/src/test/java/org/semanticweb/elk/owlapi/OWLAPIDiffClassificationCorrectnessTest.java
  10. +68 −0 ...c/test/java/org/semanticweb/elk/owlapi/OWLAPIDiffObjectPropertyClassificationCorrectnessTest.java
  11. +2 −2 ...lapi/src/test/java/org/semanticweb/elk/owlapi/OWLAPIIncrementalClassificationCorrectnessTest.java
  12. +6 −6 ...wlapi/src/test/java/org/semanticweb/elk/owlapi/OWLAPIRandomWalkIncrementalClassificationTest.java
  13. +103 −0 elk-reasoner/src/main/java/org/semanticweb/elk/reasoner/Reasoner.java
  14. +64 −0 ...in/java/org/semanticweb/elk/reasoner/saturation/properties/ObjectPropertyTaxonomyComputation.java
  15. +371 −0 .../org/semanticweb/elk/reasoner/saturation/properties/ObjectPropertyTaxonomyComputationFactory.java
  16. +98 −1 elk-reasoner/src/main/java/org/semanticweb/elk/reasoner/stages/AbstractReasonerState.java
  17. +94 −0 ...ner/src/main/java/org/semanticweb/elk/reasoner/stages/ObjectPropertyTaxonomyComputationStage.java
  18. +57 −0 elk-reasoner/src/main/java/org/semanticweb/elk/reasoner/stages/ObjectPropertyTaxonomyState.java
  19. +10 −7 elk-reasoner/src/main/java/org/semanticweb/elk/reasoner/stages/ReasonerStageManager.java
  20. +204 −0 ...easoner/src/main/java/org/semanticweb/elk/reasoner/taxonomy/ConcurrentObjectPropertyTaxonomy.java
  21. +78 −0 elk-reasoner/src/main/java/org/semanticweb/elk/reasoner/taxonomy/ElkObjectPropertyKeyProvider.java
  22. +232 −169 elk-reasoner/src/main/java/org/semanticweb/elk/reasoner/taxonomy/TaxonomyPrinter.java
  23. +22 −17 ...r/src/main/java/org/semanticweb/elk/reasoner/taxonomy/impl/AbstractUpdateableGenericTaxonomy.java
  24. +4 −4 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/BaseClassificationCorrectnessTest.java
  25. +124 −0 ...r/src/test/java/org/semanticweb/elk/reasoner/BaseObjectPropertyClassificationCorrectnessTest.java
  26. +6 −6 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/DiffClassificationCorrectnessTest.java
  27. +98 −0 ...r/src/test/java/org/semanticweb/elk/reasoner/DiffObjectPropertyClassificationCorrectnessTest.java
  28. +2 −2 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/HashClassificationCorrectnessTest.java
  29. +1 −1 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/HashConfigurationUtils.java
  30. +1 −1 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/HashTaxonomyTestManifest.java
  31. +1 −1 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/InstanceTaxonomyTestOutput.java
  32. +1 −1 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/TaxonomyDiffManifest.java
  33. +4 −4 ...c/test/java/org/semanticweb/elk/reasoner/{ClassTaxonomyTestOutput.java → TaxonomyTestOutput.java}
  34. +8 −8 ...t/java/org/semanticweb/elk/reasoner/incremental/BaseIncrementalClassificationCorrectnessTest.java
  35. +6 −6 ...test/java/org/semanticweb/elk/reasoner/incremental/BaseIncrementalRealizationCorrectnessTest.java
  36. +3 −3 .../test/java/org/semanticweb/elk/reasoner/incremental/BaseRandomWalkIncrementalCorrectnessTest.java
  37. +2 −2 .../test/java/org/semanticweb/elk/reasoner/incremental/IncrementalClassificationCorrectnessTest.java
  38. +2 −2 ...src/test/java/org/semanticweb/elk/reasoner/incremental/IncrementalRealizationCorrectnessTest.java
  39. +5 −5 .../org/semanticweb/elk/reasoner/incremental/RandomWalkIncrementalClassificationCorrectnessTest.java
  40. +1 −1 ...test/java/org/semanticweb/elk/reasoner/incremental/RandomWalkIncrementalClassificationRunner.java
  41. +198 −0 ...easoner/src/test/java/org/semanticweb/elk/reasoner/taxonomy/MockObjectPropertyTaxonomyLoader.java
  42. +334 −0 ...c/test/java/org/semanticweb/elk/reasoner/taxonomy/ObjectPropertyTaxonomyMemberComparisonTest.java
  43. +111 −38 elk-reasoner/src/test/java/org/semanticweb/elk/reasoner/taxonomy/TaxonomyIOTest.java
  44. +7 −0 elk-reasoner/src/test/resources/io/property_inconsistent.owl
  45. +17 −0 elk-reasoner/src/test/resources/io/property_taxonomy.owl
  46. +13 −0 elk-reasoner/src/test/resources/io/property_taxonomy_eq_1.owl
  47. +13 −0 elk-reasoner/src/test/resources/io/property_taxonomy_eq_2.owl
  48. +15 −0 elk-reasoner/src/test/resources/property_classification_test_input/Ancestors.expected
  49. +11 −0 elk-reasoner/src/test/resources/property_classification_test_input/Ancestors.owl
  50. +11 −0 elk-reasoner/src/test/resources/property_classification_test_input/Bottom.expected
  51. +10 −0 elk-reasoner/src/test/resources/property_classification_test_input/Bottom.owl
  52. +9 −0 elk-reasoner/src/test/resources/property_classification_test_input/Cycle.expected
  53. +11 −0 elk-reasoner/src/test/resources/property_classification_test_input/Cycle.owl
  54. +11 −0 elk-reasoner/src/test/resources/property_classification_test_input/Equivalent.expected
  55. +10 −0 elk-reasoner/src/test/resources/property_classification_test_input/Equivalent.owl
  56. +9 −0 elk-reasoner/src/test/resources/property_classification_test_input/Inconsistent.expected
  57. +11 −0 elk-reasoner/src/test/resources/property_classification_test_input/Inconsistent.owl
  58. +12 −0 elk-reasoner/src/test/resources/property_classification_test_input/Top.expected
  59. +9 −0 elk-reasoner/src/test/resources/property_classification_test_input/Top.owl
  60. +8 −0 elk-reasoner/src/test/resources/property_classification_test_input/TopSubproperties.expected
  61. +9 −0 elk-reasoner/src/test/resources/property_classification_test_input/TopSubproperties.owl
  62. +16 −0 elk-reasoner/src/test/resources/taxonomy_member_comparison/property_member_set.owl
  63. +16 −0 elk-reasoner/src/test/resources/taxonomy_member_comparison/property_node_lookup.owl
  64. +21 −0 elk-reasoner/src/test/resources/taxonomy_member_comparison/property_related_nodes.owl
View
@@ -6,3 +6,4 @@ plugin.xml
.project
.idea
*.iml
**/catalog-v???.xml
@@ -232,7 +232,7 @@ static void writeClassTaxonomyToFile(File file, Taxonomy<ElkClass> taxonomy, boo
LOGGER_.info("Writing taxonomy to {}", file);
Statistics.logOperationStart("Writing taxonomy", LOGGER_);
TaxonomyPrinter.dumpClassTaxomomyToFile(taxonomy, file.getPath(), printHash);
TaxonomyPrinter.dumpTaxomomyToFile(taxonomy, file.getPath(), printHash);
Statistics.logOperationFinish("Writing taxonomy", LOGGER_);
}
@@ -33,7 +33,7 @@
import org.semanticweb.elk.loading.Owl2StreamLoader;
import org.semanticweb.elk.owl.parsing.Owl2ParseException;
import org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParserFactory;
import org.semanticweb.elk.reasoner.ClassTaxonomyTestOutput;
import org.semanticweb.elk.reasoner.TaxonomyTestOutput;
import org.semanticweb.elk.reasoner.DiffClassificationCorrectnessTest;
import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.ReasonerFactory;
@@ -56,7 +56,7 @@
}
public CLIDiffClassificationCorrectnessTest(
final ReasoningTestManifest<ClassTaxonomyTestOutput<?>, ClassTaxonomyTestOutput<?>> testManifest) {
final ReasoningTestManifest<TaxonomyTestOutput<?>, TaxonomyTestOutput<?>> testManifest) {
super(testManifest);
}
@@ -0,0 +1,72 @@
/*
* #%L
* ELK Command Line Interface
*
* $Id$
* $HeadURL$
* %%
* Copyright (C) 2011 - 2012 Department of Computer Science, University of Oxford
* %%
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* #L%
*/
package org.semanticweb.elk.cli;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import org.semanticweb.elk.loading.AxiomLoader;
import org.semanticweb.elk.loading.Owl2StreamLoader;
import org.semanticweb.elk.owl.parsing.Owl2ParseException;
import org.semanticweb.elk.owl.parsing.javacc.Owl2FunctionalStyleParserFactory;
import org.semanticweb.elk.reasoner.TaxonomyTestOutput;
import org.semanticweb.elk.reasoner.DiffObjectPropertyClassificationCorrectnessTest;
import org.semanticweb.elk.reasoner.Reasoner;
import org.semanticweb.elk.reasoner.ReasonerFactory;
import org.semanticweb.elk.reasoner.ReasoningTestManifest;
import org.semanticweb.elk.reasoner.stages.RestartingStageExecutor;
import org.semanticweb.elk.testing.TestInput;
/**
* @author Peter Skocovsky
*/
public class CLIDiffObjectPropertyClassificationCorrectnessTest
extends DiffObjectPropertyClassificationCorrectnessTest {
static final String[] IGNORE_LIST = { "Inconsistent.owl" };
static {
Arrays.sort(IGNORE_LIST);
}
public CLIDiffObjectPropertyClassificationCorrectnessTest(
final ReasoningTestManifest<TaxonomyTestOutput<?>, TaxonomyTestOutput<?>> testManifest) {
super(testManifest);
}
@Override
protected Reasoner createReasoner(final InputStream input)
throws Owl2ParseException, IOException {
final AxiomLoader loader = new Owl2StreamLoader(
new Owl2FunctionalStyleParserFactory(), input);
return new ReasonerFactory().createReasoner(loader,
new RestartingStageExecutor());
}
@Override
protected boolean ignore(TestInput input) {
return super.ignore(input)
|| Arrays.binarySearch(IGNORE_LIST, input.getName()) >= 0;
}
}
@@ -80,7 +80,7 @@ public static void main(String[] args) throws Exception {
@Override
public void dumpTaxonomy(Taxonomy<ElkClass> taxonomy,
Writer writer) throws IOException {
TaxonomyPrinter.dumpClassTaxomomy(taxonomy, writer,
TaxonomyPrinter.dumpTaxomomy(taxonomy, writer,
false);
}
});
@@ -32,32 +32,43 @@
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
import org.semanticweb.elk.io.IOUtils;
import org.semanticweb.elk.owl.interfaces.ElkClass;
import org.semanticweb.elk.owl.interfaces.ElkClassAssertionAxiom;
import org.semanticweb.elk.owl.interfaces.ElkDeclarationAxiom;
import org.semanticweb.elk.owl.interfaces.ElkEntity;
import org.semanticweb.elk.owl.interfaces.ElkEquivalentClassesAxiom;
import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual;
import org.semanticweb.elk.owl.interfaces.ElkObject;
import org.semanticweb.elk.owl.interfaces.ElkSameIndividualAxiom;
import org.semanticweb.elk.owl.interfaces.ElkSubClassOfAxiom;
import org.semanticweb.elk.owl.managers.ElkObjectEntityRecyclingFactory;
import org.semanticweb.elk.owl.predefined.PredefinedElkIris;
import org.semanticweb.elk.owl.printers.OwlFunctionalStylePrinter;
import org.semanticweb.elk.reasoner.taxonomy.TaxonomyPrinter;
import org.semanticweb.elk.reasoner.taxonomy.ElkClassKeyProvider;
import org.semanticweb.elk.reasoner.taxonomy.ElkIndividualKeyProvider;
import org.semanticweb.elk.reasoner.taxonomy.model.InstanceNode;
import org.semanticweb.elk.reasoner.taxonomy.model.InstanceTaxonomy;
import org.semanticweb.elk.reasoner.taxonomy.model.Taxonomy;
import org.semanticweb.elk.reasoner.taxonomy.model.TaxonomyNode;
/**
* A wrapper around {@link TaxonomyPrinter} to satisfy the ORE specification
* TaxonomyPrinter that satisfies the ORE specification
*
* @author Pavel Klinov
*
* pavel.klinov@uni-ulm.de
*/
public class OreTaxonomyPrinter extends TaxonomyPrinter {
public class OreTaxonomyPrinter {
protected static Comparator<ElkEntity>
CLASS_COMPARATOR = ElkClassKeyProvider.INSTANCE.getComparator(),
INDIVIDUAL_COMPARATOR = ElkIndividualKeyProvider.INSTANCE.getComparator();
// prints SubClassOf(A, owl:Thing) for all direct subclasses of owl:Thing
static void printClassTaxonomy(Taxonomy<ElkClass> taxonomy, File out)
@@ -143,6 +154,41 @@ protected static void processTaxomomy(Taxonomy<ElkClass> classTaxonomy,
}
}
/**
* Prints class declarations
*
* @param classTaxonomy
* @param objectFactory
* @param writer
* @throws IOException
*/
protected static void printDeclarations(Taxonomy<ElkClass> classTaxonomy,
ElkObject.Factory objectFactory, Appendable writer)
throws IOException {
List<ElkClass> classes = new ArrayList<ElkClass>(classTaxonomy
.getNodes().size() * 2);
for (TaxonomyNode<ElkClass> classNode : classTaxonomy.getNodes()) {
for (ElkClass clazz : classNode) {
if (!clazz.getIri().equals(PredefinedElkIris.OWL_THING)
&& !clazz.getIri()
.equals(PredefinedElkIris.OWL_NOTHING)) {
classes.add(clazz);
}
}
}
Collections.sort(classes, CLASS_COMPARATOR);
for (ElkClass clazz : classes) {
ElkDeclarationAxiom decl = objectFactory.getDeclarationAxiom(clazz);
OwlFunctionalStylePrinter.append(writer, decl, true);
writer.append('\n');
}
}
protected static void processInstanceTaxomomy(
InstanceTaxonomy<ElkClass, ElkNamedIndividual> taxonomy,
Writer writer) throws IOException {
@@ -186,6 +232,19 @@ protected static void processInstanceTaxomomy(
}
}
protected static void printIndividualDeclarations(
Set<? extends InstanceNode<ElkClass, ElkNamedIndividual>> individualNodes,
ElkObject.Factory objectFactory, Writer writer) throws IOException {
for (InstanceNode<ElkClass, ElkNamedIndividual> individualNode : individualNodes) {
for (ElkNamedIndividual individual : individualNode) {
ElkDeclarationAxiom decl = objectFactory
.getDeclarationAxiom(individual);
OwlFunctionalStylePrinter.append(writer, decl, true);
writer.append('\n');
}
}
}
protected static void printClassAxioms(ElkClass elkClass,
ArrayList<ElkClass> orderedEquivalentClasses,
TreeSet<ElkClass> orderedSubClasses, Appendable writer)
@@ -232,4 +291,4 @@ protected static void printIndividualAxioms(ElkNamedIndividual individual,
writer.append('\n');
}
}
}
}
@@ -32,20 +32,26 @@
import org.semanticweb.elk.exceptions.ElkRuntimeException;
import org.semanticweb.elk.owl.interfaces.ElkClass;
import org.semanticweb.elk.owl.interfaces.ElkNamedIndividual;
import org.semanticweb.elk.owl.interfaces.ElkObjectProperty;
import org.semanticweb.elk.reasoner.taxonomy.model.Node;
import org.semanticweb.owlapi.model.OWLClass;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
import org.semanticweb.owlapi.model.OWLObjectProperty;
import org.semanticweb.owlapi.model.OWLObjectPropertyExpression;
import org.semanticweb.owlapi.model.OWLRuntimeException;
import org.semanticweb.owlapi.reasoner.impl.OWLClassNode;
import org.semanticweb.owlapi.reasoner.impl.OWLClassNodeSet;
import org.semanticweb.owlapi.reasoner.impl.OWLNamedIndividualNode;
import org.semanticweb.owlapi.reasoner.impl.OWLNamedIndividualNodeSet;
import org.semanticweb.owlapi.reasoner.impl.OWLObjectPropertyNode;
import org.semanticweb.owlapi.reasoner.impl.OWLObjectPropertyNodeSet;
/**
* Facade class for conversion from ELK objects to OWL API objects.
*
* @author Yevgeny Kazakov
* @author Markus Kroetzsch
* @author Peter Skocovsky
*/
public class ElkConverter {
@@ -74,6 +80,11 @@ public OWLNamedIndividual convert(ElkNamedIndividual ind) {
return ELK_ENTITY_CONVERTER.visit(ind);
}
@SuppressWarnings("static-method")
public OWLObjectProperty convert(final ElkObjectProperty prop) {
return ELK_ENTITY_CONVERTER.visit(prop);
}
public OWLClassNode convertClassNode(Node<ElkClass> node) {
Set<OWLClass> owlClasses = new HashSet<OWLClass>();
for (ElkClass cls : node) {
@@ -109,6 +120,24 @@ public OWLNamedIndividualNodeSet convertIndividualNodes(
return new OWLNamedIndividualNodeSet(owlNodes);
}
public OWLObjectPropertyNode convertObjectPropertyNode(
final Node<ElkObjectProperty> node) {
final Set<OWLObjectPropertyExpression> owlObjectProps = new HashSet<OWLObjectPropertyExpression>();
for (final ElkObjectProperty cls : node) {
owlObjectProps.add(convert(cls));
}
return new OWLObjectPropertyNode(owlObjectProps);
}
public OWLObjectPropertyNodeSet convertObjectPropertyNodes(
final Iterable<? extends Node<ElkObjectProperty>> nodes) {
Set<org.semanticweb.owlapi.reasoner.Node<OWLObjectPropertyExpression>> owlNodes = new HashSet<org.semanticweb.owlapi.reasoner.Node<OWLObjectPropertyExpression>>();
for (final Node<ElkObjectProperty> node : nodes) {
owlNodes.add(convertObjectPropertyNode(node));
}
return new OWLObjectPropertyNodeSet(owlNodes);
}
@SuppressWarnings("static-method")
public OWLRuntimeException convert(ElkException e) {
return ELK_EXCEPTION_CONVERTER.convert(e);
Oops, something went wrong.

0 comments on commit 64aa2a2

Please sign in to comment.