shexSpec / spec

ShEx specification
https://shexspec.github.io/spec/
Other
16 stars 9 forks source link

constraining multilingual attributes #48

Open pchampin opened 2 years ago

pchampin commented 2 years ago

During a workshop on Distrbuted Knowledge Graph metadata, the need emerged to constrain a property to contain:

Therefore this would be allowed

<> dct:description "My Knowledge Graph"@en, "Mon graphe de connaissances"@fr.

would be valid, but

<> dct:description "My Knowledge Graph"@en, "My KG"@en.

would not.

Is it possible to express that kind of constraint using ShEx?

labra commented 2 years ago

I think the general constrain is not possible with current ShEx and it may be a nice use case to consider.

ShEx has the possibility to express a language tagged value using:

<LanguageTagged> {
  dct:description [ @~ ] *
}

But that would allow repeated language tagged values.

In case you want a fixed set of languages (for example, es, en and fr) you could use something like:

<LanguageTagged> {
  dct:description [ @en ] ? ;
  dct:description [ @es ] ? ;
  dct:description [ @fr ] ?  
}

But of course, it would better to be able to express the general constraint without having to enumerate all the languages.

I wonder what syntax we could use to express that constraint...maybe something like the following?

<LanguageTagged> {
  dct:description [ @~ ] *  DISTINCT @~
}
ericprud commented 2 years ago

ShEx.js has the beginnings of this in the accessor branch. The idea is that you create UNIQUE constraints scoped to the particular node/shape pair, or (more expensively), across validations of that shape. Unique language tag is a good example where the uniqueness is scoped to the focus node (e.g. two different entities may both have a Spanish dct:description but no single node may do so).

An example of global uniqueness would be that no two Users may have the same combination of givenName and familyName.

It's been a long time since I worked on this feature but let me know of any use cases to keep in mind, or, ideally, if you want to geek through some uses cases/examples.