Skip to content

Commit

Permalink
'and' and 'or' now automatically flatten intersections and unions. Fixes
Browse files Browse the repository at this point in the history
 #3.
  • Loading branch information
balhoff committed Aug 20, 2014
1 parent 6dd4475 commit bc2d369
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/main/scala/org/phenoscape/scowl/OWL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ object OWL {

def oneOf(individuals: OWLNamedIndividual*): OWLObjectOneOf = factory.getOWLObjectOneOf(individuals.toSet)

implicit class ScowlClassExpression(val classExpression: OWLClassExpression) extends AnyVal {
implicit class ScowlClassExpression(val self: OWLClassExpression) extends AnyVal {

def and(other: OWLClassExpression): OWLObjectIntersectionOf = factory.getOWLObjectIntersectionOf(classExpression, other)
def and(other: OWLClassExpression): OWLObjectIntersectionOf = factory.getOWLObjectIntersectionOf(self.asConjunctSet + other)

def or(other: OWLClassExpression): OWLObjectUnionOf = factory.getOWLObjectUnionOf(classExpression, other)
def or(other: OWLClassExpression): OWLObjectUnionOf = factory.getOWLObjectUnionOf(self.asDisjunctSet + other)

def SubClassOf(other: OWLClassExpression): OWLSubClassOfAxiom = factory.getOWLSubClassOfAxiom(classExpression, other)
def SubClassOf(other: OWLClassExpression): OWLSubClassOfAxiom = factory.getOWLSubClassOfAxiom(self, other)

def EquivalentTo(other: OWLClassExpression): OWLEquivalentClassesAxiom = factory.getOWLEquivalentClassesAxiom(classExpression, other)
def EquivalentTo(other: OWLClassExpression): OWLEquivalentClassesAxiom = factory.getOWLEquivalentClassesAxiom(self, other)

def DisjointFrom(other: OWLClassExpression): OWLDisjointClassesAxiom = factory.getOWLDisjointClassesAxiom(classExpression, other)
def DisjointFrom(other: OWLClassExpression): OWLDisjointClassesAxiom = factory.getOWLDisjointClassesAxiom(self, other)

}

Expand Down
4 changes: 4 additions & 0 deletions src/test/scala/org/phenoscape/scowltest/ScowlTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ class ScowlTest {
def testIntersectionOf(): Unit = {
val class1 = Class("http://example.org/class1")
val class2 = Class("http://example.org/class2")
val class3 = Class("http://example.org/class3")
val oneAndTwo = class1 and class2
val longOneAndTwo = factory.getOWLObjectIntersectionOf(class1, class2)
Assert.assertEquals(longOneAndTwo, oneAndTwo)
val oneAndTwoAndThree = class1 and class2 and class3
val longOneAndTwoAndThree = factory.getOWLObjectIntersectionOf(class1, class2, class3)
Assert.assertEquals(longOneAndTwoAndThree, oneAndTwoAndThree)
}

@Test
Expand Down

0 comments on commit bc2d369

Please sign in to comment.