rdfjs / shacl-ui

SHACL-driven UIs
https://rdf.js.org/shacl-ui/
11 stars 2 forks source link

Use-case : define node labels #31

Open WilliamChelman opened 12 months ago

WilliamChelman commented 12 months ago

In either context of searching for a node, displaying it in a tree, an autocomplete, or wherever other case. We should be able to define the logic in which the label of a given node is determined or computed.

Simple property at the sh:PropertyShape level

At its simplest, a property shape could be defined as being used for defining the label of the node. Not advising a particular nomenclature just yet, but it could be defined as such:

<prefLabel>
  a sh:PropertyShape ;
  sh:path skos:prefLabel ;
  sh:datatype rdf:langString ; 
  shui:purpose shui:DefaultLabelPurpose ;
.

A boolean might be enough, but I do like the idea of defining purposes/use-cases for shapes in general (not only linked to labelling, I might created a dedicated issue for that). We could imagine other labelling purposes like shui:AutocompleteLabelPurpose, shui:SearchLabelPurpose, shui:TreeLabelPurpose and so on, depending on what we feel might make sense.

"Templating" at the sh:NodeShape level

The previous proposition would likely work for most cases, but what about label composition? For example, we might want to concatenate, for a given skos:Concept, its skos:prefLabel and the skos:prefLabel of all its "broader chain". For such more complex cases, being able to make use of a sparql query to build the label triples would be a good option:

<Concept>
  a sh:NodeShape ;
  sh:targetClass skos:Concept ;
  shui:labelQuery """a spaqrl query that returns labels"""
.

Wrapping things all together

Defining labelling logic at 2 possible different levels might be both counter-intuitive and hard to follow, so maybe have everything at the sh:NodeShape level instead?

<Concept>
  a sh:NodeShape ;
  sh:targetClass skos:Concept ;
  shui:labelDefinition [ 
    shui:purpose shui:DefaultLabelPurpose ;
    shui:propertyForLabel skos:prefLabel ;
  ]
  shui:labelDefinition [ 
    shui:purpose shui:SearchLabelPurpose ;
    shui:queryForLabel """my awesome SPARQL query""" ;
  ]
.

But I'll stop there for now, as we first need to decide it this feature makes sense in shacl-ui or not 😅

HolgerKnublauch commented 11 months ago

In my experience, the expectation for labels is that they also work in the other direction, e.g. for auto-complete purposes. Do you have thoughts on how this could work if labels are dynamically created?