Lingua-EN-Inflexion
view release on metacpan or search on metacpan
lib/Lingua/EN/Inflexion.pm view on Meta::CPAN
or (even more hideously):
say inflect "<#:${\(@results)}> <N:matches> <V:were> retrieved";
you can just use:
say inflect "<#i:$#results> <N:matches> <V:were> retrieved";
I<Mnemonic:> C<i> for "increment" or "its intrinsic index is insufficient; increase it".
=item C<d>
Set the current count definition, without displaying anything in place
of the markup.
This is useful for constructions that either do not mention the count
explicitly:
say inflect "<#d:$count> <N:Match> found";
# "Match found" if $count == 1
# "Matches found" if $count > 1
or in constructions where the count has to appear I<after> something
whose inflexion it controls:
say inflect "There <#d:$count> <V:were> $count <N:matches>";
# "There was 1 match" if $count == 1
# "There were 7 matches" if $count > 1
The C<a>, C<n>, and C<c> options override C<d>, so you can still be
specific when the count is less than two:
say inflect "<#asd:$count> <N:matches> <V:were> found";
# "no match was found" if $count == 0
# "a match was found" if $count == 1
# "matches were found" if $count > 1
I<Mnemonic:> C<d> for "don't display" or "disguised definition" or "delete".
=back
=head3 C<< <N: I<contents> > >>
This markup inflects its contents as a noun. That is, the markup is
replaced with C<< noun('contents')->singular >> or
C<< noun('contents')->plural >> depending on the value specified
by the most recent preceding C<< <#:...> >> markup.
This command takes three options:
=over
=item C<c>
Cause the noun inflexion to use C<< noun('contents')->classical >>:
say inflect "<#:$count> <N:$target> found";
# "7 maximums found"
# "7 formulas found"
# "7 corpuses found"
# "7 brothers found"
say inflect "<#:$count> <Nc:$target> found";
# "7 maxima found"
# "7 formulae found"
# "7 corpora found"
# "7 brethren found"
I<Mnemonic:> C<c> for "classical" or "cultured" or "conformatio Caesaris cascus".
=item C<p>
Causes the noun to inflect to the plural, regardless of the currently
active count (i.e. regardless of the actual value specified in any
preceding C<< <#:...> >>.
This is sometimes useful for constructions such as:
say inflect "Searching for <Np:$target>.....found $count";
# "Searching for walruses...found 1"
# "Searching for appendixes...found 4"
# "Searching for denarii...found 12742"
I<Mnemonic:> C<p> for "plural" or "plentiful" or "plethora".
=item C<s>
Causes the noun to inflect to the singular, regardless of the currently
active count (i.e. regardless of the value in any preceding C<< <#:...> >>.
This is sometimes useful for constructions such as:
say inflect "Searching for <#a:> <Ns:$target>.....found $count";
# "Searching for a walrus...found 1"
# "Searching for an appendix...found 4"
# "Searching for a denarius...found 12742"
I<Mnemonic:> C<s> for "singular" or "solitary" or "solo".
=back
=head3 C<< <V: I<contents> > >>
This markup inflects its contents as a verb. That is, the markup is
replaced with C<< verb('contents')->singular >> or
C<< verb('contents')->plural >> depending on the value specified
by the most recent preceding C<< <#:...> >> markup.
This command has no options.
=head3 C<< <A: I<contents> > >>
This markup inflects its contents as an adjective. That is, the markup
is replaced with C<< adj('contents')->singular >> or
C<< adj('contents')->plural >> depending on the value specified by the
most recent preceding C<< <#:...> >> markup.
This command has no options.
=head3 Long-form markup notation
lib/Lingua/EN/Inflexion.pm view on Meta::CPAN
Yes, very few people use it (and almost only ever when raging against "octopi").
No, it isn't correct English...nor was it ever used in classical Latin.
Yes, there certainly I<is> a ancient Greek precedent for the inflexion.
No, that precedent isn't relevant to English, because "octopus" didn't come from ancient Greek either.
Yes, this module recognizes the word and will correctly inflect it back to "octopus" in the singular.
No, the module will never inflect "octopus" to "octopodes".
=head2 "octopuses"
For a thorough, erudite, and eminently satisfying explanation of why
it's only ever been "octopuses", I can sincerely recommend:
L<http://web.archive.org/web/20170112234148/http://www.heracliteanriver.com/?p=240>
=head2 "viri" and "virii"
The noun "virus" had no plural in its original Latin (probably because
it was a mass noun). So the only plural in English is the natural one:
"viruses".
Nevertheless, this module will do the right thing when asked to inflect
"viri" and "virii" back to the singular (unless you happen to think that
the right thing would be to beat them to death with a stick).
=head2 Singular "they", "them", "their", and "theirs"
...were good enough for Auden, Austen, Byron, Carroll, Caxton, Chaucer,
Defoe, Dickens, Eliot, Fitzgerald, Gaskell, Kipling, Orwell, Ruskin,
Scott, Shakespeare, Shaw, Shelley, Sheridan, Spenser, Stevenson, Swift,
Thackeray, Trollope, Wells, Wharton, and Wilde...so they're good enough
for this module.
In fact, it wasn't until the 19th Century that maniacal neo-Latinizing
prescriptive grammarians started pillorying the use of gender-neutral
singular "they" I<etc.> in English.
Meanwhile, real people have kept right on using it for the past two
hundred years, just as they did for the preceding five hundred.
And the OED now actually prefers "they" to "he" for gender-nonspecific
usages.
So if someone wants to complain about this module supporting--and
even favouring--the usage, I<they> are most welcome to write I<their>
own module as best suits I<them>.
=head2 Singular "themself"
Despite the fact that "themself" has been in use for nearly 500 years,
and actually predates "themselves", the word is not considered
acceptable in modern English, and certainly not as a singular form.
Eventually it may garner the same general acceptance as singular "they",
"them", and "their"...but not yet. Although one may encounter such
gender-nonspecific constructions as:
S< >"Anyone might find B<themself> contemplating their own mortality."
the correct formulation is still:
S< >"Anyone might find B<themselves> contemplating their own mortality."
The module does recognize "themself" as a reflexive pronoun, but
converts it to the currently accepted form ("themselves") for both
singular and plural inflexions.
=head2 "inflexion"
It's exactly the same thing as "inflection".
I simply find the classical spelling more elegant.
=head1 DIAGNOSTICS
=over
=item C<< Missing arg to %s >>
You passed an C<undef> as the single argument to C<noun()>, C<verb()>,
or C<adj()>. They require a string instead.
=item C<< Can't coerce %s object to %s reference >>
Inflexion objects can convert themselves to strings, or numbers, or booleans,
or regexes, but not to references.
You didn't accidentally write something like:
$inflexion_obj->{plural} # Should be: $inflexion_obj->plural
...did you?
=back
=head1 CONFIGURATION AND ENVIRONMENT
Lingua::EN::Inflexion has no run-time configuration files or environment
variables.
However, the module itself is largely created from two tables of
inflexions (for nouns and verbs respectively).
=head2 The F<nouns.lei> file
All the noun inflexions that Lingua::EN::Inflexion provides are
generated from a single file: F<nouns.lei>.
=head3 File format
The format of each entry in this file is as follows:
SINGULAR NOUN => MODERN PLURAL FORM | CLASSICAL FORM
Either the modern plural or the classical plural--but not
both--may be omitted. If the classical plural is omitted,
( run in 2.702 seconds using v1.01-cache-2.11-cpan-302cb4679cc )