Skip to content

Add "type_designator_mapping" slot.#262

Open
gouttegd wants to merge 1 commit into
linkml:mainfrom
gouttegd:type-designator-mapping
Open

Add "type_designator_mapping" slot.#262
gouttegd wants to merge 1 commit into
linkml:mainfrom
gouttegd:type-designator-mapping

Conversation

@gouttegd

@gouttegd gouttegd commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Add a new type_designator_mapping slot.

That slot is intended to be used in a slot_definition for a slot that is set as the type designator slot for the class it belongs to.

It allows to define custom mappings to match a type designator value with the type to be designated. Such mappings can be used to provide more ways to reference a given class in a type designator value (beyond the default way of using the class name, URI, or CURIE).

This implements the idea evoked in linkml/linkml#3701.

@gouttegd gouttegd self-assigned this Jul 7, 2026
Add a new `type_designator_mapping` slot.

That slot is intended to be used in a slot_definition for a slot that is
set as the type designator slot for the class it belongs to.

It allows to define custom mappings to match a type designator value
with the type to be designated. Such mappings can be used to provide
more ways to reference a given class in a type designator value (beyond
the default way of using the class name, URI, or CURIE).

It also allows to provide a "fallback" mechanism, by which a loader or
validator can be made to accept an otherwise unrecognised designated
type, through the use of "wildcards" (shell-like patterns).

This implements the idea evoked in
linkml/linkml#3701.
@gouttegd gouttegd force-pushed the type-designator-mapping branch from 8ba7e46 to 082d0b5 Compare July 8, 2026 10:57
@gouttegd gouttegd marked this pull request as ready for review July 8, 2026 10:58
@gouttegd

gouttegd commented Jul 8, 2026

Copy link
Copy Markdown
Contributor Author

@cmungall This proposal has the following differences compared to what we discussed in linkml/linkml#3701:

(A) The keys in the type_designator_mapping map are expected to be simple, “shell-like” patterns (where the only special characters are *, standing for anything, and ?, standing for any single character), rather than full-fledged regular expressions.

So for example, the map entry that would act as the ultimate fallback (recognising anything) would be just *, instead of .*.

This is because I am not convinced we need the expressivity of full regular expressions here – this seems “overkill” to me.

However I don’t have too much of a strong opinion here. If you (or anyone else for that matter) believe regular expressions would really be beneficial here, that’s fine with me, happy to change.

(B) I introduced the notion of “longest match”, in that the designated type to be effectively used has to be found by searching for the longest matching entry in the type_designator_mapping map.

This is because the type_designator_map is serialised as a dictionary. Because of that, we cannot rely on the order of keys to avoid a premature match.

Consider the example coming from the linkml/linkml#3701 ticket:

type_designator_mapping:
  TC: TargetingComponent
  LC: LoadingComponent
  "*": FrobnicatorComponent

There is no intrinsic guarantee that the * key will be tried last! If the value of the type designator is, say, LC and the * key is tried before the LC key, then LC will be found to match the * entry (because it does, since * matches anything), and the object will be assumed to be a FrobnicatorComponent instead of the intended LoadingComponent.

The “longest match” rule avoids this situation. LC would match the key LC, and because it’s a longer (more precise) pattern, it would take precedence over the shorter * pattern.

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.

2 participants