pt-verb/conj

Fragment of a discussion from User talk:Rua
Jump to navigation Jump to search

It seems rather complicated for something that could really be much simpler than that.

CodeCat16:56, 23 January 2015

I'm not sure how this could be made much simpler. It's quite easy to understand compared to the current version and its nested template madness (pt-verb/doWork/add etc). And the code I wrote is not doing much - some lookups and data presentation. How would you simplify this ?

Jberkel (talk)17:19, 23 January 2015

Well, the templates that Daniel Carrero made are often quite convoluted.

As far as generating a table goes, I use the approach you see in Module:hu-nominals. At the bottom is a make_table function which takes a list of forms and puts them in a table. Everything in the tableCreator module could replaced with a function like that, in theory.

While having the endings as pure data can work, there are often situations where the preceding stem changes depending on what kind of ending is added, and other things like that. So my preference is to treat inflection types as functions, rather than as lists of endings. That way it's much easier to account for predictable changes.

CodeCat17:35, 23 January 2015

Agreed, the table generation code is not straightforward, but there are a few conditionals in there. It also combines the functionality of both {{pt-conj-2pp}} and {{pt-conj}}. As for the data-based approach, it is obviously not as powerful and elegant as a generative approach but simple to implement and understand.

My goal was to create a drop-in replacement for the current inflection code which would produce exactly the same output, with better performance and maintainability.

Once that is in place we can look at ways to replace the data with generators, I think Ungoliant_MMDCCLXIV (talkcontribs) had some ideas for that already. I'm a fan of doing refactorings step-by-step and not in one big swoop.

Jberkel (talk)18:27, 23 January 2015

I prefer doing it step by step as well. I guess it's just because I've done this many times already, I am able to skip some steps.

CodeCat20:17, 23 January 2015

I'd say let's keep the data the way it is for now, and I'll try your template based approach for the table generation to see if it can really simplify things.

Jberkel (talk)09:14, 24 January 2015

ok, I converted the table creation code to use templates instead of the mw.html builder. as a result it might now be a little bit easier to see whats going on, but in terms of lines of code required it's about the same for both versions. what do you think?

Jberkel (talk)02:24, 27 January 2015