Page MenuHomePhabricator

Ignore multiple same-name fields when guessing template params
Closed, ResolvedPublic3 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

Details

Related Gerrit Patches:
mediawiki/extensions/TemplateData : masterSwitch from $.inArray to array.indexOf
mediawiki/extensions/TemplateData : masterIgnore subsequent similarly-named parameters when extracting

Event Timeline

Niharika created this task.Apr 27 2018, 6:59 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptApr 27 2018, 6:59 PM
Samwilson added a subscriber: Samwilson.

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.

Restricted Application added a project: VisualEditor. · View Herald TranscriptApr 30 2018, 2:34 AM

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

Mooeypoo updated the task description. (Show Details)Aug 27 2018, 5:59 PM

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

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

Flagging this for @Deskana.

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 closed this task as Resolved.Oct 12 2018, 11:24 PM
Niharika moved this task from QA to Q2 2018-19 on the Community-Tech-Sprint board.
Restricted Application added a project: User-Ryasmeen. · View Herald TranscriptOct 12 2018, 11:24 PM