ICA-EGAD / RiC-O

ICA Records in Contexts-Ontology (ICA RiC-O) GitHub repository web pages
https://ica-egad.github.io/RiC-O/
47 stars 17 forks source link

Question : how to express the sequence order of Records inside a RecordSet ? (to order items in a tree) #97

Open tfrancart opened 5 months ago

tfrancart commented 5 months ago

Sorry if this question sounds stupid or if it was already answered before. What is the expected modelling pattern to indicate the order in which Records are rico:isDirectlyIncludedIn a RecordSet ? The very simple use-case being : I need to display a hierarchical tree of a RecordSet, how am I suppose to order the entries in the tree ? should rico:directlyFollowsInSequence be used ? I could rely on the rico:identifier but there is no garantee that it always corresponds to the sequence of the RecordSet

Some have come to use https://smiy.sourceforge.net/olo/spec/orderedlistontology.html#index to add a sequence number to Records.

andreasnef commented 5 months ago

Hi @tfrancart

Sorting/ordered sets is a challenge in graphs to do efficiently. In the end, rico:followsOrFollowed is what we decided to use. The advantage is that inserting an item into the sequence is easy.

We also considered:

I didn't know about the Ordered List Ontology that you mention, but it seems to be similar to the ORE Proxy solution. Apart fro that, it also seems not really maintained?

tfrancart commented 5 months ago

Sorting/ordered sets is a challenge in graphs to do efficiently.

That's why I am asking :-)

In the end, rico:followsOrFollowed is what we decided to use. We also considered:

May I ask who is "we" ? are you referring to the RiC-CM / RiC-O team, and should I take this answer as the RiC-O recommended way to order Records within RecordSet ? or are you referring to your specific RiC-O implementation ?

Just having a Literal with the index number. But inserting would require changing all resources that follow.

But this is a cost that you pay at insertion time. While the "linked-list-like" rico:followsOrFollowed solution is a cost to pay at query/processing time (and the SPARQL query to order the children of a RecordSet using their rico:followsOrFollowed property, while not impossible to write, is relatively tricky). It thus puts the burden on the data consumer, instead of the data producer.

My point is : simple things should be simple, and I imagine that everyone that will use RiC-O beyond the description of a few records will stumble upon this requirement. So, why not provide a literal property with the index number, in addition to, and formally linked to (with an equivalent query) rico:followsOrFollowed ?

(...) However, introducing Proxy resources seemed too heavy for a simple sequence.

Yes

I didn't know about the Ordered List Ontology that you mention, but it seems to be similar to the ORE Proxy solution. Apart fro that, it also seems not really maintained?

I can't tell, but I agree it seems old. Which is another argument to introduce a literal property with the index number in RiC-O : people implementing RiC-O will do this anyway, let's avoid ressurecting zombies ontologies and provide the adequate property directly in RiC-O.

andreasnef commented 5 months ago

"We" is docuteam, and I am talking about our own usage of RiC-O. While several of us are active in RiC-O development, I am not speaking as a member of EGAD.

Of course, all your inputs are valid, and I also think that there is not generic best solution, but depends on the context and what type of queries/updates that are expected. For another type of ordered list (repeated metadata elements), we are also using the position propery of schema.org property. Maybe this helps?

tfrancart commented 5 months ago

Thanks for all your answers !

florenceclavaud commented 5 months ago

My two cents, as a member of EGAD and lead of RiC-O development team:

The relation does not specify by itself what criteria are used for ordering the sequence. There may actually be zero to many intermediate Entities, ignored or unkown, in the sequence between the two connected Things. Can be used, for example, for specifying that some Record 'precedes' (has next) some Record within a Record Set.

So, rico:folllowsOrFollowed can also be used, but is far less precise; it can also represent a past relation. Finally, rico:directlyFollowsInSequence is a subproperty of the transitive rico:followsInSequenceTransitive, which can thus be inferred automatically and help link (if needed) two record resources that are in the same sequence without being direct successors. Just like rico:directlyIncludes and rico:includesTransitive as concerns hierarchies of RecordResources. BTW @tfrancart, we forgot to represent sequences in RiC-O Converter (I am the first person to be blamed), and so I think we should do it in the v3 ;-).

tfrancart commented 5 months ago

I cannot see exactly for now how you would formally link this new property with rico:directlyFollowsInSequence, so I would be glad to know what you have in mind, Thomas.

I am thinking about this (untested) query:

# Asserts that the rico:indexNumber of a record resource is equivalent to the number of preceding siblings
# linked to this resource through the property path rico:directlyFollowsInSequence+
CONSTRUCT {
  ?x rico:indexNumber ?indexNumber .
} WHERE {
  {
  # select the number of preceding siblings and add one to get a 1-based index number
  SELECT ?x ((COUNT(?precedingSibling)+1) AS ?indexNumber)
  WHERE {
    ?recordset a rico:RecordSet .
    ?x rico:isDirectlyIncludedIn ?recordset .
    # fetches all preceding siblings of ?x through the rico:directlyFollowsInSequence predicate, followed recursively
    ?x rico:directlyFollowsInSequence+ ?precedingSibling .
  }
  # count for each ?x
  GROUP BY ?x
  }
}

You can't assert this in OWL, of course. A SHACL rule would be a possibility

florenceclavaud commented 5 months ago

Yes you are right! this would work perfectly. I was thinking of OWL only, so I could not see a way. Thank you!