Module talk:nyms

From Wiktionary, the free dictionary
Latest comment: 11 months ago by Wpi in topic langcode prefix problem
Jump to navigation Jump to search

Alt parameters[edit]

@CodeCat: I thought my implementation of altN parameters did work – at least in bhukuda. Where wasn't it working? — Eru·tuon 18:46, 14 February 2017 (UTC)Reply

Your code assumed that args[1][x] and args["alt"][x] should be paired, which is not necessarily the case. —CodeCat 18:49, 14 February 2017 (UTC)Reply
@CodeCat: You mean args[2][x]. That's the way other templates with numbered parameters, such as {{affix}}, work. What is a case in which it would not hold true? I thought args[2] was only for terms. — Eru·tuon 18:58, 14 February 2017 (UTC)Reply
Yes, 2 not 1. A case where it would not hold true is: {{nyms|xx|a|b|c|alt2=x|alt3=y}}. Note that alt1 is missing; by default any holes in the numbering are removed, so args["alt"][2] is "y", not "x"! —CodeCat 19:04, 14 February 2017 (UTC)Reply
That's why I specified allow_holes = true in the params table. That solves the problem. — Eru·tuon 19:06, 14 February 2017 (UTC)Reply
Not quite. Because what if someone then writes {{nyms|xx||b|c|alt1=x|alt2=y}}? —CodeCat 19:08, 14 February 2017 (UTC)Reply
Then they would get an error because parameter 2 is required. — Eru·tuon 19:10, 14 February 2017 (UTC)Reply
Okay, that's wrong. They would just get a prompt for a term: [Term?]. — Eru·tuon 19:13, 14 February 2017 (UTC)Reply
You want args[2] to be {2 = "b", 3 = "c"}, and args["alt"] to be {1 = "x", 2 = "y"}. The problem is that your code uses ipairs(args[2]), which expects tables without holes. It literally starts from 1 and counts upwards. But since there is no args[2][1], the loop terminates right away. This is noted in the documentation of Module:parameters: allow_holes does not play well with functions that expect tables without holes. That's why maxindex exists. —CodeCat 19:19, 14 February 2017 (UTC)Reply
Okay, well, I think having error messages for empty terms is useful. It is not desirable to have instances of a nyms template with [Term?] prompts. So I would like to combine the use of maxindex with the error message for missing terms. — Eru·tuon 19:32, 14 February 2017 (UTC)Reply
Why would it not be desirable? —CodeCat 19:35, 14 February 2017 (UTC)Reply
Unless there is a purpose for an empty term parameter in an entry, it's useless, and useless things are undesirable. — Eru·tuon 20:05, 14 February 2017 (UTC)Reply
It's not useless in {{m}}, so whatever motivation applies to it applies here too. —CodeCat 20:07, 14 February 2017 (UTC)Reply

Testing for singular and plural[edit]

@Erutuon, DTLHS, Wyang: would it be possible to update the module so that it operates as follows?

  • If a template has multiple parameters, e.g., {{synonyms|en|happy|joyful|mirthful}}, then display "Synonyms:".
  • If a template has only one parameter, e.g., {{synonyms|en|happy}}, then display "Synonym:".

SGconlaw (talk) 09:56, 16 June 2018 (UTC)Reply

@Sgconlaw Of course, done:
{{synonyms|en|happy|joyful|mirthful}}: Synonyms: happy, joyful, mirthful
{{synonyms|en|happy|joyful}}: Synonyms: happy, joyful
{{synonyms|en|happy}}: Synonym: happy
Wyang (talk) 21:51, 17 June 2018 (UTC)Reply
Great, thanks! — SGconlaw (talk) 23:54, 17 June 2018 (UTC)Reply

Suggested tweak[edit]

@Erutuon, Jberkel, Rua, Suzukaze-c, Wyang, currently the template {{synonyms}} displays "Synonym" if there is only one term, which is correct. I think it might be useful to be able to use the template (and {{antonyms}}, of course) with thesaurus links as well, like this: {{synonyms|en|''see'' [[Thesaurus:happy]]}}. If you think this is a good idea, would it be possible to tweak the template so that if the only entry is a thesaurus link that begins with ''see'' the template displays the word "Synonyms"? — SGconlaw (talk) 15:26, 5 January 2019 (UTC)Reply

Or, just thinking aloud, another possibility would be for the template to be able to achieve the following:

SGconlaw (talk) 15:29, 5 January 2019 (UTC)Reply

I like your last idea more. The module can figure out whether something is a term or a Thesaurus link based on the prefix. It would make the format more universal. There are a few details to work out though:
  • What if the Thesaurus link isn't the last one in the list?
  • The module allows you to specify qualifiers, alternative display forms and transliterations for each of the items. What happens when someone specifies these for a Thesaurus link?
Rua (mew) 17:31, 5 January 2019 (UTC)Reply
I think it makes sense for the Thesaurus link to always be the last item in a list. I don't know if this can be done automatically by the module – seems like that might be complicated. Maybe we just have to put a note on the appropriate template description pages to tell editors to do so. Qualifiers, alternative display forms and transliterations shouldn't apply to Thesaurus links. — SGconlaw (talk) 19:17, 5 January 2019 (UTC)Reply

Don't know how it's gonna work out, but I like the idea. Per utramque cavernam 19:21, 5 January 2019 (UTC)Reply

+1 The module could automatically put the thesaurus link at the end, but I think it'd be good editing practice to always put it at the end. – Jberkel 20:45, 5 January 2019 (UTC)Reply

I implemented it: Synonyms: cheerful, joyful, merry; see also Thesaurus:happy. If the Thesaurus link is not the last list item, or if you use named parameters with it, you get an error. —Rua (mew) 21:22, 5 January 2019 (UTC)Reply

@Rua: Nice & quick! I think it should still handle the case where there's only a thesaurus link. See Special:Diff/51188179/51205143. – Jberkel 03:39, 6 January 2019 (UTC)Reply
Thanks, @Rua! Yes, my suggestion was also for the situation where there is only a Thesaurus link to be implemented as well. In that case the word before the link should be “see”, not “see also”. — SGconlaw (talk) 10:56, 6 January 2019 (UTC)Reply
Fixed. —Rua (mew) 11:46, 6 January 2019 (UTC)Reply
Excellent! Thanks. — SGconlaw (talk) 12:29, 6 January 2019 (UTC)Reply

I've made the template allow multiple thesaurus links as long as they are at the end. This fixes a module error in ineffable, which has {{syn|en|indescribable|inexpressible|unspeakable|Thesaurus:indescribable|Thesaurus:incomprehensible}}. Either that, or I think a more helpful error message in such a case would be something like "You only get to add one Thesaurus link". — Eru·tuon 20:54, 6 January 2019 (UTC)Reply

It makes more sense to allow multiple Thesaurus links, if there is already a need for it. —Rua (mew) 21:34, 6 January 2019 (UTC)Reply

Links to entries will now be separated by semicolons rather than commas if any of the entry names contains a comma (see this discussion). Maybe the same should be done for Thesaurus links, but it's an unlikely scenario so I'm not doing it yet. — Eru·tuon 02:52, 8 January 2019 (UTC)Reply

Multiple thesaurus links not arranged alphabetically[edit]

Why does {{synonyms|en|row|scuffle|squabble|Thesaurus:dispute|Thesaurus:fight}} end up producing this?

Synonyms: row, scuffle, squabble; see also Thesaurus:dispute, Thesaurus:fight

Shoudn't the thesaurus links be arranged alphabetically? — SGconlaw (talk) 18:08, 3 April 2019 (UTC)Reply

@Sgconlaw: Well, the order should at least be preserved, not reversed. Fixed. — Eru·tuon 18:14, 3 April 2019 (UTC)Reply
Thanks! — SGconlaw (talk) 18:15, 3 April 2019 (UTC)Reply

langcode prefix problem[edit]

@Benwing2 the new functionality you implemented does not work properly, where it now requests for a term instead, see for example 月份. – Wpi (talk) 11:50, 24 June 2023 (UTC)Reply