Allow selecting punned entities in remove and filter command#1251
Merged
jamesaoverton merged 3 commits intoontodev:masterfrom May 9, 2025
Merged
Allow selecting punned entities in remove and filter command#1251jamesaoverton merged 3 commits intoontodev:masterfrom
remove and filter command#1251jamesaoverton merged 3 commits intoontodev:masterfrom
Conversation
Add a `--allow-punning` option to the `remove` and `filter` command. When enabled, if a given IRI to select corresponds to several punned entities, all corresponding entities will be selected (contrary to the default behaviour, which is completely ignore all punned entities).
Mention the `--allow-punning` option in the documentation for the `remove` command. Add two test cases based on the UO ontology, which makes an intensive use of punning.
Add a unit test for the new overloading variant of OntologyHelper#getEntities() method, checking that it can return punned entities or not depending of the third parameter.
matentzn
approved these changes
Mar 27, 2025
Contributor
matentzn
left a comment
There was a problem hiding this comment.
Clean implementation, backwards compatible, important feature. Thank you!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
docs/have been added/updatedmvn verifysays all tests passmvn sitesays all JavaDocs correctCHANGELOG.mdhas been updatedCurrently, the
removeandfiltercommands completely ignore punned entities. That is, if the ontology contains, for example, both a class and an individual with the same IRIhttp://purl.obolibrary.org/obo/UO_0000039, thenrobot remove --term UO:0000039will fail to remove anything.This is because the
OntologyHelper#getEntities()method, and theOntologyHelper#getEntity()it calls in turn, does not expect any IRI to match more than exactly one entity (OntologyHelper#getEntity()explicitly throws an exception if it finds more than one entity).This PR adds a
--allow-punning(defaulting to false, preserving the default behaviour) to theremoveandfiltercommand. When set to true, whenever a term IRI matches several entities, all matching entities will be selected.This is particularly useful when dealing with the UO ontology, which makes intensive use of punning (most if not all units in that ontology are defined both as a class and as an individual).