def testNegatedDisjunctionTest(self): contains = Property(EX_NS.contains) omega = EX.Omega alpha = EX.Alpha innerDisjunct = omega | alpha foo = EX.foo testClass1 = foo & (contains | only | ~innerDisjunct) testClass1.identifier = EX_NS.Bar self.assertEqual(repr(testClass1), 'ex:foo THAT ( ex:contains ONLY ( NOT ( ex:Omega OR ex:Alpha ) ) )') NormalFormReduction(self.ontGraph) self.assertEqual(repr(testClass1), 'ex:foo THAT ( NOT ( ex:contains SOME ( ex:Omega OR ex:Alpha ) ) )') individual1 = BNode() individual2 = BNode() foo.extent = [individual1] contains.extent = [(individual1, individual2)] (EX.Baz).extent = [individual2] ruleStore, ruleGraph, network = SetupRuleStore(makeNetwork=True) posRules, ignored = CalculateStratifiedModel(network, self.ontGraph, [EX_NS.Bar]) self.failUnless(not posRules, "There should be no rules in the 0 strata.") self.assertEqual(len(ignored), 2, "There should be 2 'negative' rules") testClass1.graph = network.inferredFacts self.failUnless(individual1 in testClass1.extent, "%s should be in ex:Bar's extent" % individual1)
def testGeneralConceptInclusion(self): # Some Class # ## Primitive Type ## # SubClassOf: Class: ex:NoExclusion . # DisjointWith ( ex:contains some ex:IsolatedCABGConcomitantExclusion ) contains = Property(EX_NS.contains) testClass = ~(contains | some | EX.Exclusion) testClass2 = EX.NoExclusion testClass2 += testClass NormalFormReduction(self.ontGraph) individual1 = BNode() individual2 = BNode() contains.extent = [(individual1, individual2)] ruleStore, ruleGraph, network = SetupRuleStore(makeNetwork=True) posRules, negRules = CalculateStratifiedModel(network, self.ontGraph, [EX_NS.NoExclusion]) self.failUnless(not posRules, "There should be no rules in the 0 strata.") self.assertEqual(len(negRules), 2, "There should be 2 'negative' rules") Individual.factoryGraph = network.inferredFacts targetClass = Class(EX_NS.NoExclusion, skipOWLClassMembership=False) self.failUnless( individual1 in targetClass.extent, "There is a BNode that bears the contains relation with another individual that is not a member of Exclusion." ) self.assertEquals(len(list(targetClass.extent)), 1, "There should only be one member in NoExclusion")
def testGeneralConceptInclusion(self): # Some Class # ## Primitive Type ## # SubClassOf: Class: ex:NoExclusion . # DisjointWith # ( ex:contains some ex:IsolatedCABGConcomitantExclusion ) contains = Property(EX_NS.contains) testClass = ~(contains | some | EX.Exclusion) testClass2 = EX.NoExclusion testClass2 += testClass NormalFormReduction(self.ontGraph) individual1 = BNode() individual2 = BNode() contains.extent = [(individual1, individual2)] ruleStore, ruleGraph, network = SetupRuleStore(makeNetwork=True) posRules, negRules = CalculateStratifiedModel( network, self.ontGraph, [EX_NS.NoExclusion]) self.failUnless( not posRules, "There should be no rules in the 0 strata!") self.assertEqual( len(negRules), 2, "There should be 2 'negative' rules") Individual.factoryGraph = network.inferredFacts targetClass = Class(EX_NS.NoExclusion, skipOWLClassMembership=False) self.failUnless( individual1 in targetClass.extent, "There is a BNode that bears the contains " + "relation with another individual that is not " + "a member of Exclusion!") self.assertEquals( len(list(targetClass.extent)), 1, "There should only be one member in NoExclusion.")
def testNegatedDisjunctionTest(self): contains = Property(EX_NS.contains) omega = EX.Omega alpha = EX.Alpha innerDisjunct = omega | alpha foo = EX.foo testClass1 = foo & (contains | only | ~innerDisjunct) testClass1.identifier = EX_NS.Bar self.assertEqual( repr(testClass1), 'ex:foo THAT ( ex:contains ONLY ( NOT ( ex:Omega OR ex:Alpha ) ) )' ) NormalFormReduction(self.ontGraph) self.assertEqual( repr(testClass1), 'ex:foo THAT ( NOT ( ex:contains SOME ( ex:Omega OR ex:Alpha ) ) )' ) individual1 = BNode() individual2 = BNode() foo.extent = [individual1] contains.extent = [(individual1, individual2)] (EX.Baz).extent = [individual2] ruleStore, ruleGraph, network = SetupRuleStore(makeNetwork=True) posRules, ignored = CalculateStratifiedModel(network, self.ontGraph, [EX_NS.Bar]) self.failUnless(not posRules, "There should be no rules in the 0 strata.") self.assertEqual(len(ignored), 2, "There should be 2 'negative' rules") testClass1.graph = network.inferredFacts self.failUnless(individual1 in testClass1.extent, "%s should be in ex:Bar's extent" % individual1)