Page MenuHomePhabricator

Ignore multiple same-name fields when guessing template params
Closed, ResolvedPublic3 Estimated Story Points

Description

See T191756#4163084

When templateData is unavailable, the wizard provides "guessed" parameters based on the template code. The guessed parameters may have within them aliases that are almost the same parameter name, with spaces or underscores interchanged.

When TemplateWizard guesses parameters, it should ignore (not display) repeated parameters like these.
However, this should only happen during the "guessing" part. If TemplateData information exists with multiple params, they should all show, since we assume saved TemplateData blobs know better.

Here's an example I saw in TemplateData editor parameter guess

image.png (1×1 px, 149 KB)

Event Timeline

Samwilson subscribed.

I think this is completely within TemplateData, and TemplateWizard doesn't need to do anything. Anyone using the includeMissingTitles templatedata API parameter would benefit from these duplicates being removed.

The problem is you can't really know for sure if one variable in an alias of another without fully parsing the template syntax.

Usually it's

{{{my var|{{{my_var}}}}}}

but that is only by convention. You can add heuristic normalisation rules (space -> '_'), but then you'd need to work out which one was canonical, and which one was the alias, it may vary from template to template, or even within a template.

You also need to consider non-trivial aliases, such as surname/family name/family_name. This will be hard to detect by regex alone, as they may be split across multiple lines.

It's true, and this is really only a rough approximation of aliases and we should make that clear in a message that is displayed wherever the results are used.

But I think it's okay, if we only handle the case-differences, hyphen, and underscore, and use the first-found form of any duplicated parameter. This means that for {{{my var|{{{my_var}}}}}} we'd use my var and we wouldn't even attempt to do anything with surname etc.

But yeah, they key is to make sure people know that if the parameters aren't right (of course, they mightn't know, if they're not familiar with the template) then they know they can add templatedata (or request it be added? we could add button that somehow does that?).

kaldari set the point value for this task to 3.May 1 2018, 11:47 PM
Vvjjkkii renamed this task from Ignore multiple same-name fields when guessing template params to u2daaaaaaa.Jul 1 2018, 1:13 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed the point value for this task.
Vvjjkkii removed a subscriber: Aklapper.
Yann renamed this task from u2daaaaaaa to Ignore multiple same-name fields when guessing template params.Jul 1 2018, 1:09 PM
Yann raised the priority of this task from High to Needs Triage.
Yann updated the task description. (Show Details)
Yann set the point value for this task to 3.
Yann added a subscriber: Aklapper.

Change 455486 had a related patch set uploaded (by Samwilson; owner: Samwilson):
[mediawiki/extensions/TemplateData@master] Ignore subsequent similarly-named parameters when extracting

https://gerrit.wikimedia.org/r/455486

Change 455486 merged by jenkins-bot:
[mediawiki/extensions/TemplateData@master] Ignore subsequent similarly-named parameters when extracting

https://gerrit.wikimedia.org/r/455486

Change 455751 had a related patch set uploaded (by Samwilson; owner: Samwilson):
[mediawiki/extensions/TemplateData@master] Switch from $.inArray to array.indexOf

https://gerrit.wikimedia.org/r/455751

Change 455751 merged by jenkins-bot:
[mediawiki/extensions/TemplateData@master] Switch from $.inArray to array.indexOf

https://gerrit.wikimedia.org/r/455751

Niharika moved this task from QA to Q2 2018-19 on the Community-Tech-Sprint board.