Template talk:Detect singular
Displaying single wikilinks as singular?
[edit]Hi Hike395—this is a neat template you've created! I'm planning on following up about the discussion about infobox plurality at the VPT, and this template will be one of the ones under consideration, so I'd like it to be in good shape. Two potential improvements that come to mind:
- Adding "and" as a word that triggers a plural result
- Making it so that inputs that consist entirely of a single wikilink trigger a singular result, even if they have a comma or "list".
Thoughts? Also, I realize you missed the earlier plurality discussion. I've drafted an RfC follow-up and am seeking feedback at User_talk:Sdkb#RfC_draft_feedback, so feel free to let me know if you have thoughts about that more broadly. {{u|Sdkb}} talk 00:07, 9 December 2020 (UTC)
- These are both good ideas! It might be easiest to convert this to a small bit of Lua code. Unfortunately, I can't edit the template anymore (since I'm a templateeditor, not an admin). Thanks for letting me know about the RfC. — hike395 (talk) 06:15, 9 December 2020 (UTC)
- @Hike395, just following up about this. The latest stage in my quest to fix the
(s)
issue was this VPT discussion, and although the reception there was somewhat warm enough, there were a bunch of concerns about whether {{Detect singular}} was quite developed enough to be ready for the task. It's enough to make me nervous about trying to roll it out further, since those sorts of concerns can tip consensus. Do you have any interest in working with this in the sandbox to try to get it able to read all wikilinks as singular? In quasi-technical terms, I think what we want is basically to get it to remove anything within [[ ... ]] before it does the check for list things. Cheers, {{u|Sdkb}} talk 04:13, 8 January 2022 (UTC)- I can try to make a short Lua script to implement something this. I'll also ask for a reduction in page protection (down to templateeditor). — hike395 (talk) 05:02, 8 January 2022 (UTC)
- @Sdkb:
Done See Template:Detect singular/testcases. I've handled all of the corner cases correctly:
- Items inside of wikilinks don't get parsed, so treated as singular objects ("[[Alabama]] and [[Georgia]]" becomes plural)
- "and" as its own word triggers plural
- A list of QIDs will trigger plural
- Multiple asterisks in a row count as one asterisk
- Comma only triggers plural if preceded by a letter and followed by a non-letter. This handles "May 4, 2020" and "4,563,523" both as singular
- At this point, we may be able to turn on
|bullets=1by default or get rid of it. We could also get rid of|no_comma=, keeping {{force singular}} for cases like "Martin Luther King, Jr." (which is still recognized as plural outside of wikilinks). What do you think? — hike395 (talk) 06:47, 8 January 2022 (UTC) - Later: handled all of the cases brought up in VPT (i.e., lists with one element, lists with items with commas). Added test cases for them. Should be OK now. — hike395 (talk) 07:16, 8 January 2022 (UTC)
- Television articles will not be using {{force singular}} so make sure that the functionally of
|bullets=and|no_comma=work or don't remove them. Gonnym (talk) 08:41, 8 January 2022 (UTC)- @Gonnym: They work right now: I don't have to remove them. — hike395 (talk) 08:46, 8 January 2022 (UTC)
- Great, that was my only concern. Gonnym (talk) 08:48, 8 January 2022 (UTC)
- @Gonnym: I used Template:Infobox television episode/testcases to test the Lua version: to make everything work, I must set the default
|bullets=yes. That's because {{plainlist}} doesn't expand into <li></li> pairs, but leaves any list items marked by asterisks. One of the VPT requests was to count the number of list items and if there's only one, call it singular. So I need to count the number of asterisk-delimited items under all cases, not just when|bullets=is set explicitly to yes. - In any event, the new Lua code does not break Template:Infobox television episode. Gonny, if there are any other infoboxes that you're worried about, please let me know and I can test the Lua version explicitly. — hike395 (talk) 09:06, 8 January 2022 (UTC)
- That was the one. Thanks for making sure it works :) Gonnym (talk) 09:08, 8 January 2022 (UTC)
- @Gonnym: I used Template:Infobox television episode/testcases to test the Lua version: to make everything work, I must set the default
- Great, that was my only concern. Gonnym (talk) 08:48, 8 January 2022 (UTC)
- @Gonnym: They work right now: I don't have to remove them. — hike395 (talk) 08:46, 8 January 2022 (UTC)
- @Hike395, just checked it out, and that's fantastic! (see token of appreciation on your talk) Regarding the parameters, I think if we're able to remove those, that'd be nice, as simplicity is always good. Once you're done working on the module, let's open an edit request to get the new version implemented. I just saw you commented with some work on {{Infobox settlement}}; I'll take a look at that, and begin some work on {{Infobox person}} myself. Combining those two very prominent infoboxes will hopefully give us a nice launch that others will pick up and spread to other infoboxes. Cheers, {{u|Sdkb}} talk 23:17, 8 January 2022 (UTC)
- Thanks for the barnstar!!
- So far I've tested {{Infobox settlement}} (new), {{Infobox film}} (existing), {{Infobox television}} (existing), and {{Infobox television episode}} (existing). The most challenging one was {{Infobox settlement}}.
- I would recommend using {{Pluralize from text}} if you want to play with {{Infobox person}}. That one will be tricky, with all of the commas, etc.
- Per Gonnym, I think the only parameter we should drop is
|bullets=, which should always be on AFAICT.
- — hike395 (talk) 23:38, 8 January 2022 (UTC)
- Thanks for the barnstar!!
- Television articles will not be using {{force singular}} so make sure that the functionally of
- @Sdkb:
- I can try to make a short Lua script to implement something this. I'll also ask for a reduction in page protection (down to templateeditor). — hike395 (talk) 05:02, 8 January 2022 (UTC)
- @Hike395, just following up about this. The latest stage in my quest to fix the
I'm starting to slowly convert the live versions of {{Infobox television}}, {{Infobox television episode}}, and {{Infobox film}} to use {{Pluralize from text}} and Module:Detect singular. — hike395 (talk) 15:57, 9 January 2022 (UTC)
- Another thought I just had: Would it be possible to make it so that links return as plural if they link to a page with "list of" in the title? E.g.
[[List of honors and awards received by Barack Obama]]should return plural. {{u|Sdkb}} talk 22:39, 9 January 2022 (UTC)- That's a good idea! Will implement. — hike395 (talk) 00:22, 10 January 2022 (UTC)
- My work on {{Infobox person}} is here in the sandbox. I'll test out in previews on a bunch of biographies and see if I spot any errors. Let me know how it looks to you! {{u|Sdkb}} talk 23:36, 9 January 2022 (UTC)
- Okay, we've got a problem at Edgar Allen Poe. It uses
spouse = {{Marriage|[[Virginia Eliza Clemm Poe]]|1836|1847|end=died}}, which is returning plural for some reason. Other uses of {{Marriage}} seem to be doing the same (see e.g. William Hanna). Any idea why, @Hike395? Also, we need to remove everything within a citation, so that the citations at e.g. Mark David Chapman don't lead to a plural result. {{u|Sdkb}} talk 00:17, 10 January 2022 (UTC)- Will check it out. I think removing everything in references is a good idea. — hike395 (talk) 00:21, 10 January 2022 (UTC)
- Problem with {{marriage}} is
Fixed. The template was getting confused by all of the markup, so I simply removed it before doing many of the checks. I'll work on your suggested changes next. — hike395 (talk) 01:10, 10 January 2022 (UTC)
- Problem with {{marriage}} is
- Will check it out. I think removing everything in references is a good idea. — hike395 (talk) 00:21, 10 January 2022 (UTC)
- Also, something to note is that I had a particularly difficult time deciding what to do with
|parents=, since it's often used to only list one parent when a person only has one notable parent, but it should still useParents
in that case, expect for the rare instance where someone actually has only one parent. So I'm not sure we can escape(s)
in that particular scenario. {{u|Sdkb}} talk 00:20, 10 January 2022 (UTC)- We may need to keep the (s), oh well. — hike395 (talk) 00:22, 10 January 2022 (UTC)
- Okay, we've got a problem at Edgar Allen Poe. It uses
Works with Template:Infobox settlement
[edit]I've gotten this to work with all of the area codes, demonyms, nicknames, and mottoes in Template:Infobox settlement/testcases. I made the following changes:
- Create a function _pluralize() that makes it easy to plug into an infobox. This is exposed as Template:Pluralize from text: interface is documented in Template:Pluralize from text/doc.
- Added a parameter
|ignore_links=that, when false, prevents the rewriting of all wikilinks as WIKILINK. This is required to parse the nicknames of some cities. - Made the scanner look for a semicolon-separated list in addition to a comma-separated list.
- Made 4 changes to Template:Infobox settlement/sandbox to set up the automatic parsing of singular/plural, calling {{Pluralize from text}}.
Comments/suggestions are welcome. I'll see if I can find other interesting infoboxes to auto-pluralize. — hike395 (talk) 22:50, 8 January 2022 (UTC)
- If the template is going to support pluralization like you did, then really the next step is to deprecate the plural parameter name (drop
|nicknames=and keep|nickname=), have a bot replace usages and when complete, remove support from the infobox. But that's not really related to this template, you just asked for comments :) Gonnym (talk) 23:43, 9 January 2022 (UTC)- True -- I think we'd have to do that infobox-by-infobox. But happy to remove args[2] when those are all gone. — hike395 (talk) 00:22, 10 January 2022 (UTC)
Proposed new features
[edit]Sdkb proposed two new features (above):
- Strip out references from input.
Not done --- the preprocessor already replaces references with opaque objects, so it's not needed. Plural stuff in references don't trigger the existing code - "List of" inside of a wikilink to trigger plural.
Done --- hopefully this doesn't cause unanticipated issues.
— hike395 (talk) 02:07, 10 January 2022 (UTC)
- Awesome; thanks! {{u|Sdkb}} talk 05:28, 10 January 2022 (UTC)
Protected edit request on 14 January 2022
[edit]This edit request has been answered. Set the |answered= parameter to no to reactivate your request. |
Per above, please adopt the sandbox version, which converts to Lua to improve this template's functionality. Courtesy ping Hike395. {{u|Sdkb}} talk 07:03, 14 January 2022 (UTC)
Done — Martin (MSGJ · talk) 18:46, 18 January 2022 (UTC)
Fix for br bug in marriage?
[edit]@Frietjes: It looks like you added a bug fix to Module:Detect singular/sandbox for a case where there is a trailing line break in an argument to {{marriage}}. You wrote test cases, but you never promoted it to the main Module. I'm about to do some development in the sandbox: do you want me to incorporate your fix, or let it revert? — hike395 (talk) 01:19, 7 September 2022 (UTC)
- hike395, I think we should incorporate it. I can't think of any non-visual reason why there would be a br before a closing div tag. thank you. Frietjes (talk) 15:04, 7 September 2022 (UTC)
Numbered items
[edit]@Hike395, rolling this out to a few infoboxes, I'm wondering if it might be possible to get this template to properly detect values like 3 children or 3 counts of aggravated wiki-vandalism as plural? The RegEx might be something like a number followed by a word with -s or other plural endings. Sdkb talk 01:50, 4 March 2025 (UTC)
- I can see why you would want "plural" for this case, but it's tricky, because "10 very angry caterpillars" vs. "10 meters high". Let me think about it. — hike395 (talk) 02:40, 4 March 2025 (UTC)
- Uh oh. "10 August 2024" is going to be a problem: it should definitely be singular. I don't think this is solvable. I would use {{force plural}} for your cases. — hike395 (talk) 04:28, 4 March 2025 (UTC)
- Maybe if the parameter is known as a "N in TYPE" value that is in the style of the above, the template can have a
|number_type=yesparameter (or any other word). That way editors using it know the risk and confirm the usage is intended. Gonnym (talk) 12:05, 4 March 2025 (UTC)- To give a bit of additional context, I encountered it when adding pluralization to {{Infobox criminal}}'s
|conviction=and Template:Infobox_criminal/testcases#Bill_Cosby failed. Sdkb talk 16:12, 4 March 2025 (UTC)- I like Gonny's suggestion, will play with it. — hike395 (talk) 06:38, 5 March 2025 (UTC)
- I implemented it (as
|parse_number=), but it doesn't work for the Bill Cosby test case, because the conviction string is wrapped in a div. Would it be possible to remove the div? Otherwise you could {{force plural}}. — hike395 (talk) 07:18, 5 March 2025 (UTC)
- I implemented it (as
- I like Gonny's suggestion, will play with it. — hike395 (talk) 06:38, 5 March 2025 (UTC)
- To give a bit of additional context, I encountered it when adding pluralization to {{Infobox criminal}}'s
- Maybe if the parameter is known as a "N in TYPE" value that is in the style of the above, the template can have a
- Uh oh. "10 August 2024" is going to be a problem: it should definitely be singular. I don't think this is solvable. I would use {{force plural}} for your cases. — hike395 (talk) 04:28, 4 March 2025 (UTC)
Weird error with separated entries
[edit]Came across this situation recently:
{{pluralize from text|→ singuar{{csv|1|2|3}}|singular=singular|likely=likely|plural=plural}}{{pluralize from text|→ likely{{br list|1|2|3}}|singular=singular|likely=likely|plural=plural}}
Note that both {{csv}} and {{br list}} call Module:Separated entries... Separated entries specifically has code on lines 24-25 that is supposed to flag things that are plural. It is not clear to me if the error is in THIS module, or if it lies in separated entries.
@Hike395: I know this module is your baby... any chance you can take a look? Zackmann (Talk to me/What I been doing) 06:54, 28 October 2025 (UTC)
- @Zackmann08: Module:Separated entries only does the data plural magic on lines 24-25 if
|dataPlural=1is explicitly set when called. Neither {{csv}} nor {{br list}} call Module:Separated entries with|dataPlural=1. If you want that behavior, you would need to set that parameter. — hike395 (talk) 00:14, 29 October 2025 (UTC)- Uhh. You lost me... Can you give me an example of how that would be done? Is the issue with the code in {{csv}} needing to set a param? Or is it in my transclusion of
{{csv|1|2|3|something_here}}? This is probably gonna be obvious once you explain it but I'm lost at the moment. Zackmann (Talk to me/What I been doing) 00:19, 29 October 2025 (UTC)- Currently {{csv}} contains
{{#invoke:Separated entries|comma}}. To get the behavior you want, it would have to say{{#invoke:Separated entries|comma|dataPlural=1}}— hike395 (talk) 01:25, 30 October 2025 (UTC)- Thank you! much appreciated. Zackmann (Talk to me/What I been doing) 01:57, 30 October 2025 (UTC)
- Currently {{csv}} contains
- Uhh. You lost me... Can you give me an example of how that would be done? Is the issue with the code in {{csv}} needing to set a param? Or is it in my transclusion of