Hey,
In the current JSON, statements are grouped by property ("statement groups") and the statements in each group are in a list (ordered). The statement groups, however, are in a map (unordered) and no extra order information is given [1].
Should we consider this the official definition? When we defined the original datamodel, we used to have statements ordered (and there were no groups by properties), but now we have the groups and abandoning statement-group order makes sense with Reasonator-style UIs that find a good order automatically. However, this should then also match the internal datamodel implementation as used, e.g., for diffs (if a bot edits an item, and statement order is not part of the data, then it might randomly reorder statement groups).
Tools that work on the JSON as it is now cannot guarantee any order of statement groups. In Java the order you get can really be different from run to run. So we should change our interfaces in WDTK from List to Set (otherwise our tests fail as soon as we read more than one statement). But before doing this, I would like to know if this is really the future or if there are plans to keep the order of statement groups and to extend the JSON instead.
Cheers,
Markus
[1] The current JSON has the following ordered elements:
* statements in one statement group (the collection of all statements with the same property) are stored as a list (ordered) * statement qualifiers are a map (no order) but extra order information is given ("qualifier-order") * the "list of references" of a statement is indeed a list (ordered) * the snaks of each reference are a map (no order) but extra order information is given ("snak-order") * aliases of each language are stored in a list (ordered)
What is not ordered:
* statement groups are stored in a map (from property ids to lists of statements with this property); no order is expressed between statements with different main properties. * labels, descriptions, alias lists (map from language to content)
Hey Markus,
In the PHP DataModel, statements are still kept in just an ordered list. The lack of order information for the statement groups in the JSON was, as far as I know, not a design choice and simply something not thought about. So far I've been assuming that if we'd introduce a list of statement groups in the PHP DataModel, that it'd be ordered.
Cheers
-- Jeroen De Dauw - http://www.bn2vs.com Software craftsmanship advocate Evil software architect at Wikimedia Germany ~=[,,_,,]:3
Hi Jeroen
So far I've been assuming that if we'd introduce a list of statement groups in the PHP DataModel, that it'd be ordered.
Do you think this would be a good idea? I think it is because the statements are basically ordered by property and therefore it makes sense to group them in the datamodel as well. They are grouped in the ui and in the list so why not create a StatementGroup and StatementGroupList for this case? Those could replace the current StatementList in Item and Property.
Best regards, Bene
Hey,
So far I've been assuming that if we'd introduce a list of statement groups
in the PHP DataModel, that it'd be ordered.
Do you think this would be a good idea? I think it is because the statements are basically ordered by property and therefore it makes sense to group them in the datamodel as well. They are grouped in the ui and in the list so why not create a StatementGroup and StatementGroupList for this case? Those could replace the current StatementList in Item and Property.
This was discussed quite some time ago, and added as a TODO. https://github.com/wmde/WikibaseDataModel/issues/22
Still have not gotten to that though.
Cheers
-- Jeroen De Dauw - http://www.bn2vs.com Software craftsmanship advocate Evil software architect at Wikimedia Germany ~=[,,_,,]:3
wikidata-tech@lists.wikimedia.org