Skip to content

Commit

Permalink
Merge branch 'master' into ci/update-dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
francescalb authored Jul 1, 2024
2 parents e87e688 + 9b32587 commit 7b3cbcb
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 14 deletions.
85 changes: 85 additions & 0 deletions emmopy/emmocheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,91 @@ def test_object_property_label(self):
class TestFunctionalEMMOConventions(TestEMMOConventions):
"""Test functional EMMO conventions."""

def test_description(self):
"""Check that all entities have a description.
A description is either an emmo:elucidation, an
emmo:definition or an emmo:conceptualisation.
Exceptions include entities from standard w3c vocabularies.
"""
exceptions = set()
exceptions.update(self.get_config("test_description.exceptions", ()))
props = self.onto.world._props # pylint: disable=protected-access
if (
"EMMO_967080e5_2f42_4eb2_a3a9_c58143e835f9" not in props
or "EMMO_31252f35_c767_4b97_a877_1235076c3e13" not in props
or "EMMO_70fe84ff_99b6_4206_a9fc_9a8931836d84" not in props
):
self.fail(
"ontology has no description (emmo:elucidation, "
"emmo:definition or emmo:conceptualisation)"
)
for entity in self.onto.classes(self.check_imported):

# Skip concepts from exceptions and common w3c vocabularies
vocabs = "owl.", "0.1.", "bibo.", "core.", "terms.", "vann."
r = repr(entity)
if r in exceptions or any(r.startswith(v) for v in vocabs):
continue

label = str(get_label(entity))
with self.subTest(entity=entity, label=label):
self.assertTrue(
hasattr(entity, "elucidation"),
msg=f"{label} has no emmo:elucidation",
)
self.assertTrue(
hasattr(entity, "definition"),
msg=f"{label} has no emmo:definition",
)
self.assertTrue(
hasattr(entity, "conceptualisation"),
msg=f"{label} has no emmo:conceptualisation",
)
self.assertTrue(
len(entity.elucidation)
+ len(entity.definition)
+ len(entity.conceptualisation)
>= 1,
msg="missing description (emmo:elucidation, "
f"emmo:deinition and/or emmo:conceptualidation): {label}",
)
self.assertTrue(
len(
[
s
for s in entity.elucidation
if not hasattr(s, "lang") or s.lang == "en"
]
)
< 2,
msg=f"more than one emmo:elucidation for {label}",
)
self.assertTrue(
len(
[
s
for s in entity.definition
if not hasattr(s, "lang") or s.lang == "en"
]
)
< 2,
msg=f"more than one emmo:definition for {label}",
)
self.assertTrue(
len(
[
s
for s in entity.conceptualisation
if not hasattr(s, "lang") or s.lang == "en"
]
)
< 2,
msg=f"more than one emmo:conceptualisation for {label}",
)

def test_unit_dimension(self):
"""Check that all measurement units have a physical dimension.
Expand Down
5 changes: 4 additions & 1 deletion ontopy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -888,8 +888,11 @@ def copy_annotation(onto, src, dst):
"""
if onto.world[src]:
src = onto.world[src]
else:
elif src in onto:
src = onto[src]
else:
warnings.warn(f"no such annotation: '{src}' Skip copy annotation...")
return

if onto.world[dst]:
dst = onto.world[dst]
Expand Down
13 changes: 0 additions & 13 deletions tests/test_emmocheck_module.py

This file was deleted.

5 changes: 5 additions & 0 deletions tests/tools/test_emmocheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,9 @@ def test_run() -> None:
test_file = ontodir / "models.ttl"
emmocheck = get_tool_module("emmocheck")

# The main() method will raise an exception on error, so it is
# sufficient to just call it here

emmocheck.main(["--skip=test_description", str(test_file)])

emmocheck.main([str(test_file)])
2 changes: 2 additions & 0 deletions tools/ontoconvert
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,8 @@ def main(argv: list = None):
"-->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",
"conceptualisation"
"-->http://www.w3.org/2000/01/rdf-schema#comment",
"comment-->http://www.w3.org/2000/01/rdf-schema#comment",
]
)
Expand Down

0 comments on commit 7b3cbcb

Please sign in to comment.