Skip to content

Commit

Permalink
Adds equivalentProperties to graph for #109
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Condit committed May 15, 2015
1 parent a0d4882 commit 6401cbe
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import static com.google.common.collect.Lists.transform;
import static edu.sdsc.scigraph.owlapi.OwlApiUtils.getIri;

import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand All @@ -42,6 +43,7 @@
import org.semanticweb.owlapi.model.OWLDifferentIndividualsAxiom;
import org.semanticweb.owlapi.model.OWLDisjointClassesAxiom;
import org.semanticweb.owlapi.model.OWLEquivalentClassesAxiom;
import org.semanticweb.owlapi.model.OWLEquivalentObjectPropertiesAxiom;
import org.semanticweb.owlapi.model.OWLIndividual;
import org.semanticweb.owlapi.model.OWLLiteral;
import org.semanticweb.owlapi.model.OWLNamedIndividual;
Expand Down Expand Up @@ -70,6 +72,7 @@

import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.collect.Collections2;

import edu.sdsc.scigraph.frames.CommonProperties;
import edu.sdsc.scigraph.frames.EdgeProperties;
Expand Down Expand Up @@ -382,6 +385,21 @@ public Void visit(OWLSubObjectPropertyOfAxiom axiom) {
return null;
}

@Override
public Void visit(OWLEquivalentObjectPropertiesAxiom axiom) {
Collection<Long> nodes =
Collections2.transform(axiom.getObjectPropertiesInSignature(), new Function<OWLObjectProperty, Long>() {

@Override
public Long apply(OWLObjectProperty objectProperty) {
return getOrCreateNode(getIri(objectProperty));
}
});

graph.createRelationshipsPairwise(nodes, OwlRelationships.OWL_EQUIVALENT_OBJECT_PROPERTY);
return null;
}

@Override
public Void visit(OWLSubPropertyChainOfAxiom axiom) {
long chain = getOrCreateNode(getIri(axiom.getSuperProperty()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class OwlRelationships {
public static final RelationshipType RDFS_SUB_PROPERTY_OF = DynamicRelationshipType
.withName(getFragment(OWLRDFVocabulary.RDFS_SUB_PROPERTY_OF));

public static final RelationshipType OWL_EQUIVALENT_OBJECT_PROPERTY = DynamicRelationshipType
.withName(getFragment(OWLRDFVocabulary.OWL_EQUIVALENT_PROPERTY));

public static final RelationshipType OWL_PROPERTY_CHAIN_AXIOM = DynamicRelationshipType
.withName(getFragment(OWLRDFVocabulary.OWL_PROPERTY_CHAIN_AXIOM));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,13 @@ public void testSubPropeties() {
assertThat(hasDirectedRelationship(hasWife, hasSpouse, OwlRelationships.RDFS_SUB_PROPERTY_OF), is(true));
}

@Test
public void testEquivalentProperties() {
Node hasChild1 = getNode(ROOT + "/hasChild");
Node hasChild2 = getNode(OTHER_ROOT + "/child");
assertThat(hasRelationship(hasChild1, hasChild2, OwlRelationships.OWL_EQUIVALENT_OBJECT_PROPERTY), is(true));
}

@Test
public void chainedObjectProperties() {
Node chain = getNode(ROOT + "/hasUncle");
Expand Down

0 comments on commit 6401cbe

Please sign in to comment.