[Wiki Loves Monuments] Help! List to template transformation

Maarten Dammers maarten at mdammers.nl
Sun Jul 1 11:56:54 UTC 2012


Hi Andrij,

Op 29-6-2012 22:59, Андрій Бондаренко schreef:
> It seems to be interesting but how could it resolve the main issue - 
> wikitable-to-template convertion?
You could use pywikipedia. This line should be a good basis:

replace.py -lang:uk -regex 
"\|-[\s\r\n]+\|(.+)\|\|(.+)\|\|(.+)\|\|(.+)\|\|(.+)\|\|\|\|(.+)\|\|(.+)\|\|(.+)" 
"{{Templatename\n|p1=\1\n|p2=\2\n|p3=\3\n|p4=\4\n|p5=\5\n|p6=\6\n|p7=\7\n|p8=\8\n}}"
-page:%D0%92%D1%96%D0%BA%D1%96%D0%BF%D0%B5%D0%B4%D1%96%D1%8F:%D0%92%D1%96%D0%BA%D1%96_%D0%BB%D1%8E%D0%B1%D0%B8%D1%82%D1%8C_%D0%BF%D0%B0%D0%BC%27%D1%8F%D1%82%D0%BA%D0%B8/%D0%92%D1%96%D0%BD%D0%BD%D0%B8%D1%86%D1%8C%D0%BA%D0%B0_%D0%BE%D0%B1%D0%BB%D0%B0%D1%81%D1%82%D1%8C/%D0%96%D0%BC%D0%B5%D1%80%D0%B8%D0%BD%D0%BA%D0%B0

The 
"\|-[\s\r\n]+\|(.+)\|\|(.+)\|\|(.+)\|\|(.+)\|\|(.+)\|\|\|\|(.+)\|\|(.+)\|\|(.+)" 
will match the row and it's fields.
"{{Templatename\n|p1=\1\n|p2=\2\n|p3=\3\n|p4=\4\n|p5=\5\n|p6=\6\n|p7=\7\n|p8=\8\n}}" 
can be modified to use your template with the right parameters.

You should probably not include WLM in the template name. WLM is just a 
project in September, your heritage project should outlast it! Something 
like "Пам'ятки_рядок" and similar for the header. You seem to be having 
multiple sources. How is everything structured exactly? We might have to 
create multiple lists. We did this for example in Denmark. The have 2 
registers and we created two sets of templates and lists to be able to 
properly handle that.

You should have a chat with Elke, she understands the language much 
better than I do ;-)

Maarten





More information about the WikiLovesMonuments mailing list