translators
translators copied to clipboard
Wikidata translator does not support subclasses of supported classes
An adaptation of Wikidata translator is used in the Cita addon for Zotero.
There, a user noticed that a Wikidata item (Q713593) was not understood by the translator as a "case" item type.
The Wikidata translator maps the Wikidata class "legal case" (Q2334719) to the Zotero's "case" item type. Wikidata item Q713593 is an instance of Wikidata class "United States Supreme Court decision" (Q19692072), which is in turn a subclass of Q2334719.
To have the Wikidata translator support the item Q713593, one would have to make it an instance of Q2334719 as well. But I suspect that might be undesired in Wikidata (i.e., making an item both an instance of its class and the class this is a subclass of).
This is just an example, but it applies to all items which are an instance of a class which is not itself supported by the Wikidata translator, but which is a subclass (or subclass of subclass, etc) of a class that is supported.
In the original report I suggested that one possible fix could be:
fix Zotero's Wikidata translator to support subclasses of supported "instance of" values. To do this, the map could include all subclasses of supported "instance of" values. Alternatively, a separate SPARQL query could be run to determine if an "instance of" value not found in the map is, in fact, a subclass of a supported value.
@zuphilip, what do you think?
Another example was reported by @Dominic-DallOsto. He suggested mapping items of the Wikidata class literary work
(Q7725634) to the Zotero item type book
. literary work
is a subclass of written work
(Q47461344) (although also a subclass of work of art
Q838948), which is already mapped to book
in the Wikidata translator.
Technically one can have several Wikidata item types to map to the same Zotero item type and this is already done e.g. for books:
https://github.com/zotero/translators/blob/2073381a3fe8a72e030fae3956a61ff63e02485c/Wikidata.js#L45-L47
However, I this mapping should maybe stay limited to the main classes. I guess that there is a huge amount of different classes like "decision by court X in country Y". That sounds like too much blowing up this mapping.
An alternative could be to look for the properties present in Wikidata and make a guess out from there. For example if P133 "published in" is there, then it is some kind of publications which we also want to save in Zotero. If in addition we have P4884 "court" then we detect "case" as its Zotero type. That would resolve the first example of the legal US case.
The easiest fix for the second example would be to change or add the P31 to Q571 "book", because that is also what the description is saying about it.
one can have several Wikidata item types to map to the same Zotero item type (...) However, I [think] this mapping should maybe stay limited to the main classes
I agree. That's why I wondered whether the translator could run a separate SPARQL query to determine if an "instance of" value not found in the map is, in fact, a subclass of a supported value. What do you think?
The easiest fix for the second example would be to change or add the P31 to Q571 "book"
This would be analogous to what was said in the first example:
To have the Wikidata translator support the item Q713593, one would have to make it an instance of Q2334719 as well. But I suspect that might be undesired in Wikidata (i.e., making an item both an instance of its class and the class this is a subclass of).
In this regard, a Wikidata help page says that "if an item A is an instance of class B, and class B is a subclass of class C, item A is implicitly also an instance of class C. There is no general need to add a statement for the relation A→C to Wikidata". I found an example where it is suggested that such redundant claims be deleted.
run a separate SPARQL query to determine if an "instance of" value not found in the map is, in fact, a subclass of a supported value
By the way, in addition to the extra coding, there may be cases where an item is an instance of a class which is a subclass of two or more classes mapped to different Zotero item types. For example, Q95626722 is an instance of preprint
(Q580922), which is a subclass of article
(Q191067), which is in turn a subclass of document
(Q49848) which is mapped to Zotero item type document
. However, article
is also a subclass of written work
(Q47461344) which is mapped to Zotero item type book
. How shall we decide what Zotero item type to use?