Page MenuHomePhabricator

Implement “Units” constraint
Closed, ResolvedPublic

Description

As a data maintainer I want to be able to define which units are allowed for a given property with datatype quantity.
I only want to define the base-unit for a dimension and then automatically all the other derived units are also allowed.

See Template:Constraint:Units: must use one of the listed units (or novalue for no units allowed).

This ought to cover T132704.

Steps:

  • see README for adding a new constraint type in general
  • this checker will need some unit resolver thingy injected – see RangeCheckerHelper (because we also want to accept millimetres if the constraint says metres)

Patch-For-Review:

Details

Related Gerrit Patches:
mediawiki/extensions/WikibaseQualityConstraints : masterMove word inside {{PLURAL}} template
mediawiki/extensions/WikibaseQualityConstraints : masterUse wbqc-violation-message-units-none message
mediawiki/extensions/WikibaseQualityConstraints : masterAdd missing roles to AllowedUnitsChecker messages
mediawiki/extensions/WikibaseQualityConstraints : masterAdd support for parsing units parameter
mediawiki/extensions/WikibaseQualityConstraints : masterAdd “allowed units” constraint type

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMay 3 2017, 2:16 PM
Lydia_Pintscher triaged this task as High priority.May 5 2017, 12:59 PM
Lydia_Pintscher moved this task from incoming to ready to go on the Wikidata board.

We might also want to add another constraint, for the base unit of a quantity (kg, s, m, …), accepting any quantity whose conversion to standard units (via UnitConverter) has that base unit as unit.

I suppose this could also be done as the same constraint type with two different kinds of parameters.

Restricted Application added a subscriber: PokestarFan. · View Herald TranscriptJul 24 2017, 2:16 PM

@Lydia_Pintscher:

I only want to define the base-unit for a dimension and then automatically all the other derived units are also allowed.

That’s a change in behavior from KrBot (for example, P​2660 “topographic prominence” has a constraint stating that the unit should be “metre”, and the database report lists lots of items with unit “foot” as violations). Are we sure we want this to be the default behavior?

We just talked about it and it makes sense to have the default be more lenient for now. If needed we can add a parameter to be more strict later.

Restricted Application added a project: User-Ladsgroup. · View Herald TranscriptMar 27 2018, 2:13 PM

Change 423972 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Add support for parsing units parameter

https://gerrit.wikimedia.org/r/423972

Change 423973 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Add “allowed units” constraint type

https://gerrit.wikimedia.org/r/423973

Esc3300 added a subscriber: Esc3300.EditedApr 16 2018, 6:07 PM

I'm not sure if it's a good idea to allow any convertible unit by default.

There are several things that could be improved around quantity datatype and I wouldn't start with this one.

Change 423972 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Add support for parsing units parameter

https://gerrit.wikimedia.org/r/423972

Change 423973 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Add “allowed units” constraint type

https://gerrit.wikimedia.org/r/423973

I’m an idiot, back to “in progress” we go

Change 427391 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Add missing roles to AllowedUnitsChecker messages

https://gerrit.wikimedia.org/r/427391

Change 427392 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Use wbqc-violation-message-units-none message

https://gerrit.wikimedia.org/r/427392

Change 427393 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Move word inside {{PLURAL}} template

https://gerrit.wikimedia.org/r/427393

Change 427391 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Add missing roles to AllowedUnitsChecker messages

https://gerrit.wikimedia.org/r/427391

This is live on wikidata-constraints now – see e. g. the last four statements of Leonardo da Vinci.

Change 427392 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Use wbqc-violation-message-units-none message

https://gerrit.wikimedia.org/r/427392

Change 427393 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Move word inside {{PLURAL}} template

https://gerrit.wikimedia.org/r/427393