Page MenuHomePhabricator

Add support for “instance or subclass of” relation (days: 1)
Closed, ResolvedPublic

Description

Some properties that want to allow either relation, from Template talk:Constraint:Type:

  • P​1080 “from fictional universe”: Most things are instances of some “fictitious entity” subclass, but “lightsaber” is a subclass of “fictional sword”, not an instance of anything.
  • P​1422 “Sandrart.net person ID”: some “persons” are groups that, in Wikidata, are represented by a class item.
  • P​306 “operating system” (value type constraint): an operating system, like Linux or Windows (yes, I know, OS ≠ kernel, shut up), or the special value “cross-platform”. “cross-platform” isn’t an instance of anything, but it is at least an “indirect” subclass of itself (path length 0), so the relation “instance of or subclass of” would permit that value, which the current relation “instance of” doesn’t.
  • P​705 “Ensembl Protein ID” needs this, because its items are either proteins (instances) or families of proteins (subclasses). There are a lot of items using this property.

There’s already an item for this relation (Q30208840), and apparently some constraints are already using it. But I don’t know if this feature is high priority.

Event Timeline

So this does not exist yet but editors would like to have it? Or it does exist and we need to support it in the extension?

Well, there are a bunch of constraint statements on Wikidata with “instance or subclass of” relation, all added by User:Dhx1 as far as I can see (who also added it to the documentation – I reverted that part, see discussion).

It would be good to make this work.

Another case worth noting is P39 "position held":

Position held (P39) can take a value that is either

  • a particular position, eg Mayor of London (Q38931), i.e. a specific instance of (P31) of position (Q4164871); or
  • a generic class of position, eg mayor (Q30185), that is a subclass of (P279) of position (Q4164871).

This is high-profile data, so an area where active constraint-checking is highly desirable.

However for the moment it seems that can be done is specify the constraint-type-value relation as Q30208840 "instance or subclass of", and accept that that will be interpreted as a broken constraint specification, and not be acted upon until this ticket is dealt with.

I think we should replace the current "relation" property to two new properties A and B (don't know what's the suitable name)
A is like the 'instance of' property, B is like the 'subclass of' property. Item X is in class Y iff X <a> Y1 <b1> Y2 <b2> ... <bn> Y, where a is one of A's value (or X=Y1 if a=novalue), b1, b2, ... are one of B's value, n is non-negative integer.

e.g.
instance of relation => A=P31, B=P279
subclass of relation => A=novalue, B=P279 (A=P279, B=P279 if the type item itself should be excluded)
instance or subclass of relation => A=P31 and novalue, B=P279
T173593 (1) => A=novalue, B=P171
T173593 (2) => A=P31, B=P171
T173596 => A=P106, B=P279

I think hardcoded WBQualityConstraintsInstanceOfId and WBQualityConstraintsSubclassOfId should be removed so that it will be easy to check other properties with a interesting chain (e.g. P131, P22).

I have also used this constraint type for https:wikidata.org/wiki/Property:P2341 "indigenous to", where clothing and dance in particular require an instance or a subclass.

If we have this contraint available to editors, it should work.

99of9 updated the task description. (Show Details)
99of9 subscribed.

Change 404708 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Remove unused message

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

Change 404710 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Add support for parsing “instance or subclass of” relation

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

Change 404711 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseQualityConstraints@master] Add support for “instance or subclass of” relation

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

WMDE-leszek renamed this task from Add support for “instance or subclass of” relation to Add support for “instance or subclass of” relation .Jan 18 2018, 11:08 AM
WMDE-leszek renamed this task from Add support for “instance or subclass of” relation to Add support for “instance or subclass of” relation (days: 1).

Change 404708 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Remove unused message

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

Change 404710 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Add support for parsing “instance or subclass of” relation

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

Change 404711 merged by jenkins-bot:
[mediawiki/extensions/WikibaseQualityConstraints@master] Add support for “instance or subclass of” relation

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

Okay, the code side is done and will probably be deployed next Wednesday. Afterwards, we need to update the on-wiki documentation.

Okay, the code side is done and will probably be deployed next Wednesday.

Nope, I forgot that there’ll be no MediaWiki train for the next two weeks due to Dev Summit and RelEng team offsite events (see wikitech:Deployments). Next train for group1 is on February 7th.