1Lingua::EN::PluralToSinUgsuelrarC(o3n)tributed Perl DocuLmienngtuaat:i:oEnN::PluralToSingular(3)
2
3
4
6 Lingua::EN::PluralToSingular - change an English plural to a singular
7
9 use Lingua::EN::PluralToSingular qw/to_singular is_plural/;
10 my @words = qw/knives sheep dog dogs cannabis/;
11 for my $word (@words) {
12 if (is_plural ($word)) {
13 my $sing = to_singular ($word);
14 print "The singular of '$word' is '$sing'.\n";
15 }
16 else {
17 print "'", ucfirst ($word), "' is not plural.\n";
18 }
19 }
20
21 produces output
22
23 The singular of 'knives' is 'knife'.
24 The singular of 'sheep' is 'sheep'.
25 'Dog' is not plural.
26 The singular of 'dogs' is 'dog'.
27 'Cannabis' is not plural.
28
29 (This example is included as synopsis.pl
30 <https://fastapi.metacpan.org/source/BKB/JSON-
31 Parse-0.21/examples/synopsis.pl> in the distribution.)
32
34 This documents Lingua::EN::PluralToSingular version 0.21 corresponding
35 to git commit 2d53254eeaec8d2006655f63f61b4f6868e81153
36 <https://github.com/benkasminbullock/Lingua-EN-
37 PluralToSingular/commit/2d53254eeaec8d2006655f63f61b4f6868e81153>
38 released on Thu Jun 21 17:48:56 2018 +0900.
39
41 This converts words denoting a plural in the English language into
42 words denoting a singular noun.
43
45 to_singular
46 my $singular = to_singular ($word);
47
48 Convert $word into its singular form. For example,
49
50 to_singular ('cats')
51
52 returns 'cat'. If the word is unknown or does not seem to be plural,
53 "to_singular" returns the word itself, so
54
55 to_singular ('battlehorn');
56
57 returns 'battlehorn'.
58
59 is_plural
60 if (is_plural ($word)) {
61 print "There are too many $word here.\n";
62 }
63 else {
64 print "There is a $word here.\n";
65 }
66
67 Returns 1 if the word is a valid plural, 0 if not. It also returns 1
68 for ambiguous words like "sheep".
69
71 Assumes the input is a noun
72 "to_singular" assumes its input is a noun. For example, "lives" may be
73 the plural of "life", or the verb "live", as in "he lives". The routine
74 assumes a noun and converts to "life".
75
76 Distinguishes lower and upper case
77 It does not deal with capitalized words. If the input word may be
78 capitalized, or if its initial letter may be capitalized, the user must
79 preprocess it to put it into the normal case. So, for example,
80
81 to_singular ('FLIES');
82
83 returns 'FLIES' and
84
85 to_singular ('Wolves');
86
87 returns 'Wolve'. Similarly,
88
89 to_singular ('Charles');
90
91 returns 'Charles', but
92
93 to_singular ('charles');
94
95 returns 'charle', since the exception only applies if the word is
96 capitalized.
97
98 Does not handle pronouns
99 The module does not attempt to handle pronoun forms like "ourselves" or
100 "themselves". These words are left unaltered.
101
102 False plurals also accepted
103 For the sake of user convenience, false plurals like "octopi" are also
104 accepted by the module. (The plural of "octopus" is "octopuses".)
105
106 Not all exceptional plurals are included
107 There are many exceptions which have not been included, notably words
108 with Latin or Greek plurals.
109
111 The script scripts/singular provides a quick way to get singular
112 versions of nouns:
113
114 singular cats dogs geese
115 # Prints "cat dog goose".
116
118 Lingua::EN::Inflect
119 Lingua::EN::Inflect by Damian Conway converts English singular
120 nouns to plurals, but not vice-versa.
121
122 Lingua::EN::Inflect::Number
123 Lingua::EN::Inflect::Number is supposed to do the same thing as
124 this module. However, as of the time of writing (version 1.12) it's
125 actually based on the third-person verb handling of
126 Lingua::EN::Inflect, in other words it takes a verb in the "he
127 says" form and converts it into "say". Thus you get bugs like
128 <https://rt.cpan.org/Public/Bug/Display.html?id=64564> where the
129 reporter demonstrates that 'to_S incorrectly renders the singular
130 of "statuses" as "statuse."'
131
133 Thanks to Xan Charbonnet and H2CHANG for various additions and fixes.
134 Lisa Hare contributed support for plurals ending in i as part of the
135 2016 Pull Request Challenge.
136
138 Ben Bullock, <bkb@cpan.org>
139
141 This package and associated files are copyright (C) 2011-2018 Ben
142 Bullock.
143
144 You can use, copy, modify and redistribute this package and associated
145 files under the Perl Artistic Licence or the GNU General Public
146 Licence.
147
148
149
150perl v5.38.0 2023-07-20 Lingua::EN::PluralToSingular(3)