|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Erykai\Pluralize; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* Pluralize text language en |
|
7
|
|
|
*/ |
|
8
|
|
|
trait TraitPluralize |
|
9
|
|
|
{ |
|
10
|
|
|
/** |
|
11
|
|
|
* @var array|string[] |
|
12
|
|
|
*/ |
|
13
|
|
|
private array $ruleUncountable = [ |
|
14
|
|
|
'adulthood', |
|
15
|
|
|
'advice', |
|
16
|
|
|
'agenda', |
|
17
|
|
|
'aid', |
|
18
|
|
|
'aircraft', |
|
19
|
|
|
'alcohol', |
|
20
|
|
|
'ammo', |
|
21
|
|
|
'analytics', |
|
22
|
|
|
'anime', |
|
23
|
|
|
'athletics', |
|
24
|
|
|
'audio', |
|
25
|
|
|
'bison', |
|
26
|
|
|
'blood', |
|
27
|
|
|
'bream', |
|
28
|
|
|
'buffalo', |
|
29
|
|
|
'butter', |
|
30
|
|
|
'carp', |
|
31
|
|
|
'cash', |
|
32
|
|
|
'chassis', |
|
33
|
|
|
'chess', |
|
34
|
|
|
'clothing', |
|
35
|
|
|
'cod', |
|
36
|
|
|
'commerce', |
|
37
|
|
|
'cooperation', |
|
38
|
|
|
'corps', |
|
39
|
|
|
'debris', |
|
40
|
|
|
'diabetes', |
|
41
|
|
|
'digestion', |
|
42
|
|
|
'elk', |
|
43
|
|
|
'energy', |
|
44
|
|
|
'equipment', |
|
45
|
|
|
'excretion', |
|
46
|
|
|
'expertise', |
|
47
|
|
|
'firmware', |
|
48
|
|
|
'flounder', |
|
49
|
|
|
'fun', |
|
50
|
|
|
'gallows', |
|
51
|
|
|
'garbage', |
|
52
|
|
|
'graffiti', |
|
53
|
|
|
'hardware', |
|
54
|
|
|
'headquarters', |
|
55
|
|
|
'health', |
|
56
|
|
|
'herpes', |
|
57
|
|
|
'highjinks', |
|
58
|
|
|
'homework', |
|
59
|
|
|
'housework', |
|
60
|
|
|
'information', |
|
61
|
|
|
'jeans', |
|
62
|
|
|
'justice', |
|
63
|
|
|
'kudos', |
|
64
|
|
|
'labour', |
|
65
|
|
|
'literature', |
|
66
|
|
|
'machinery', |
|
67
|
|
|
'mackerel', |
|
68
|
|
|
'mail', |
|
69
|
|
|
'media', |
|
70
|
|
|
'mews', |
|
71
|
|
|
'money', |
|
72
|
|
|
'moose', |
|
73
|
|
|
'music', |
|
74
|
|
|
'mud', |
|
75
|
|
|
'manga', |
|
76
|
|
|
'news', |
|
77
|
|
|
'only', |
|
78
|
|
|
'personnel', |
|
79
|
|
|
'pike', |
|
80
|
|
|
'plankton', |
|
81
|
|
|
'pliers', |
|
82
|
|
|
'police', |
|
83
|
|
|
'pollution', |
|
84
|
|
|
'premises', |
|
85
|
|
|
'rain', |
|
86
|
|
|
'research', |
|
87
|
|
|
'rice', |
|
88
|
|
|
'salmon', |
|
89
|
|
|
'scissors', |
|
90
|
|
|
'series', |
|
91
|
|
|
'sewage', |
|
92
|
|
|
'shambles', |
|
93
|
|
|
'shrimp', |
|
94
|
|
|
'software', |
|
95
|
|
|
'species', |
|
96
|
|
|
'staff', |
|
97
|
|
|
'swine', |
|
98
|
|
|
'tennis', |
|
99
|
|
|
'thanks', |
|
100
|
|
|
'traffic', |
|
101
|
|
|
'transportation', |
|
102
|
|
|
'trout', |
|
103
|
|
|
'tuna', |
|
104
|
|
|
'wealth', |
|
105
|
|
|
'welfare', |
|
106
|
|
|
'whiting', |
|
107
|
|
|
'wildebeest', |
|
108
|
|
|
'wildlife', |
|
109
|
|
|
'you', |
|
110
|
|
|
'/pok[eé]mon$/i', |
|
111
|
|
|
'/[^aeiou]ese$/i', |
|
112
|
|
|
'/deer$/i', |
|
113
|
|
|
'/fish$/i', |
|
114
|
|
|
'/measles$/i', |
|
115
|
|
|
'/o[iu]s$/i', |
|
116
|
|
|
'/pox$/i', |
|
117
|
|
|
'/sheep$/i' |
|
118
|
|
|
]; |
|
119
|
|
|
/** |
|
120
|
|
|
* @var array|string[] |
|
121
|
|
|
*/ |
|
122
|
|
|
private array $ruleIrregular = [ |
|
123
|
|
|
'move' => 'moves', |
|
124
|
|
|
'sex' => 'sexes', |
|
125
|
|
|
'child' => 'children', |
|
126
|
|
|
'man' => 'men', |
|
127
|
|
|
'person' => 'people', |
|
128
|
|
|
'I' => 'we', |
|
129
|
|
|
'me' => 'us', |
|
130
|
|
|
'he' => 'they', |
|
131
|
|
|
'she' => 'they', |
|
132
|
|
|
'them' => 'them', |
|
133
|
|
|
'myself' => 'ourselves', |
|
134
|
|
|
'yourself' => 'yourselves', |
|
135
|
|
|
'itself' => 'themselves', |
|
136
|
|
|
'herself' => 'themselves', |
|
137
|
|
|
'himself' => 'themselves', |
|
138
|
|
|
'themself' => 'themselves', |
|
139
|
|
|
'is' => 'are', |
|
140
|
|
|
'was' => 'were', |
|
141
|
|
|
'has' => 'have', |
|
142
|
|
|
'this' => 'these', |
|
143
|
|
|
'that' => 'those', |
|
144
|
|
|
'echo' => 'echoes', |
|
145
|
|
|
'dingo' => 'dingoes', |
|
146
|
|
|
'volcano' => 'volcanoes', |
|
147
|
|
|
'tornado' => 'tornadoes', |
|
148
|
|
|
'torpedo' => 'torpedoes', |
|
149
|
|
|
'genus' => 'genera', |
|
150
|
|
|
'viscus' => 'viscera', |
|
151
|
|
|
'stigma' => 'stigmata', |
|
152
|
|
|
'stoma' => 'stomata', |
|
153
|
|
|
'dogma' => 'dogmata', |
|
154
|
|
|
'lemma' => 'lemmata', |
|
155
|
|
|
'schema' => 'schemata', |
|
156
|
|
|
'anathema' => 'anathemata', |
|
157
|
|
|
'ox' => 'oxen', |
|
158
|
|
|
'axe' => 'axes', |
|
159
|
|
|
'die' => 'dice', |
|
160
|
|
|
'yes' => 'yeses', |
|
161
|
|
|
'foot' => 'feet', |
|
162
|
|
|
'eave' => 'eaves', |
|
163
|
|
|
'goose' => 'geese', |
|
164
|
|
|
'tooth' => 'teeth', |
|
165
|
|
|
'quiz' => 'quizzes', |
|
166
|
|
|
'human' => 'humans', |
|
167
|
|
|
'proof' => 'proofs', |
|
168
|
|
|
'carve' => 'carves', |
|
169
|
|
|
'valve' => 'valves', |
|
170
|
|
|
'looey' => 'looies', |
|
171
|
|
|
'thief' => 'thieves', |
|
172
|
|
|
'groove' => 'grooves', |
|
173
|
|
|
'pickaxe' => 'pickaxes', |
|
174
|
|
|
'passerby' => 'passersby', |
|
175
|
|
|
'cookie' => 'cookies' |
|
176
|
|
|
]; |
|
177
|
|
|
/** |
|
178
|
|
|
* @var array|string[] |
|
179
|
|
|
*/ |
|
180
|
|
|
private array $rulePlural = [ |
|
181
|
|
|
'/(quiz)$/i' => "$1zes", |
|
182
|
|
|
'/^(ox)$/i' => "$1en", |
|
183
|
|
|
'/([m|l])ouse$/i' => "$1ice", |
|
184
|
|
|
'/(matr|vert|ind)ix|ex$/i' => "$1ices", |
|
185
|
|
|
'/(x|ch|ss|sh)$/i' => "$1es", |
|
186
|
|
|
'/([^aeiouy]|qu)y$/i' => "$1ies", |
|
187
|
|
|
'/(hive)$/i' => "$1s", |
|
188
|
|
|
'/(?:([^f])fe|([lr])f)$/i' => "$1$2ves", |
|
189
|
|
|
'/(shea|lea|loa|thie)f$/i' => "$1ves", |
|
190
|
|
|
'/sis$/i' => "ses", |
|
191
|
|
|
'/([ti])um$/i' => "$1a", |
|
192
|
|
|
'/(tomat|potat|ech|her|vet)o$/i' => "$1oes", |
|
193
|
|
|
'/(bu)s$/i' => "$1ses", |
|
194
|
|
|
'/(alias)$/i' => "$1es", |
|
195
|
|
|
'/(octop)us$/i' => "$1i", |
|
196
|
|
|
'/(ax|test)is$/i' => "$1es", |
|
197
|
|
|
'/(us)$/i' => "$1es", |
|
198
|
|
|
'/s$/i' => "s", |
|
199
|
|
|
'/$/' => "s" |
|
200
|
|
|
]; |
|
201
|
|
|
/** |
|
202
|
|
|
* @var array|string[] |
|
203
|
|
|
*/ |
|
204
|
|
|
private array $ruleSingular = [ |
|
205
|
|
|
'/(quiz)zes$/i' => "$1", |
|
206
|
|
|
'/(matr)ices$/i' => "$1ix", |
|
207
|
|
|
'/(vert|ind)ices$/i' => "$1ex", |
|
208
|
|
|
'/^(ox)en$/i' => "$1", |
|
209
|
|
|
'/(alias)es$/i' => "$1", |
|
210
|
|
|
'/(octop|vir)i$/i' => "$1us", |
|
211
|
|
|
'/(cris|ax|test)es$/i' => "$1is", |
|
212
|
|
|
'/(shoe)s$/i' => "$1", |
|
213
|
|
|
'/(o)es$/i' => "$1", |
|
214
|
|
|
'/(bus)es$/i' => "$1", |
|
215
|
|
|
'/([m|l])ice$/i' => "$1ouse", |
|
216
|
|
|
'/(x|ch|ss|sh)es$/i' => "$1", |
|
217
|
|
|
'/(m)ovies$/i' => "$1ovie", |
|
218
|
|
|
'/(s)eries$/i' => "$1eries", |
|
219
|
|
|
'/([^aeiouy]|qu)ies$/i' => "$1y", |
|
220
|
|
|
'/([lr])ves$/i' => "$1f", |
|
221
|
|
|
'/(tive)s$/i' => "$1", |
|
222
|
|
|
'/(hive)s$/i' => "$1", |
|
223
|
|
|
'/(li|wi|kni)ves$/i' => "$1fe", |
|
224
|
|
|
'/(shea|loa|lea|thie)ves$/i' => "$1f", |
|
225
|
|
|
'/(^analy)ses$/i' => "$1sis", |
|
226
|
|
|
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis", |
|
227
|
|
|
'/([ti])a$/i' => "$1um", |
|
228
|
|
|
'/(n)ews$/i' => "$1ews", |
|
229
|
|
|
'/(h|bl)ouses$/i' => "$1ouse", |
|
230
|
|
|
'/(corpse)s$/i' => "$1", |
|
231
|
|
|
'/(us)es$/i' => "$1", |
|
232
|
|
|
'/s$/i' => "" |
|
233
|
|
|
]; |
|
234
|
|
|
|
|
235
|
|
|
/** |
|
236
|
|
|
* @param string $string |
|
237
|
|
|
* @return bool |
|
238
|
|
|
*/ |
|
239
|
|
|
protected function uncountable(string $string): bool |
|
240
|
|
|
{ |
|
241
|
|
|
if (in_array(strtolower($string), $this->getUncountable(), true)) { |
|
|
|
|
|
|
242
|
|
|
return true; |
|
243
|
|
|
} |
|
244
|
|
|
return false; |
|
245
|
|
|
} |
|
246
|
|
|
|
|
247
|
|
|
/** |
|
248
|
|
|
* @return array |
|
249
|
|
|
*/ |
|
250
|
|
|
protected function ruleIrregular(): array |
|
251
|
|
|
{ |
|
252
|
|
|
return $this->ruleIrregular; |
|
253
|
|
|
} |
|
254
|
|
|
|
|
255
|
|
|
/** |
|
256
|
|
|
* @return array |
|
257
|
|
|
*/ |
|
258
|
|
|
protected function rulePlural(): array |
|
259
|
|
|
{ |
|
260
|
|
|
return $this->rulePlural; |
|
261
|
|
|
} |
|
262
|
|
|
|
|
263
|
|
|
/** |
|
264
|
|
|
* @return array |
|
265
|
|
|
*/ |
|
266
|
|
|
protected function ruleSingular(): array |
|
267
|
|
|
{ |
|
268
|
|
|
return $this->ruleSingular; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
/** |
|
272
|
|
|
* @return array |
|
273
|
|
|
*/ |
|
274
|
|
|
protected function ruleUncountable(): array |
|
275
|
|
|
{ |
|
276
|
|
|
return $this->ruleUncountable; |
|
277
|
|
|
} |
|
278
|
|
|
} |