From f719cd47e96e37667a6a92a66e66f08593471b1b Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 17 Mar 2024 11:37:18 +0100 Subject: [PATCH 1/2] Added additional recognised prefixes (expected to be used by FOOPS) --- ontopy/ontology.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ontopy/ontology.py b/ontopy/ontology.py index 02e1a217f..31fba7222 100644 --- a/ontopy/ontology.py +++ b/ontopy/ontology.py @@ -1004,15 +1004,17 @@ def save( # Make a copy of the owlready2 graph object to not mess with # owlready2 internals graph = rdflib.Graph() - graph_owlready2 = self.world.as_rdflib_graph() - for triple in graph_owlready2.triples((None, None, None)): + for triple in self.world.as_rdflib_graph(): graph.add(triple) - # Add namespaces - graph.namespace_manager.bind("", rdflib.Namespace(self.base_iri)) - graph.namespace_manager.bind( - "swrl", rdflib.Namespace("http://www.w3.org/2003/11/swrl#") - ) + # Add common namespaces unknown to rdflib + extra_namespaces = [ + ("", self.base_iri), + ("swrl", "http://www.w3.org/2003/11/swrl#"), + ("bibo", "http://purl.org/ontology/bibo/"), + ] + for prefix, iri in extra_namespaces: + graph.namespace_manager.bind(prefix, rdflib.Namespace(iri)) # Remove all ontology-declarations in the graph that are # not the current ontology. From 802232ef5f0b74453390c29e77c8a937cd92d1b3 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 17 Mar 2024 11:45:54 +0100 Subject: [PATCH 2/2] Do not override existing namespaces in save() --- ontopy/ontology.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ontopy/ontology.py b/ontopy/ontology.py index 31fba7222..47425c771 100644 --- a/ontopy/ontology.py +++ b/ontopy/ontology.py @@ -1014,7 +1014,9 @@ def save( ("bibo", "http://purl.org/ontology/bibo/"), ] for prefix, iri in extra_namespaces: - graph.namespace_manager.bind(prefix, rdflib.Namespace(iri)) + graph.namespace_manager.bind( + prefix, rdflib.Namespace(iri), override=False + ) # Remove all ontology-declarations in the graph that are # not the current ontology.