Skip to content

Allow selecting punned entities in remove and filter command #1251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gouttegd
Copy link
Contributor

  • docs/ have been added/updated
  • tests have been added/updated
  • mvn verify says all tests pass
  • mvn site says all JavaDocs correct
  • CHANGELOG.md has been updated

Currently, the remove and filter commands completely ignore punned entities. That is, if the ontology contains, for example, both a class and an individual with the same IRI http://purl.obolibrary.org/obo/UO_0000039, then robot remove --term UO:0000039 will fail to remove anything.

This is because the OntologyHelper#getEntities() method, and the OntologyHelper#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 the remove and filter command. 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).

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.
@gouttegd gouttegd self-assigned this Mar 25, 2025
Copy link
Contributor

@matentzn matentzn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean implementation, backwards compatible, important feature. Thank you!

Copy link
Member

@jamesaoverton jamesaoverton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jamesaoverton jamesaoverton merged commit 1808bc6 into ontodev:master May 9, 2025
3 checks passed
@gouttegd gouttegd deleted the allow-selecting-punned-entities branch May 9, 2025 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants