Commits

Anonymous committed 16a7968

some more fuxi tests and remove debugging information

Comments (0)

Files changed (3)

ordf/handler/fuxi.py

         self.get = _get
 
         rstore, rgraph, rete = SetupRuleStore(makeNetwork=True)
+        rete.inferredFacts = Graph()
         for modname in self.rule_modules:
             __import__(modname, {}, {}, ["inference_rules"]).inference_rules(self.handler, rete)
 
                 ### this is a naive way of figuring out which inferred
                 ### facts are relevant
                 copy = Graph(identifier=ctx.identifier)
-                for statement in ctx.triples((None, None, None)):
-                    copy.add(statement)
-                for statement in rete.inferredFacts.triples((ctx.identifier, None, None)):
-                    copy.add(statement)
+                copy += ctx
+                copy += rete.inferredFacts.bnc((ctx.identifier, None, None))
                 change_ctx.add(copy)
 
         ### save the changes

ordf/namespace.py

     "sioc": SIOC,
     "skos": SKOS,
     "time": TIME,
+    "uuid": UUID,
     "void": VOID,
     "wot": WOT,
 }

ordf/tests/test_fuxi.py

 from ordf.graph import Graph
 from ordf.handler import init_handler
-from ordf.namespace import Namespace, RDF, RDFS
+from ordf.namespace import register_ns, Namespace, RDF, RDFS, OWL, SKOS
+from ordf.vocab.owl import Class
 
-def fuxi_handler():
+def fuxi_handler(default={}):
     config = {
         "ordf.readers": "fuxi,rdflib",
         "ordf.writers": "fuxi,rdflib",
-        "fuxi.args": "ordf.vocab.rdfs",
         }
+    config.update(default)
     return init_handler(config)
 
 EX = Namespace("http://example.org/")
+register_ns("ex", EX)
 
 def test_01_rdfs():
-    h = fuxi_handler()
+    h = fuxi_handler({ "fuxi.args": "ordf.vocab.rdfs" })
 
     g = Graph(identifier=EX["Max"])
     g.add((EX["Max"], RDF["type"], EX["Cat"]))
     
     r = h.get(EX["Max"])
     assert r.exists((EX["Max"], RDF["type"], RDFS["Resource"]))
+
+def test_02_owl():
+    h = fuxi_handler({ "fuxi.args": "ordf.vocab.owl" })
+
+    ctx = h.context("test", "cat")
+
+    cat = Class(EX["Cat"], graph=Graph(identifier=EX["Cat"]))
+    ctx.add(cat.graph)
+
+    cateq = Class(EX["CatEquiv"],
+                  equivalentClass=[EX["Cat"]],
+                  graph=Graph(identifier=EX["CatEquiv"]))
+    ctx.add(cateq.graph)
+
+    max = Graph(identifier=EX["Max"])
+    max.add((EX["Max"], RDF["type"], EX["Cat"]))
+    ctx.add(max)
+
+    ctx.commit()
+
+    cat = h.get(EX["Cat"])
+    assert cat.exists((EX["Cat"], OWL["equivalentClass"], EX["CatEquiv"]))
+
+def test_03_skos():
+    h = fuxi_handler({ "fuxi.args": "ordf.vocab.skos" })
+    ctx = h.context("test", "cat")
+
+    animal = Class(EX["Animal"], graph=Graph(identifier=EX["Animal"]))
+    animal.graph.add((EX["Animal"], RDF["type"], SKOS["Concept"]))
+    ctx.add(animal.graph)
+
+    cat = Class(EX["Cat"], graph=Graph(identifier=EX["Cat"]))
+    cat.graph.add((EX["Cat"], SKOS["broaderTransitive"], EX["Animal"]))
+    ctx.add(cat.graph)
+
+    tabby = Class(EX["Tabby"], graph=Graph(identifier=EX["Tabby"]))
+    tabby.graph.add((EX["Tabby"], SKOS["broaderTransitive"], EX["Cat"]))
+    ctx.add(tabby.graph)
+
+    ctx.commit()
+
+    animal = h.get(EX["Animal"])
+    print animal.serialize(format="n3")