Lingua:...::Phrase(3)
π Lingua::EN::Inflect::Phrase(3) β the perl manpage, but make it cute π
okay so bestie, this is the Lingua:...::Phrase(3) page from the User Contributed Perl Documentation β yes the header is literally abbreviated like that, don't come for me β and it's all about making short English phrases go singular β plural. it's giving grammar fairy godmother and honestly? we're obsessed. π§β¨
πΈ NAME πΈ
Lingua::EN::Inflect::Phrase β Inflect short English Phrases. that's it, that's the whole vibe. π
π¦ SYNOPSIS π¦
here's the whole thing in action, copied exactly so you can steal it:
use Lingua::EN::Inflect::Phrase;
use Test::More tests => 2;
my $plural = Lingua::EN::Inflect::Phrase::to_PL('green egg and ham');
is $plural, 'green eggs and ham';
my $singular = Lingua::EN::Inflect::Phrase::to_S('green eggs and ham');
is $singular, 'green egg and ham';
like, green egg and ham becomes green eggs and ham and back again. iconic behavior. π₯π
β¨ DESCRIPTION β¨
so what does it do? it Attempts to pluralize or singularize short English phrases. short phrases. keep it short, bestie, don't be sending it a whole novel. π
the tea: Does not throw exceptions at present β if you try to pluralize something that's already plural, it just leaves it unchanged (and vice versa). no drama, no errors, it simply moves on with its life. π
now, a little honesty hour: The behavior of this module is subject to change as I tweak the heuristics, as some things get fixed others might regress. The processing of natural language is a messy business. fr fr β English is a chaos gremlin and heuristics are just vibes with a compiler. some things get fixed, other things regress, it's a whole thing. π
and If it doesn't work, please email or submit to RT the example you tried, and I'll try to fix it. so if it fumbles, send the example in! the author will try to fix it. π«Ά
π OPTIONS π
okay this part is lowkey important so pay attention. By default, this module prefers to treat words as nouns β because sometimes a word could be a verb or a noun and there's zero context to tell (rude of English tbh). this default is better for things such as database table/column names, which is what this module is primarily for. so if you're naming your tables, you're in the right place. π
this behavior can be switched with the variable $prefer_nouns. The default is 1. (yes, one. noun mode: on. main character energy.)
for example (verbatim, because the details matter):
{
local $Lingua::EN::Inflect::Phrase::prefer_nouns = 0;
is Lingua::EN::Inflect::Phrase::to_S('sources split'), 'source splits';
}
{
local $Lingua::EN::Inflect::Phrase::prefer_nouns = 1;
is Lingua::EN::Inflect::Phrase::to_S('source splits'), 'source split';
}
see how the same input flips depending on the flag? that's the whole point. π¦
π OPTIONAL EXPORTS π
to_PL, to_S β those two, if you want them. π
π SUBROUTINES π
to_PL β
Attempts to pluralizes a phrase unless already plural. (yes the original says "pluralizes", we're keeping it, it's part of the charm.) one β many, but only if it isn't already many. π«
to_S β
Attempts to singularize a phrase unless already singular. many β one, but only if it isn't already one. π
π BUGS π
got beef? Please report any bugs or feature requests to bug-lingua-en-inflect-phrase at rt.cpan.org, or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Lingua-EN-Inflect-Phrase>.
and here's the cute part: I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. you literally get updates. it's a whole subscription service but for your bug report. π₯
π§ REPOSITORY π§
clone it, bestie:
git clone git://github.com/rkitover/lingua-en-inflect-phrase.git lingua-en-inflect-phrase
πΈ SEE ALSO πΈ
go check out these icons too:
Lingua::EN::InflectLingua::EN::Inflect::NumberLingua::EN::Tagger
π AUTHOR π
rkitover: Rafael Kitover <rkitover@cpan.org> π
π«Ά CONTRIBUTORS π«Ά
zakame: Zak B. Elep <zakame@zakame.net> π
π LICENSE AND COPYRIGHT π
Copyright (c) 2018 Rafael Kitover (rkitover@cpan.org).
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
okay that's the whole page, no notes. π
sign-off szn π β this little beauty is documented as perl v5.42.0, dated 2018-02-27, and it lives at the top of the page as Lingua:...::Phrase(3) (the abbreviated little legend). mwah. πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: perl-Lingua-EN-Inflect-Phrase 0.20-bp160.1.11 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms