Page 1 of 1

pluralizing something within a group call but not at the end

Posted: Mon Jan 28, 2013 pm31 7:57 pm
by thunderclap
I've got this:

GROUP Sphere
ENTRY drop of ##liquid;

Using ##Sphere;~ would pluralize the liquid, which is the wrong thing to be pluralized there. Is there any way to make that "drops of" without having to make a separate group that's always pluralized?

I take it that the following wouldn't work because the group call would screw it up?

MULTI drop of ##liquid;:drops of ##liquid;

Re: pluralizing something within a group call but not at the

Posted: Mon Feb 04, 2013 am28 12:42 am
by Ryan
This is an interesting problem. Of course, the reason that the usual ~ AGC won't work is that autogrammar functions are processed after all references have been parsed. So, what you see as "ENTRY Some ##Sphere;~." will be seen by the parser, by the time it applies autogrammar rules, as "Some drop of liquid~." - which of course will be pluralised (quite correctly) as "Some drop of liquids."

There is a (currently proposed) addition in the 5.4 language specification to allow the capitalisation AGC to be applied to paranthsized passages of text (see this thread), and the functionality you're seeking here is essentially an application of this logic to the pluralisation AGC, rather like the following:

Code: Select all

ENTRY Some (drop of water)~.
BLANK Produces: "Some drops of water."


However, implementation of anything like this would clearly be somewhat non-trivial, as it would require the parser itself to have a human-level understanding of a potentially complex passage of paranthesised text. Therefore, a function literally working like this is unlikely to be possible, short of a true artificial intelligence being built into future parsers. Let's discount that possibility for now. :P

And of course, your example using the MULTI qualifier wouldn't work for two reasons: firstly (and most importantly), that the pluralisation AGC would only be applied to the last word of the sentence anyway; and secondly, as you noted, the inclusion of references in the MULTI qualifier would cause it not to consistently match the given phrase.

The most direct route is, as you mentioned, to use seperate groups for plural and singular entries - a straightforward, but somewhat inefficient process:

Code: Select all

GROUP Phrase
ENTRY <Phrase 1>A cup containing several #*PluralSphere; will be heavier than a cup containing a #*SingularSphere;.

GROUP SingularSphere
ENTRY marble
ENTRY crystal ball
ENTRY drop of ##Liquid;

GROUP PluralSphere
ENTRY marbles
ENTRY crystal balls
ENTRY drops of ##Liquid;


There are some slightly more efficient but somwhat inelegant ways to break this down further:


Code: Select all

GROUP Phrase
ENTRY <Phrase 1>A cup containing several #*PluralSphere; will be heavier than a cup containing a #*SingularSphere;.

GROUP SingularSphere
ENTRY ##Sphere;
ENTRY ##SpecialSphere;

GROUP PluralSphere
ENTRY ##Sphere;~
ENTRY ##PluralSpecialSphere;

GROUP Sphere
ENTRY marble
ENTRY crystal ball
ENTRY golf ball
ENTRY raindrop
ENTRY planetoid

GROUP SpecialSphere
ENTRY drop of ##Liquid;
ENTRY balloon of ##Liquid;

GROUP PluralSpecialSphere
ENTRY drops of ##Liquid;
ENTRY balloons of ##Liquid;

GROUP Liquid
ENTRY water
ENTRY blood
ENTRY oil


As you can see, the advantage of this is that only the special case entries need to be duplicated, saving space in the script. And of course, RATIO qualifiers could be used to balance the likelihood of the different groups:

Code: Select all

GROUP Phrase
ENTRY <Phrase 1>A cup containing several #*PluralSphere; will be heavier than a cup containing a #*SingularSphere;.

GROUP SingularSphere
RATIO 5:##Sphere;
RATIO 2:##SpecialSphere;

GROUP PluralSphere
RATIO 5:##Sphere;~
RATIO 2:##PluralSpecialSphere;

GROUP Sphere
ENTRY marble
ENTRY crystal ball
ENTRY golf ball
ENTRY raindrop
ENTRY planetoid

GROUP SpecialSphere
ENTRY drop of ##Liquid;
ENTRY balloon of ##Liquid;

GROUP PluralSpecialSphere
ENTRY drops of ##Liquid;
ENTRY balloons of ##Liquid;

GROUP Liquid
ENTRY water
ENTRY blood
ENTRY oil


The COUNT qualifer proposed for the Regnus 5.4 specification would be a slightly more elegant way to achieve the same:

Code: Select all

GROUP SingularSphere
COUNT Sphere:##Sphere;
COUNT SpecialSphere:##SpecialSphere;

GROUP PluralSphere
COUNT Sphere:##Sphere;~
COUNT PluralSpecialSphere:##PluralSpecialSphere;


However, I can't currently think of a sensible solution using current language features. It is possible using ALIAS qualifiers and hidden references storing flags, but this is such an over-complex solution that it doesn't gain any efficiency over the methods above. So... For now, you have me stumped. :P

Can anyone think of a better way?

Ryan

Re: pluralizing something within a group call but not at the

Posted: Mon Feb 04, 2013 am28 2:16 am
by thunderclap
I didn't realize the problem was going to be that complicated. Your post did give me an idea though.

The first thing I can say is that the problem would only occur for unique entries, so it would make sense to have a way to define the pluralization rule for the unusual entry when the entry itself is defined.

Having a new qualifier to do that could be a problem, because then how do you use something like Ratio or Count for an entry that needs a special pluralization?

The simplest way to handle it that I can think of is to be able do something like this:

ENTRY drop of ##Liquid;:drops of ##Liquid;
RATIO 3:balloon of ##Liquid;:balloons of ##Liquid;
COUNT Liquid:bucket of ##Liquid;:buckets of ##Liquid;

If the extra colon isn't present in an entry normal pluralization would simply be used of course.

Re: pluralizing something within a group call but not at the

Posted: Mon Feb 04, 2013 pm28 12:15 pm
by Ryan
The problem with that as a solution is that it requires including non-entry data in an entry, and therefore use of an additional special character which might be used anyway in an entry (forcing people to escape all colons probably wouldn't be good for ease of use!) - and additionally, it would be making that change purely for cases where the given entry contains nothing but a single phrase to be pluralised, which simply isn't the case with many uses of entries in Regnus.

If new functionality were to be implemented into the language to cover this eventuality, it would be far more elegant and appropriate, I think, to extend the use of the MULTI qualifier to enable it to match phrases rather than just single words. This would require a slight change to the way that pluralisation characters are parsed, but would actually be relatively simple with some of the efficiency updates intended for parsers in the next specification.

Of course, this would still require that a MULTI qualifier is specified for each possibility. So, for the given example:

Code: Select all

GROUP Phrase
ENTRY <Phrase 1>I possess a cup containing several ##Sphere;.

GROUP Sphere
ENTRY marble
ENTRY crystal ball
ENTRY golf ball
ENTRY raindrop
ENTRY planetoid
ENTRY drop of ##Liquid;

GROUP Liquid
ENTRY water
ENTRY blood
ENTRY oil

MULTI drop of water:drops of water
MULTI drop of blood:drops of blood
MULTI drop of oil:drops of oil


The need to specify each case would, I'm afraid, be necessary unless some form of Regex parsing were to be implemented for MULTI qualifiers. However, for what I think is a relatively unusual case scenario, I think this would certainly be an acceptable approach for the next spec. I'll add it to the notes in the 5.4 thread. :)

Ryan