From 933f1433a39f8df8f206574e5d0671c0d17bd640 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Thu, 14 Mar 2024 00:58:15 +0100 Subject: [PATCH 01/13] Updated list of IRIs to ignore when looking for labels. --- emmopy/emmocheck.py | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/emmopy/emmocheck.py b/emmopy/emmocheck.py index 1df5ca8b7..db177de82 100644 --- a/emmopy/emmocheck.py +++ b/emmopy/emmocheck.py @@ -73,17 +73,30 @@ def test_number_of_labels(self): """ exceptions = set( ( - "terms.license", + "0.1.homepage", # foaf:homepage + "0.1.logo", + "0.1.page", + "0.1.name", + "bibo:doi", + "core.altLabel", + "core.hiddenLabel", + "core.prefLabel", "terms.abstract", + "terms.alternative", + "terms:bibliographicCitation", "terms.contributor", + "terms.created", "terms.creator", + "terms.hasFormat", + "terms.identifier", + "terms.issued", + "terms.license", + "terms.modified", "terms.publisher", + "terms.source", "terms.title", - "core.prefLabel", - "core.altLabel", - "core.hiddenLabel", - "foaf.logo", - "0.1.logo", # foaf.logo + "vann:preferredNamespacePrefix", + "vann:preferredNamespaceUri", ) ) exceptions.update( From b57d5b3fe346eb5f0c138e40195bb0fde431948d Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Thu, 14 Mar 2024 08:04:28 +0100 Subject: [PATCH 02/13] Started to add --copy-annotation option to ontoconvert. --- tools/ontoconvert | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/tools/ontoconvert b/tools/ontoconvert index 934d12df8..b8f1b8c4b 100755 --- a/tools/ontoconvert +++ b/tools/ontoconvert @@ -59,6 +59,26 @@ def main(argv: list = None): "The default is to append to it." ), ) + parser.add_argument( + "--copy-annotation", + "-c", + action="append", + default=[], + metavar="FROM-->TO", + help=( + "Copy annotation FROM to annotation TO in each class and " + "property in the ontology. May be provided multiple times." + ), + ) + parser.add_argument( + "--copy-preflabel", + "-p", + action="store_true", + help=( + "Alias for: `--copy-annotation=http://www.w3.org/2004/02/skos/" + "core#prefLabel-->http://www.w3.org/2000/01/rdf-schema#label`" + ), + ) parser.add_argument( "--no-catalog", "-n", @@ -72,7 +92,7 @@ def main(argv: list = None): "--infer", "-i", nargs="?", - const="FaCT++", + const="HermiT", choices=["HermiT", "Pellet", "FaCT++"], metavar="NAME", help=( @@ -188,6 +208,14 @@ def main(argv: list = None): if not output_format: output_format = "xml" + if args.copy_annotation is None: + args.copy_annotation = [] + if args.copy_preflabel: + args.copy_annotation.append( + "http://www.w3.org/2004/02/skos/core#prefLabel-->" + "http://www.w3.org/2000/01/rdf-schema#label" + ) + # Perform conversion with warnings.catch_warnings(record=True) as warnings_handle: warnings.simplefilter("always") @@ -218,6 +246,11 @@ def main(argv: list = None): debug=verbose, ) + for cpy in args.copy_annotation: + src, dst = cpy.split("-->", 1) + print(src) + print(" -->", dst) + onto.save( args.output, format=output_format, From ac3dd9738e183f893befb83db1ede4d02c0451fa Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Thu, 14 Mar 2024 10:59:02 +0100 Subject: [PATCH 03/13] Added --copy-annotation option to ontoconvert --- ontopy/utils.py | 31 +++++++++++++++++++++++++++++++ tests/tools/test_ontoconvert.py | 15 +++++++++++++++ tools/ontoconvert | 5 ++--- 3 files changed, 48 insertions(+), 3 deletions(-) diff --git a/ontopy/utils.py b/ontopy/utils.py index cf759d0b7..212d0b930 100644 --- a/ontopy/utils.py +++ b/ontopy/utils.py @@ -835,3 +835,34 @@ def recur(o): ) return layout + + +def copy_annotation(onto, src, dst): + """In all classes and properties in `onto`, copy annotation `src` to `dst`. + + The `src` and `dst` can either be provided as a label string or a full IRI. + """ + if onto.world[src]: + src = onto.world[src] + else: + src = onto[src] + + if onto.world[dst]: + dst = onto.world[dst] + elif dst in onto: + dst = onto[dst] + else: + if "://" not in dst: + raise ValueError( + "new destination annotation property must be provided as " + "a full IRI" + ) + name = min(dst.rsplit("#")[-1], dst.rsplit("/")[-1]) + iri = dst + dst = onto.new_annotation_property(name, owlready2.AnnotationProperty) + dst.iri = iri + + for e in onto.get_entities(): + new = getattr(e, src.name).first() + if new and new not in getattr(e, dst.name): + getattr(e, dst.name).append(new) diff --git a/tests/tools/test_ontoconvert.py b/tests/tools/test_ontoconvert.py index 8a6c1e719..a1df28b78 100644 --- a/tests/tools/test_ontoconvert.py +++ b/tests/tools/test_ontoconvert.py @@ -39,3 +39,18 @@ def test_run() -> None: assert re.search("@prefix : ", output2) assert re.search(" .* owl:Ontology", output2) assert re.search("testclass .* owl:Class", output2) + + # Test 3 - copy-annotation + ontoconvert.main( + [ + "-p", + "--iri=https://w3id.org/ex/testonto", + "--base-iri=https://w3id.org/ex/testonto#", + str(ontodir / "testonto.ttl"), + str(outdir / "test_ontoconvert3.ttl"), + ] + ) + input3 = (ontodir / "testonto.ttl").read_text() + output3 = (outdir / "test_ontoconvert3.ttl").read_text() + assert not re.search('rdfs:label "hasAnnotationProperty"@en', input3) + assert re.search('rdfs:label "hasAnnotationProperty"@en', output3) diff --git a/tools/ontoconvert b/tools/ontoconvert index b8f1b8c4b..f48e9b0d7 100755 --- a/tools/ontoconvert +++ b/tools/ontoconvert @@ -7,7 +7,7 @@ import warnings from rdflib.util import guess_format from ontopy import get_ontology -from ontopy.utils import annotate_source, rename_iris +from ontopy.utils import annotate_source, rename_iris, copy_annotation def main(argv: list = None): @@ -248,8 +248,7 @@ def main(argv: list = None): for cpy in args.copy_annotation: src, dst = cpy.split("-->", 1) - print(src) - print(" -->", dst) + copy_annotation(onto, src, dst) onto.save( args.output, From 59f8b4e7436b3d9be350ef638f18549df97687cb Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Thu, 14 Mar 2024 17:50:14 +0100 Subject: [PATCH 04/13] Updated docstring as requested by reviewer --- ontopy/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ontopy/utils.py b/ontopy/utils.py index 212d0b930..d5e9a09ae 100644 --- a/ontopy/utils.py +++ b/ontopy/utils.py @@ -840,7 +840,11 @@ def recur(o): def copy_annotation(onto, src, dst): """In all classes and properties in `onto`, copy annotation `src` to `dst`. - The `src` and `dst` can either be provided as a label string or a full IRI. + Arguments: + onto: Ontology to work on. + src: Name of source annotation. + dst: Name or IRI of destination annotation. Use IRI if the + destination annotation is not already in the ontology. """ if onto.world[src]: src = onto.world[src] From 49609a381613d4d67bf77febe810dde781a903ef Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Thu, 14 Mar 2024 18:19:01 +0100 Subject: [PATCH 05/13] Added new test as required by reviewer --- ontopy/utils.py | 2 +- tests/tools/test_ontoconvert.py | 15 +++++++++++++++ tools/ontoconvert | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ontopy/utils.py b/ontopy/utils.py index d5e9a09ae..010e5e751 100644 --- a/ontopy/utils.py +++ b/ontopy/utils.py @@ -861,7 +861,7 @@ def copy_annotation(onto, src, dst): "new destination annotation property must be provided as " "a full IRI" ) - name = min(dst.rsplit("#")[-1], dst.rsplit("/")[-1]) + name = min(dst.rsplit("#")[-1], dst.rsplit("/")[-1], key=len) iri = dst dst = onto.new_annotation_property(name, owlready2.AnnotationProperty) dst.iri = iri diff --git a/tests/tools/test_ontoconvert.py b/tests/tools/test_ontoconvert.py index a1df28b78..542387f2b 100644 --- a/tests/tools/test_ontoconvert.py +++ b/tests/tools/test_ontoconvert.py @@ -54,3 +54,18 @@ def test_run() -> None: output3 = (outdir / "test_ontoconvert3.ttl").read_text() assert not re.search('rdfs:label "hasAnnotationProperty"@en', input3) assert re.search('rdfs:label "hasAnnotationProperty"@en', output3) + + # Test 4 - copy-annotation with source as annotation label + ontoconvert.main( + [ + "-c prefLabel-->http://www.w3.org/2004/02/skos/core#hiddenLabel", + "--iri=https://w3id.org/ex/testonto", + "--base-iri=https://w3id.org/ex/testonto#", + str(ontodir / "testonto.ttl"), + str(outdir / "test_ontoconvert4.ttl"), + ] + ) + input4 = (ontodir / "testonto.ttl").read_text() + output4 = (outdir / "test_ontoconvert4.ttl").read_text() + assert not re.search('skos:hiddenLabel "hasAnnotationProperty"@en', input4) + assert re.search('skos:hiddenLabel "hasAnnotationProperty"@en', output4) diff --git a/tools/ontoconvert b/tools/ontoconvert index f48e9b0d7..e388cec5e 100755 --- a/tools/ontoconvert +++ b/tools/ontoconvert @@ -248,7 +248,7 @@ def main(argv: list = None): for cpy in args.copy_annotation: src, dst = cpy.split("-->", 1) - copy_annotation(onto, src, dst) + copy_annotation(onto, src.strip(), dst.strip()) onto.save( args.output, From 4ea6ce814fc54962e235fe2c68e15a6a73ba9427 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Thu, 14 Mar 2024 21:49:32 +0100 Subject: [PATCH 06/13] Updated option documentation --- tools/ontoconvert | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/ontoconvert b/tools/ontoconvert index e388cec5e..5a75d1dd1 100755 --- a/tools/ontoconvert +++ b/tools/ontoconvert @@ -67,7 +67,10 @@ def main(argv: list = None): metavar="FROM-->TO", help=( "Copy annotation FROM to annotation TO in each class and " - "property in the ontology. May be provided multiple times." + "property in the ontology. FROM and TO may be given as " + "full IRIs or (if they already exists as annotations in the " + "ontology) as entity names. " + "This option be given multiple times." ), ) parser.add_argument( From aea7e3f85cfdb60c4047e28fe80ec61591e8472a Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 17 Mar 2024 11:34:29 +0100 Subject: [PATCH 07/13] Renamed option --copy-preflabel to --copy-emmo-annotations and more content to what it alias. --- tools/ontoconvert | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/tools/ontoconvert b/tools/ontoconvert index 5a75d1dd1..45f068228 100755 --- a/tools/ontoconvert +++ b/tools/ontoconvert @@ -74,12 +74,18 @@ def main(argv: list = None): ), ) parser.add_argument( - "--copy-preflabel", - "-p", + "--copy-emmo-annotations", + "-e", action="store_true", help=( - "Alias for: `--copy-annotation=http://www.w3.org/2004/02/skos/" - "core#prefLabel-->http://www.w3.org/2000/01/rdf-schema#label`" + "Make a copy of EMMO annotations to plain RDFS for increased " + "interoperability. " + "Alias for: `--copy-annotation=" + "http://www.w3.org/2004/02/skos/core#prefLabel" + "-->http://www.w3.org/2000/01/rdf-schema#label " + "--copy-annotation=" + "https://w3id.org/emmo#EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9" + "-->http://www.w3.org/2000/01/rdf-schema#comment`" ), ) parser.add_argument( @@ -211,12 +217,16 @@ def main(argv: list = None): if not output_format: output_format = "xml" - if args.copy_annotation is None: - args.copy_annotation = [] - if args.copy_preflabel: - args.copy_annotation.append( - "http://www.w3.org/2004/02/skos/core#prefLabel-->" - "http://www.w3.org/2000/01/rdf-schema#label" + # Annotations to copy with --copy-emmo-annotations + if args.copy_emmo_annotations: + args.copy_annotation.extend( + [ + "http://www.w3.org/2004/02/skos/core#prefLabel" + "-->http://www.w3.org/2000/01/rdf-schema#label", + "https://w3id.org/emmo#" + "EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9" + "-->http://www.w3.org/2000/01/rdf-schema#comment", + ] ) # Perform conversion From f719cd47e96e37667a6a92a66e66f08593471b1b Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 17 Mar 2024 11:37:18 +0100 Subject: [PATCH 08/13] 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 09/13] 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. From 70ae9b28b8fce3db9a8b71635e77214443debbaa Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 17 Mar 2024 12:23:49 +0100 Subject: [PATCH 10/13] Added new dedicated test ontology for test_ontoconvert.py --- tests/testonto/domainonto.ttl | 44 +++++++++++++++++++++++++++++++++ tests/tools/test_ontoconvert.py | 30 +++++++++++++--------- tools/ontoconvert | 4 +-- 3 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 tests/testonto/domainonto.ttl diff --git a/tests/testonto/domainonto.ttl b/tests/testonto/domainonto.ttl new file mode 100644 index 000000000..ff1f85c51 --- /dev/null +++ b/tests/testonto/domainonto.ttl @@ -0,0 +1,44 @@ +@prefix : . +@prefix owl: . +@prefix rdf: . +@prefix xml: . +@prefix xsd: . +@prefix rdfs: . +@prefix skos: . +@prefix dcterms: . +@prefix emmo: . + + + rdf:type owl:Ontology ; + owl:versionIRI ; + owl:versionInfo "0.1.0" ; + dcterms:abstract "Test for an EMMO-based domain ontolgoy."@en . + + +:testclass rdf:type owl:Class ; + rdfs:subClassOf owl:Thing ; + skos:prefLabel "TestClass"@en ; + emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 "A test class."@en . + +:testobjectproperty rdf:type owl:ObjectProperty ; + rdfs:domain :testclass ; + rdfs:range :testclass ; + skos:prefLabel "hasObjectProperty"@en . + +:testannotationproperty rdf:type owl:AnnotationProperty ; + rdfs:domain :testclass ; + rdfs:range rdfs:Literal ; + skos:prefLabel "hasAnnotationProperty"@en . + +:testdatatypeproperty rdf:type owl:DatatypeProperty ; + rdfs:domain :testclass ; + rdfs:range xsd:string ; + skos:prefLabel "hasDataProperty"@en . + + +# Declare elucidation here since we are not importing EMMO +emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 a owl:AnnotationProperty ; + skos:prefLabel "elucidation"@en ; + rdfs:comment "Short enlightening explanation aimed to facilitate the user in drawing the connection (interpretation) between a OWL entity and the real world object(s) for which it stands."@en . + +skos:prefLabel a owl:AnnotationProperty . diff --git a/tests/tools/test_ontoconvert.py b/tests/tools/test_ontoconvert.py index 542387f2b..92f4a19c1 100644 --- a/tests/tools/test_ontoconvert.py +++ b/tests/tools/test_ontoconvert.py @@ -40,32 +40,38 @@ def test_run() -> None: assert re.search(" .* owl:Ontology", output2) assert re.search("testclass .* owl:Class", output2) - # Test 3 - copy-annotation + # Test 3 - copy-emmo-annotations + infile3 = ontodir / "domainonto.ttl" + outfile3 = outdir / "test_ontoconvert3.ttl" ontoconvert.main( [ - "-p", + "--copy-emmo-annotations", "--iri=https://w3id.org/ex/testonto", "--base-iri=https://w3id.org/ex/testonto#", - str(ontodir / "testonto.ttl"), - str(outdir / "test_ontoconvert3.ttl"), + str(infile3), + str(outfile3), ] ) - input3 = (ontodir / "testonto.ttl").read_text() - output3 = (outdir / "test_ontoconvert3.ttl").read_text() - assert not re.search('rdfs:label "hasAnnotationProperty"@en', input3) - assert re.search('rdfs:label "hasAnnotationProperty"@en', output3) + input3 = infile3.read_text() + output3 = outfile3.read_text() + assert 'rdfs:label "hasAnnotationProperty"@en' not in input3 + assert 'rdfs:label "hasAnnotationProperty"@en' in output3 + assert 'rdfs:comment "A test class."@en' not in input3 + assert 'rdfs:comment "A test class."@en' in output3 # Test 4 - copy-annotation with source as annotation label + infile4 = ontodir / "testonto.ttl" + outfile4 = outdir / "test_ontoconvert3.ttl" ontoconvert.main( [ "-c prefLabel-->http://www.w3.org/2004/02/skos/core#hiddenLabel", "--iri=https://w3id.org/ex/testonto", "--base-iri=https://w3id.org/ex/testonto#", - str(ontodir / "testonto.ttl"), - str(outdir / "test_ontoconvert4.ttl"), + str(infile4), + str(outfile4), ] ) - input4 = (ontodir / "testonto.ttl").read_text() - output4 = (outdir / "test_ontoconvert4.ttl").read_text() + input4 = infile4.read_text() + output4 = outfile4.read_text() assert not re.search('skos:hiddenLabel "hasAnnotationProperty"@en', input4) assert re.search('skos:hiddenLabel "hasAnnotationProperty"@en', output4) diff --git a/tools/ontoconvert b/tools/ontoconvert index 45f068228..3fda84302 100755 --- a/tools/ontoconvert +++ b/tools/ontoconvert @@ -223,9 +223,7 @@ def main(argv: list = None): [ "http://www.w3.org/2004/02/skos/core#prefLabel" "-->http://www.w3.org/2000/01/rdf-schema#label", - "https://w3id.org/emmo#" - "EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9" - "-->http://www.w3.org/2000/01/rdf-schema#comment", + "elucidation-->http://www.w3.org/2000/01/rdf-schema#comment", ] ) From 5996e43cc37672cb7ba9012f4a3e8bf8299b5dfb Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 17 Mar 2024 12:49:14 +0100 Subject: [PATCH 11/13] Added emmo:definition-->rdfs:comment to --copy-emmo-annotations --- tests/testonto/domainonto.ttl | 2 +- tools/ontoconvert | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/testonto/domainonto.ttl b/tests/testonto/domainonto.ttl index ff1f85c51..9b53f9d9a 100644 --- a/tests/testonto/domainonto.ttl +++ b/tests/testonto/domainonto.ttl @@ -36,7 +36,7 @@ skos:prefLabel "hasDataProperty"@en . -# Declare elucidation here since we are not importing EMMO +# Declare emmo:elucidation and skos:prefLabel here since we are not importing these ontologies emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 a owl:AnnotationProperty ; skos:prefLabel "elucidation"@en ; rdfs:comment "Short enlightening explanation aimed to facilitate the user in drawing the connection (interpretation) between a OWL entity and the real world object(s) for which it stands."@en . diff --git a/tools/ontoconvert b/tools/ontoconvert index 3fda84302..4e06cdf79 100755 --- a/tools/ontoconvert +++ b/tools/ontoconvert @@ -83,8 +83,9 @@ def main(argv: list = None): "Alias for: `--copy-annotation=" "http://www.w3.org/2004/02/skos/core#prefLabel" "-->http://www.w3.org/2000/01/rdf-schema#label " - "--copy-annotation=" - "https://w3id.org/emmo#EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9" + "--copy-annotation=elucidation" + "-->http://www.w3.org/2000/01/rdf-schema#comment`" + "--copy-annotation=definition" "-->http://www.w3.org/2000/01/rdf-schema#comment`" ), ) @@ -224,6 +225,7 @@ def main(argv: list = None): "http://www.w3.org/2004/02/skos/core#prefLabel" "-->http://www.w3.org/2000/01/rdf-schema#label", "elucidation-->http://www.w3.org/2000/01/rdf-schema#comment", + "definition-->http://www.w3.org/2000/01/rdf-schema#comment", ] ) From 6033f82ff36572361b70a341a2c204c8f0988277 Mon Sep 17 00:00:00 2001 From: Jesper Friis Date: Sun, 17 Mar 2024 17:41:13 +0100 Subject: [PATCH 12/13] Added definition to domainonto --- tests/testonto/domainonto.ttl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/testonto/domainonto.ttl b/tests/testonto/domainonto.ttl index 9b53f9d9a..f7e5bf71e 100644 --- a/tests/testonto/domainonto.ttl +++ b/tests/testonto/domainonto.ttl @@ -36,9 +36,16 @@ skos:prefLabel "hasDataProperty"@en . -# Declare emmo:elucidation and skos:prefLabel here since we are not importing these ontologies +# Declare skos:prefLabel, emmo:elucidation and emmo:definition here +# since we are not importing these ontologies emmo:EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9 a owl:AnnotationProperty ; + rdfs:subPropertyOf rdfs:comment ; skos:prefLabel "elucidation"@en ; rdfs:comment "Short enlightening explanation aimed to facilitate the user in drawing the connection (interpretation) between a OWL entity and the real world object(s) for which it stands."@en . +:EMMO_70fe84ff_99b6_4206_a9fc_9a8931836d84 a owl:AnnotationProperty ; + rdfs:subPropertyOf rdfs:comment ; + skos:prefLabel "definition"@en ; + rdfs:comment "Precise and univocal description of an ontological entity in the framework of an axiomatic system."@en . + skos:prefLabel a owl:AnnotationProperty . From 09fcba8e3bb574bf47f0bd03829eb1beab7c3a55 Mon Sep 17 00:00:00 2001 From: "Francesca L. Bleken" <48128015+francescalb@users.noreply.github.com> Date: Wed, 10 Apr 2024 11:46:30 +0200 Subject: [PATCH 13/13] Load doamin-battery instead of battinfo which is just an extra wrapping (#745) # Description This should deprecate PR #741 in which the tests where removed, also incorrectly. ## Type of change - [ ] Bug fix. - [ ] New feature. - [ ] Documentation update. - [ ] Test update. ## Checklist This checklist can be used as a help for the reviewer. - [ ] Is the code easy to read and understand? - [ ] Are comments for humans to read, not computers to disregard? - [ ] Does a new feature has an accompanying new test (in the CI or unit testing schemes)? - [ ] Has the documentation been updated as necessary? - [ ] Does this close the issue? - [ ] Is the change limited to the issue? - [ ] Are errors handled for all outcomes? - [ ] Does the new feature provide new restrictions on dependencies, and if so is this documented? ## Comments --- tests/test_get_by_label.py | 5 ++++- tests/test_load.py | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_get_by_label.py b/tests/test_get_by_label.py index 5b84a5281..669ad9715 100644 --- a/tests/test_get_by_label.py +++ b/tests/test_get_by_label.py @@ -109,8 +109,11 @@ def test_get_by_label_emmo(emmo: "Ontology") -> None: assert emmo[emmo.Atom.iri] == emmo.Atom # Load an ontology with imported sub-ontologies + # Note that this test also includes testing of loading + # ontology with catalog file directly from the web + # It is therefore not duplicated in test_load. onto = get_ontology( - "https://raw.githubusercontent.com/BIG-MAP/BattINFO/master/battinfo.ttl" + "https://raw.githubusercontent.com/emmo-repo/domain-battery/master/battery.ttl" ).load() assert onto.Electrolyte.prefLabel.en.first() == "Electrolyte" diff --git a/tests/test_load.py b/tests/test_load.py index bb5f04223..35c911fd3 100755 --- a/tests/test_load.py +++ b/tests/test_load.py @@ -35,11 +35,8 @@ def test_load(repo_dir: "Path", testonto: "Ontology") -> None: assert str(testonto.TestClass.prefLabel.first()) == "TestClass" # Use catalog file when downloading from web - onto = get_ontology( - "https://raw.githubusercontent.com/BIG-MAP/BattINFO/master/" - "battinfo.ttl" - ).load() - assert str(onto.Electrolyte.prefLabel.first()) == "Electrolyte" + # This is tested in test_get_by_label in which some additional tests + # are performed on labels. with pytest.raises( EMMOntoPyException,