• Re: Algol 68 - pluralizing text parts

    From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.misc on Mon Aug 25 01:21:16 2025
    From Newsgroup: comp.lang.misc

    On 24.08.2025 00:08, Keith Thompson wrote:
    Janis Papanagnou <janis_papanagnou+ng@hotmail.com> writes:
    [...]
    Since I'm also doing a lot of text oriented processing
    I'm usually using some pluralization, e.g. in "C" like

    printf ("Copy %d item%s ...", n, (n>1 ? "s" : "") );
    [...]

    I'd probably write :

    Yes, sure. That was just an ad hoc typed sample to show
    what I'm basically doing when considering more accurate
    formulations in software.


    printf("Copy %d item%s ...", n, n==1 ? "" : "s");

    For legibility I prefer using parenthesis, though.

    (And not only because of precedence rules in case of C++
    where you typically cout << ... items.)


    "Copy 0 items" seems more correct than "Copy 0 item".

    Well, *that* can't happen in this application case. ;-)
    (I would also not "add -2 items", BTW, to indicate any
    removal.)

    But in the cases that you're obviously referring to I'd
    typically also avoid numbers and use "no items" (or "zero
    items", depending on context).

    Janis

    --- Synchronet 3.21a-Linux NewsLink 1.2
  • From Janis Papanagnou@janis_papanagnou+ng@hotmail.com to comp.lang.misc on Mon Aug 25 01:31:15 2025
    From Newsgroup: comp.lang.misc

    On 24.08.2025 01:01, Andy Walker wrote:
    On 23/08/2025 17:49, Janis Papanagnou wrote:
    Often we stumble across text output from software, like
    Copy 42 items (12 minutes left).
    ...
    Copy 1 items (1 minutes left).
    Since I'm also doing a lot of text oriented processing
    I'm usually using some pluralization, e.g. in "C" like
    printf ("Copy %d item%s ...", n, (n>1 ? "s" : "") );

    Firstly, I agree with Keith that English uses the
    plural in the case n = 0; n < 0 is, I suppose, unlikely to
    occur in real examples.

    As said in my reply to Keith's post this makes no sense in
    an application case where I illustrated a copying progress.

    (I agree of course about the plural of 0; how could I not.)


    [...]. So instead of inline-ternary operators ?:
    or procedures these Algol 68 operator variants emerged:
    PRIO PLURAL = 6;
    OP PLURAL = (INT amount, STRING word) STRING :
    whole (amount, 0) + word + ( amount > 1 | "s" | "" );

    Secondly, if you're generalising, then you "should" look
    at the end of "word": eg "flies" rather than "flys". I accept,
    of course, that there are limits to how much should be done; you
    can spend years tweaking stuff like that.

    The context where I use that is a very primitive application
    case; I'm not doing text generation or anything complex like
    that. - In my post I had mentioned roguelikes, like Nethack.
    If you want to see a much more sophisticated algorithm have a
    look into the respective source code; they have spent really
    a lot effort for pluralizing rules (much more than just the
    example you added!), dozens or even hundreds of lines (IIRC).
    To give an example; most stuff (items) are fixed in Nethack,
    but there's one thing where you can externally define a fruit;
    without thinking I defined "cactus", and was surprised when I
    played a game and found "two cacti" lying on the ground. :-)

    Janis

    [...]


    --- Synchronet 3.21a-Linux NewsLink 1.2