Skip to content

ControlledTerm returns a blank term with a warning when a name matches no instance #171

Description

@ehennestad

openminds.base.ControlledTerm.deserializeFromName (line 154) handles a name that matches no known instance with

warning('No matching instances were found for name "%s"', instanceName)

and returns a blank term with a fresh blank-node id. The caller gets an object of the right class with no name, no definition and no controlled-instance IRI, and a warning that is easy to lose in a long import. A collection then holds a term that serializes as an anonymous node under the controlled-terms type, which is invalid openMINDS: a controlled term must be one of the published instances.

The matching itself is generous: case-insensitive, whitespace-stripped, then matlab.lang.makeValidName with deletion. That is helpful for typing Species("mus musculus"), but it also means a near-miss silently resolves to nothing rather than to an error naming the closest instances. This is one cause of the ChemicalSubstance round-trip gap recorded in ommtest.helper.knownRoundTripGap.

Proposal:

  • Error by default with an identified id, listing the nearest known names (edit distance on the CONTROLLED_INSTANCES constant is cheap).
  • Keep a lenient mode as an explicit option for interactive use.
  • Never construct a controlled term without a controlled-instance IRI unless the caller asked for a reference (IsReference=true with an id).

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions