Usuari Discussió:Vriullop

El contingut de la pàgina no s'admet en altres llengües.
De la Viquipèdia, l'enciclopèdia lliure


Hi, Can you help to find a solution ? I create a generic infobox based on wikidata informations. Next, I tried to add a selection of an other infobox more specific (when it is possible) based on P31 (other otherwise select the generic infobox). But I got more than 10 values for building infobox for example and it's not enough.

Is there any solution to do that with a wikidata query? Thank you in advance. --وهراني (disc.) 10:29, 15 maig 2023 (CEST)Respon[respon]

@وهراني I'm not sure if I understand your problem. I think you mean if Instance of (P31) = Human (Q5) then select Infobox person, right? What is the case where you get more than 10 values? I need more context. V.RiuLlop (parlem-ne) 11:46, 15 maig 2023 (CEST)Respon[respon]
The idea is to have an infobox template ex. {{Infobox generic}} containing the following code :
{{#switch: {{#invoke:Wikidades|claim|property=P31|listmax=1|formatting=raw}}
  | Q5 = {{Infobox person}}
  | Q11424 = {{Infobox film}}
  | Q11032|Q1110794|Q41298 = {{Infobox periodic}}
  | Q867143|Q27686|Q4989906|Q44539|Q41176|Q16970|Q23413|Q16560|Q3947| Q11303 = {{Infobox building}}
  | #default = {{Infobox generic/core}}
It's hard to gather all Qid foreach template. Is there an easy solution ? --وهراني (disc.) 20:47, 15 maig 2023 (CEST)Respon[respon]
@وهراني Ok, I get it. The solution is to make recursive calls until you find a value that identifies an infobox. I've made a sample function in my sandbox. The process is, for example: Eiffel Tower (Q243) > Lattice tower (Q1440476) > Tower (Q12518) > Building (Q41176).
It does not work for churches because it reaches Religious building (Q24398318) where "building" is defined as the second value, not the first one. The same happens with Newspaper (Q11032) that not detects "periodical". To be consistent, function getParentValues should be hacked using whitelist instead of just the best statement. To bypass it, more values can be defined in the table. This was intended to be avoided in the first place, but it can detect far more cases. V.RiuLlop (parlem-ne) 13:49, 16 maig 2023 (CEST)Respon[respon]
I found a similar solution kab:Module:Categorizer created by @Sami At Ferḥat. What you think about it ? --وهراني (disc.) 19:59, 16 maig 2023 (CEST)Respon[respon]
@وهراني Sami has made a great job. The idea behind it is the same I proposed: get P31, search those ids in tables, if not found then try again with parent Subclass of (P279). The good point is that it tries it with all P31 values while getParentValues only does it with the best one. To be improved: avoid using mw.wikibase.getEntity, it uploads the whole entity, it is expensive and may run out of memory; also, more iterations of P279 will reduce number of definitions needed in tables, getParentValues makes up to 10 iterations, just as a protection.
Let me think some days about it. As I commented, a good solution can be a fork of function getParentValues to work with more than one value and simplified to this user case. V.RiuLlop (parlem-ne) 08:55, 17 maig 2023 (CEST)Respon[respon]
@وهراني It has become simpler when I realized that it's better to do it from scratch than to try to reuse Wikidades. This module has multiple purposes and options but in this case it's all about doing the right iterations. See the new version Special:Permalink/31699987. I left the options open to be able to do other queries with other tables or other properties. V.RiuLlop (parlem-ne) 13:45, 18 maig 2023 (CEST)Respon[respon]
Thank you very much. Simple works are always better. With your permission, I'll test it and use on arabic wikipedia and perhaps and I'll add more features. --وهراني (disc.) 21:58, 18 maig 2023 (CEST)Respon[respon]