|
NAMELingua::EN::PluralToSingular - change an English plural to a singularSYNOPSISuse Lingua::EN::PluralToSingular qw/to_singular is_plural/; my @words = qw/knives sheep dog dogs cannabis/; for my $word (@words) { if (is_plural ($word)) { my $sing = to_singular ($word); print "The singular of '$word' is '$sing'.\n"; } else { print "'", ucfirst ($word), "' is not plural.\n"; } } produces output The singular of 'knives' is 'knife'. The singular of 'sheep' is 'sheep'. 'Dog' is not plural. The singular of 'dogs' is 'dog'. 'Cannabis' is not plural. (This example is included as synopsis.pl <https://fastapi.metacpan.org/source/BKB/JSON-Parse-0.21/examples/synopsis.pl> in the distribution.) VERSIONThis documents Lingua::EN::PluralToSingular version 0.21 corresponding to git commit 2d53254eeaec8d2006655f63f61b4f6868e81153 <https://github.com/benkasminbullock/Lingua-EN-PluralToSingular/commit/2d53254eeaec8d2006655f63f61b4f6868e81153> released on Thu Jun 21 17:48:56 2018 +0900.DESCRIPTIONThis converts words denoting a plural in the English language into words denoting a singular noun.FUNCTIONSto_singularmy $singular = to_singular ($word); Convert $word into its singular form. For example, to_singular ('cats') returns 'cat'. If the word is unknown or does not seem to be plural, "to_singular" returns the word itself, so to_singular ('battlehorn'); returns 'battlehorn'. is_pluralif (is_plural ($word)) { print "There are too many $word here.\n"; } else { print "There is a $word here.\n"; } Returns 1 if the word is a valid plural, 0 if not. It also returns 1 for ambiguous words like "sheep". LIMITATIONS AND CAVEATSAssumes the input is a noun"to_singular" assumes its input is a noun. For example, "lives" may be the plural of "life", or the verb "live", as in "he lives". The routine assumes a noun and converts to "life".Distinguishes lower and upper caseIt does not deal with capitalized words. If the input word may be capitalized, or if its initial letter may be capitalized, the user must preprocess it to put it into the normal case. So, for example,to_singular ('FLIES'); returns 'FLIES' and to_singular ('Wolves'); returns 'Wolve'. Similarly, to_singular ('Charles'); returns 'Charles', but to_singular ('charles'); returns 'charle', since the exception only applies if the word is capitalized. Does not handle pronounsThe module does not attempt to handle pronoun forms like "ourselves" or "themselves". These words are left unaltered.False plurals also acceptedFor the sake of user convenience, false plurals like "octopi" are also accepted by the module. (The plural of "octopus" is "octopuses".)Not all exceptional plurals are includedThere are many exceptions which have not been included, notably words with Latin or Greek plurals.STANDALONE SCRIPTThe script scripts/singular provides a quick way to get singular versions of nouns:singular cats dogs geese # Prints "cat dog goose". SEE ALSO
ACKNOWLEDGEMENTSThanks to Xan Charbonnet and H2CHANG for various additions and fixes. Lisa Hare contributed support for plurals ending in i as part of the 2016 Pull Request Challenge.AUTHORBen Bullock, <bkb@cpan.org>COPYRIGHT & LICENCEThis package and associated files are copyright (C) 2011-2018 Ben Bullock.You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.
Visit the GSP FreeBSD Man Page Interface. |