Module talk:PropertyChain
Jump to navigation
Jump to search
Prototype
[edit]Copied from Commons_talk:Batch_uploading/Geograph#Reverse_geocoding
Multichill I got a little prototype at Module:PropertyChain:
{{#invoke:PropertyChain|PropertyChain|qID=Q2510182|pID=P131}}
gives Lakes→South Lakeland→Cumbria→North West England→England→United Kingdom{{#invoke:PropertyChain|PropertyChain|qID=Q981109|pID=P131|lang=ru|separator==>|link=commonscat}}
gives West Ilsley=>Западный Беркшир=>Беркшир=>Юго-Восточная Англия=>Англия=>Великобритания
--Jarekt (talk) 21:51, 9 April 2020 (UTC)
- Really nice. I would like to be able to set a stop condition. In this case when the located in the administrative territorial entity (P131) is the same as country (P17) on the first item.
- So I can make
{{#invoke:PropertyChain|PropertyChain|qID=Q817840|pID=P131|endpID=P17}}
(Bennebroek→Bloemendaal→North Holland→Netherlands→Kingdom of the Netherlands) should stop Netherlands (Q55) (and include this item. - Not sure about the visual part if we show it in files like File:Talsarnau Chapel - geograph.org.uk - 6000168.jpg. May just the location with the pencil and than small between () the output of this template?
- Multichill (talk) 08:49, 10 April 2020 (UTC)
Multichill Now the code has 2 stopping criteria: endpID and endqID
{{#invoke:PropertyChain|PropertyChain|qID=Q817840|pID=P131|endpID=P17}}
gives "Bennebroek→Bloemendaal→North Holland→Netherlands"{{#invoke:PropertyChain|PropertyChain|qID=Q817840|pID=P131|endqID=Q55}}
gives "Bennebroek→Bloemendaal→North Holland→Netherlands"
--Jarekt (talk) 14:45, 13 April 2020 (UTC)
- @Jarekt: coming back to this one. I would like to add it to {{Geograph from structured data}}.
- What do you think the best approach would be? Maybe a helper function in this module so that it grabs location of creation (P1071) and starts form there?
- It should probably look like: "Talsarnau (Talsarnau→Gwynedd→Wales→United Kingdom)". Or any better ideas? Multichill (talk) 16:33, 25 April 2020 (UTC)
- One off wikidata modules should be able to look up a property and return it as a item ID. I will try to see how. --Jarekt (talk) 01:22, 27 April 2020 (UTC)
- Multichill, I think I got this, thanks to user:RexxS's advice again. See File:Talsarnau Chapel - geograph.org.uk - 6000168.jpg or any other file using {{Geograph from structured data}}, and let me know if this is what you had in mind. --Jarekt (talk) 02:04, 27 April 2020 (UTC)
- Just in case you run into the same problems as I did when a town is in a region that is part of two higher level regions, there is code in Module:WikidataIB in the location function (lines 1484 to 1635) that usually resolves it.
- The last example at Module talk:WikidataIB/testing #location shows how that works. Cheers --RexxS (talk) 02:33, 27 April 2020 (UTC)
- Multichill, I think I got this, thanks to user:RexxS's advice again. See File:Talsarnau Chapel - geograph.org.uk - 6000168.jpg or any other file using {{Geograph from structured data}}, and let me know if this is what you had in mind. --Jarekt (talk) 02:04, 27 April 2020 (UTC)
- One off wikidata modules should be able to look up a property and return it as a item ID. I will try to see how. --Jarekt (talk) 01:22, 27 April 2020 (UTC)