This file is indexed.

/usr/share/perl5/Lingua/EN/Inflect.pm is in liblingua-en-inflect-perl 1.901-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 243
 244
 245
 246
 247
 248
 249
 250
 251
 252
 253
 254
 255
 256
 257
 258
 259
 260
 261
 262
 263
 264
 265
 266
 267
 268
 269
 270
 271
 272
 273
 274
 275
 276
 277
 278
 279
 280
 281
 282
 283
 284
 285
 286
 287
 288
 289
 290
 291
 292
 293
 294
 295
 296
 297
 298
 299
 300
 301
 302
 303
 304
 305
 306
 307
 308
 309
 310
 311
 312
 313
 314
 315
 316
 317
 318
 319
 320
 321
 322
 323
 324
 325
 326
 327
 328
 329
 330
 331
 332
 333
 334
 335
 336
 337
 338
 339
 340
 341
 342
 343
 344
 345
 346
 347
 348
 349
 350
 351
 352
 353
 354
 355
 356
 357
 358
 359
 360
 361
 362
 363
 364
 365
 366
 367
 368
 369
 370
 371
 372
 373
 374
 375
 376
 377
 378
 379
 380
 381
 382
 383
 384
 385
 386
 387
 388
 389
 390
 391
 392
 393
 394
 395
 396
 397
 398
 399
 400
 401
 402
 403
 404
 405
 406
 407
 408
 409
 410
 411
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
package Lingua::EN::Inflect;

use strict;
use vars qw($VERSION @EXPORT_OK %EXPORT_TAGS @ISA);
use Env;

require Exporter;
@ISA = qw(Exporter);

our $VERSION = '1.901';

%EXPORT_TAGS =
(
    ALL =>      [ qw( classical inflect
                  PL PL_N PL_V PL_ADJ NO NUM A AN
                  PL_eq PL_N_eq PL_V_eq PL_ADJ_eq
                  PART_PRES
                  ORD
                  NUMWORDS
                  WORDLIST
                  def_noun def_verb def_adj def_a def_an )],

    INFLECTIONS =>  [ qw( classical inflect
                  PL PL_N PL_V PL_ADJ PL_eq
                  NO NUM A AN PART_PRES )],

    PLURALS =>  [ qw( classical inflect
                  PL PL_N PL_V PL_ADJ NO NUM
                  PL_eq PL_N_eq PL_V_eq PL_ADJ_eq )],

    COMPARISONS =>  [ qw( classical
                  PL_eq PL_N_eq PL_V_eq PL_ADJ_eq )],

    ARTICLES => [ qw( classical inflect NUM A AN )],

    NUMERICAL =>    [ qw( ORD NUMWORDS )],

    USER_DEFINED => [ qw( def_noun def_verb def_adj def_a def_an )],
);

Exporter::export_ok_tags(qw( ALL ));

# SUPPORT CLASSICAL PLURALIZATIONS

my %def_classical = (
    all      => 0,
    zero     => 0,
    herd     => 0,
    names    => 1,
    persons  => 0,
    ancient  => 0,
);

my %all_classical = (
    all               => 1,
    zero              => 1,
    herd              => 1,
    names             => 1,
    persons           => 1,
    ancient           => 1,
    noble_and_ancient => 10,
);

my %classical = %def_classical;

my $classical_mode = join '|', keys %all_classical;
   $classical_mode = qr/^(?:$classical_mode)$/;

sub classical
{
    if (!@_) {
        %classical = %all_classical;
        return;
    }
    if (@_==1 && $_[0] !~ $classical_mode) {
        %classical = $_[0] ? %all_classical : ();
        return;
    }
    while (@_) {
        my $arg = shift;
        if ($arg !~ $classical_mode) {
            die "Unknown classical mode ($arg)\n";
        }
        if (@_ && $_[0] !~ $classical_mode) { $classical{$arg} = shift; }
        else                                { $classical{$arg} = 1;     }

        if ($arg eq 'all') {
            %classical = $classical{all} ? %all_classical : ();
        }
    }
}

my $persistent_count;

sub NUM     # (;$count,$show)
{
    if (defined $_[0])
    {
        $persistent_count = $_[0];
        return $_[0] if !defined($_[1]) || $_[1];
    }
    else
    {
        $persistent_count = undef;
    }
    return '';
}


# 0. PERFORM GENERAL INFLECTIONS IN A STRING

sub enclose { "(?:$_[0])" }

sub inflect
{
    my $save_persistent_count = $persistent_count;
    my @sections = split /(NUM\([^)]*\))/, $_[0];
    my $inflection = "";

    foreach ( @sections )
    {
        unless (s/NUM\(\s*?(?:([^),]*)(?:,([^)]*))?)?\)/ NUM($1,$2) /xe)
        {
            1 while
               s/\bPL   \( ([^),]*) (, ([^)]*) )? \)  / PL($1,$3)   /xeg
            || s/\bPL_N \( ([^),]*) (, ([^)]*) )? \)  / PL_N($1,$3) /xeg
            || s/\bPL_V \( ([^),]*) (, ([^)]*) )? \)  / PL_V($1,$3) /xeg
            || s/\bPL_ADJ \( ([^),]*) (, ([^)]*) )? \)  / PL_ADJ($1,$3) /xeg
            || s/\bAN?  \( ([^),]*) (, ([^)]*) )? \)  / A($1,$3)    /xeg
            || s/\bNO   \( ([^),]*) (, ([^)]*) )? \)  / NO($1,$3)   /xeg
            || s/\bORD  \( ([^)]*) \)                 / ORD($1)   /xeg
            || s/\bNUMWORDS  \( ([^)]*) \)            / NUMWORDS($1)   /xeg
            || s/\bPART_PRES  \( ([^)]*) \)            / PART_PRES($1)   /xeg
        }

        $inflection .= $_;
    }

    $persistent_count = $save_persistent_count;
    return $inflection;
}


# 1. PLURALS

my %PL_sb_irregular_s =
(
    "corpus"          => "corpuses|corpora",
    "opus"            => "opuses|opera",
    "magnum opus"     => "magnum opuses|magna opera",
    "genus"           => "genera",
    "mythos"          => "mythoi",
    "penis"           => "penises|penes",
    "testis"          => "testes",
    "atlas"           => "atlases|atlantes",
    "yes"             => "yeses",
    'editio princeps' => 'editiones principes',
    'starets'         => 'startsy',
    'staretz'         => 'startzy',
);

my %PL_sb_irregular =
(
    "child"       => "children",
    "brother"     => "brothers|brethren",
    "loaf"        => "loaves",
    "hoof"        => "hoofs|hooves",
    "beef"        => "beefs|beeves",
    "thief"       => "thiefs|thieves",
    "money"       => "monies",
    "mongoose"    => "mongooses",
    "ox"          => "oxen",
    "cow"         => "cows|kine",
    "graffito"    => "graffiti",
    "prima donna" => "prima donnas|prime donne",
    "octopus"     => "octopuses|octopodes",
    "genie"       => "genies|genii",
    "ganglion"    => "ganglions|ganglia",
    "trilby"      => "trilbys",
    "turf"        => "turfs|turves",
    "numen"       => "numina",
    "atman"       => "atmas",
    "occiput"     => "occiputs|occipita",
    'sabretooth'  => 'sabretooths',
    'sabertooth'  => 'sabertooths',
    'lowlife'     => 'lowlifes',
    'flatfoot'    => 'flatfoots',
    'tenderfoot'  => 'tenderfoots',
    'Romany'      => 'Romanies',
    'romany'      => 'romanies',
    'Tornese'     => 'Tornesi',
    'Jerry'       => 'Jerrys',
    'jerry'       => 'jerries',
    'Mary'        => 'Marys',
    'mary'        => 'maries',
    'talouse'     => 'talouses',
    'blouse'      => 'blouses',
    'Rom'         => 'Roma',
    'rom'         => 'roma',
    'carmen'      => 'carmina',
    'cheval'      => 'chevaux',
    'chervonetz'  => 'chervontzi',
    'kuvasz'      => 'kuvaszok',
    'felo'        => 'felones',
    'put-off'     => 'put-offs',
    'set-off'     => 'set-offs',
    'set-out'     => 'set-outs',
    'set-to'      => 'set-tos',
    'brother-german' => 'brothers-german|brethren-german',
    'studium generale' => 'studia generali',

    %PL_sb_irregular_s,
);

my $PL_sb_irregular = enclose join '|', reverse sort keys %PL_sb_irregular;

# Z's that don't double

my @PL_sb_z_zes =
(
    "batz", "quartz", "topaz", "snooz(?=e)", "kibbutz",
);
my $PL_sb_z_zes = enclose join '|', @PL_sb_z_zes;

# UNCONDITIONAL "..is" -> "..ides"

my @PL_sb_U_is_ides =
(
    "aphis",
);

my $PL_sb_U_is_ides = enclose join "|", map { substr($_,0,-2) } @PL_sb_U_is_ides;

# CLASSICAL "..is" -> "..ides"

my @PL_sb_C_is_ides =
(
# GENERAL WORDS...

    "ephemeris", "iris", "clitoris",
    "chrysalis", "epididymis",

# INFLAMATIONS...

    ".*itis",

);

my $PL_sb_C_is_ides = enclose join "|", map { substr($_,0,-2) } @PL_sb_C_is_ides;

# UNCONDITIONAL "..a" -> "..ata"

my @PL_sb_U_a_ata =
(
    "plasmalemma", "pseudostoma",
);

my $PL_sb_U_a_ata = enclose join "|", map { substr($_,0,-1) } @PL_sb_U_a_ata;

# CLASSICAL "..a" -> "..ata"

my @PL_sb_C_a_ata =
(
    "anathema", "bema", "carcinoma", "charisma", "diploma",
    "dogma", "drama", "edema", "enema", "enigma", "lemma",
    "lymphoma", "magma", "melisma", "miasma", "oedema",
    "sarcoma", "schema", "soma", "stigma", "stoma", "trauma",
    "gumma", "pragma", "bema",
);

my $PL_sb_C_a_ata = enclose join "|", map { substr($_,0,-1) } @PL_sb_C_a_ata;

# UNCONDITIONAL "..a" -> "..ae"

my $PL_sb_U_a_ae = enclose join "|",
(
    "alumna", "alga", "vertebra", "persona"
);

# CLASSICAL "..a" -> "..ae"

my $PL_sb_C_a_ae = enclose join "|",
(
    "amoeba", "antenna", "formula", "hyperbola",
    "medusa", "nebula", "parabola", "abscissa",
    "hydra", "nova", "lacuna", "aurora", ".*umbra",
    "flora", "fauna",
);

# CLASSICAL "..en" -> "..ina"

my $PL_sb_C_en_ina = enclose join "|", map { substr($_,0,-2) }
(
    "stamen", "foramen", "lumen"
);

# UNCONDITIONAL "..um" -> "..a"

my $PL_sb_U_um_a = enclose join "|", map { substr($_,0,-2) }
(
    "bacterium",    "agendum",  "desideratum",  "erratum",
    "stratum",  "datum",    "ovum",     "extremum",
    "candelabrum", "intermedium", "malum", "Progymnasium",
);

# CLASSICAL "..um" -> "..a"

my $PL_sb_C_um_a = enclose join "|", map { substr($_,0,-2) }
(
    "maximum",  "minimum",    "momentum",   "optimum",
    "quantum",  "cranium",    "curriculum", "dictum",
    "phylum",   "aquarium",   "compendium", "emporium",
    "enconium", "gymnasium",  "honorarium", "interregnum",
    "lustrum",  "memorandum", "millennium", "rostrum",
    "spectrum", "speculum",   "stadium",    "trapezium",
    "ultimatum",    "medium",   "vacuum",   "velum",
    "consortium",
);

# UNCONDITIONAL "..us" -> "i"

my $PL_sb_U_us_i = enclose join "|", map { substr($_,0,-2) }
(
    "alumnus",  "alveolus", "bacillus", "bronchus",
    "locus",    "nucleus",  "stimulus", "meniscus",
    "sarcophagus", "interradius", "perradius", "triradius",
);

# CLASSICAL "..us" -> "..i"

my $PL_sb_C_us_i = enclose join "|", map { substr($_,0,-2) }
(
    "focus",    "radius",   "genius",
    "incubus",  "succubus", "nimbus",
    "fungus",   "nucleolus",    "stylus",
    "torus",    "umbilicus",    "uterus",
    "hippopotamus", "cactus",
);

# CLASSICAL "..us" -> "..us"  (ASSIMILATED 4TH DECLENSION LATIN NOUNS)

my $PL_sb_C_us_us = enclose join "|",
(
    "status", "apparatus", "prospectus", "sinus",
    "hiatus", "impetus", "plexus",
);

# UNCONDITIONAL "..on" -> "a"

my $PL_sb_U_on_a = enclose join "|", map { substr($_,0,-2) }
(
    "criterion",    "perihelion",   "aphelion",
    "phenomenon",   "prolegomenon", "noumenon",
    "organon",  "asyndeton",    "hyperbaton",
    "legomenon",
);

# CLASSICAL "..on" -> "..a"

my $PL_sb_C_on_a = enclose join "|", map { substr($_,0,-2) }
(
    "oxymoron",
);

# CLASSICAL "..o" -> "..i"  (BUT NORMALLY -> "..os")

my @PL_sb_C_o_i =
(
    "solo",     "soprano",  "basso",    "alto",
    "contralto",    "tempo",    "piano",    "virtuoso",
);
my $PL_sb_C_o_i = enclose join "|", map { substr($_,0,-1) } @PL_sb_C_o_i;

# ALWAYS "..o" -> "..os"

my $PL_sb_U_o_os = enclose join "|",
(
        "^ado",          "aficionado",   "aggro",
        "albino",       "allegro",      "ammo",
        "Antananarivo", "archipelago",  "armadillo",
        "auto",         "avocado",      "Bamako",
        "Barquisimeto", "bimbo",        "bingo",
        "Biro",         "bolero",       "Bolzano",
        "bongo",        "Boto",         "burro",
        "Cairo",        "canto",        "cappuccino",
        "casino",       "cello",        "Chicago",
        "Chimango",     "cilantro",     "cochito",
        "coco",         "Colombo",      "Colorado",
        "commando",     "concertino",   "contango",
        "credo",        "crescendo",    "cyano",
        "demo",         "ditto",        "Draco",
        "dynamo",       "embryo",       "Esperanto",
        "espresso",     "euro",         "falsetto",
        "Faro",         "fiasco",       "Filipino",
        "flamenco",     "furioso",      "generalissimo",
        "Gestapo",      "ghetto",       "gigolo",
        "gizmo",        "Greensboro",   "gringo",
        "Guaiabero",    "guano",        "gumbo",
        "gyro",         "hairdo",       "hippo",
        "Idaho",        "impetigo",     "inferno",
        "info",         "intermezzo",   "intertrigo",
        "Iquico",       "^ISO",          "jumbo",
        "junto",        "Kakapo",       "kilo",
        "Kinkimavo",    "Kokako",       "Kosovo",
        "Lesotho",      "libero",       "libido",
        "libretto",     "lido",         "Lilo",
        "limbo",        "limo",         "lineno",
        "lingo",        "lino",         "livedo",
        "loco",         "logo",         "lumbago",
        "macho",        "macro",        "mafioso",
        "magneto",      "magnifico",    "Majuro",
        "Malabo",       "manifesto",    "Maputo",
        "Maracaibo",    "medico",       "memo",
        "metro",        "Mexico",       "micro",
        "Milano",       "Monaco",       "mono",
        "Montenegro",   "Morocco",      "Muqdisho",
        "myo",          "^NATO",         "^NCO",
        "neutrino",     "^NGO",          "Ningbo",
        "octavo",       "oregano",      "Orinoco",
        "Orlando",      "Oslo",         "^oto",
        "panto",        "Paramaribo",   "Pardusco",
        "pedalo",       "photo",        "pimento",
        "pinto",        "pleco",        "Pluto",
        "pogo",         "polo",         "poncho",
        "Porto-Novo",   "Porto",        "pro",
        "psycho",       "pueblo",       "quarto",
        "Quito",        "rhino",        "risotto",
        "rococo",       "rondo",        "Sacramento",
        "saddo",        "sago",         "salvo",
        "Santiago",     "Sapporo",      "Sarajevo",
        "scherzando",   "scherzo",      "silo",
        "sirocco",      "sombrero",     "staccato",
        "sterno",       "stucco",       "stylo",
        "sumo",         "Taiko",        "techno",
        "terrazzo",     "testudo",      "timpano",
        "tiro",         "tobacco",      "Togo",
        "Tokyo",        "torero",       "Torino",
        "Toronto",      "torso",        "tremolo",
        "typo",         "tyro",         "ufo",
        "UNESCO",       "vaquero",      "vermicello",
        "verso",        "vibrato",      "violoncello",
        "Virgo",        "weirdo",       "WHO",
        "WTO",          "Yamoussoukro", "yo-yo",
        "zero",         "Zibo",

    @PL_sb_C_o_i,
);


# UNCONDITIONAL "..ch" -> "..chs"

my $PL_sb_U_ch_chs = enclose join "|", map { substr($_,0,-2) }
qw(
    czech eunuch stomach
);

# UNCONDITIONAL "..[ei]x" -> "..ices"

my $PL_sb_U_ex_ices = enclose join "|", map { substr($_,0,-2) }
(
    "codex",    "murex",    "silex",
);

my $PL_sb_U_ix_ices = enclose join "|", map { substr($_,0,-2) }
(
    "radix",    "helix",
);

# CLASSICAL "..[ei]x" -> "..ices"

my $PL_sb_C_ex_ices = enclose join "|", map { substr($_,0,-2) }
(
    "vortex",   "vertex",   "cortex",   "latex",
    "pontifex", "apex",     "index",    "simplex",
);

my $PL_sb_C_ix_ices = enclose join "|", map { substr($_,0,-2) }
(
    "appendix",
);

# ARABIC: ".." -> "..i"

my $PL_sb_C_i = enclose join "|",
(
    "afrit",    "afreet",   "efreet",
);

# HEBREW: ".." -> "..im"

my $PL_sb_C_im = enclose join "|",
(
    "goy",      "seraph",   "cherub",  "zuz", "kibbutz",
);

# UNCONDITIONAL "..man" -> "..mans"

my $PL_sb_U_man_mans = enclose join "|",
qw(
    \bataman caiman cayman ceriman
    \bdesman \bdolman \bfarman \bharman \bhetman
    human \bleman ottoman shaman talisman
    Alabaman Bahaman Burman German
    Hiroshiman Liman Nakayaman Norman Oklahoman
    Panaman Roman Selman Sonaman Tacoman Yakiman
    Yokohaman Yuman
);

my @PL_sb_uninflected_s =
(
# PAIRS OR GROUPS SUBSUMED TO A SINGULAR...
    "breeches", "britches", "pajamas", "pyjamas", "clippers", "gallows",
    "hijinks", "headquarters", "pliers", "scissors", "testes", "herpes",
    "pincers", "shears", "proceedings", "trousers",

# UNASSIMILATED LATIN 4th DECLENSION

    "cantus", "coitus", "nexus",

# RECENT IMPORTS...
    "contretemps", "corps", "debris",
    ".*ois", "siemens",

# DISEASES
    ".*measles", "mumps",

# MISCELLANEOUS OTHERS...
    "diabetes", "jackanapes", ".*series", "species", "rabies",
    "chassis", "innings", "news", "mews", "haggis",
);

my $PL_sb_uninflected_herd = enclose join "|",
# DON'T INFLECT IN CLASSICAL MODE, OTHERWISE NORMAL INFLECTION
(
    "wildebeest", "swine", "eland", "bison", "buffalo",
    "elk", "rhinoceros", 'zucchini',
    'caribou', 'dace', 'grouse', 'guinea[- ]fowl',
    'haddock', 'hake', 'halibut', 'herring', 'mackerel',
    'pickerel', 'pike', 'roe', 'seed', 'shad',
    'snipe', 'teal', 'turbot', 'water[- ]fowl',
);

my $PL_sb_lese_lesen = enclose join "|",
(
    'Auslese',
    'beerenauslese',
    'Spaetlese',
    'trockenbeerenauslese',
);

my $PL_sb_uninflected = enclose join "|",
(
# SOME FISH AND HERD ANIMALS
    ".*fish", "tuna", "salmon", "mackerel", "trout",
    "bream", "sea[- ]bass", "carp", "cod", "flounder", "whiting",

    ".*deer", ".*sheep", "moose",

# ALL NATIONALS ENDING IN -ese
    "Portuguese", "Amoyese", "Borghese", "Congoese", "Faroese",
    "Foochowese", "Genevese", "Genoese", "Gilbertese", "Hottentotese",
    "Kiplingese", "Kongoese", "Lucchese", "Maltese", "Nankingese",
    "Niasese", "Pekingese", "Piedmontese", "Pistoiese", "Sarawakese",
    "Shavese", "Vermontese", "Wenchowese", "Yengeese",
    ".*[nrlm]ese",

# SOME WORDS ENDING IN ...s (OFTEN PAIRS TAKEN AS A WHOLE)

    @PL_sb_uninflected_s,

# DISEASES
    ".*pox",


# OTHER ODDITIES
    "graffiti", "djinn", 'samuri',
    '.*craft$', 'offspring', 'pence', 'quid', 'hertz',
);

# SINGULAR WORDS ENDING IN ...s (ALL INFLECT WITH ...es)

my $PL_sb_singular_s = enclose join '|',
(
    ".*ss",
        "acropolis", "aegis", "alias", "asbestos", "bathos", "bias",
    "bronchitis", "bursitis", "caddis", "cannabis",
        "canvas", "chaos", "cosmos", "dais", "digitalis",
        "epidermis", "ethos", "eyas", "gas", "glottis",
    "hubris", "ibis", "lens", "mantis", "marquis", "metropolis",
        "pathos", "pelvis", "polis", "rhinoceros",
        "sassafras", "trellis", ".*us", "[A-Z].*es",

    @PL_sb_C_is_ides,
    @PL_sb_U_is_ides,
);

my $PL_v_special_s = enclose join '|',
(
    $PL_sb_singular_s,
    @PL_sb_uninflected_s,
    keys %PL_sb_irregular_s,
    '(.*[csx])is',
    '(.*)ceps',
    '[A-Z].*s',
);

my %PL_sb_postfix_adj = (
    'general' => ['(?!major|lieutenant|brigadier|adjutant|.*star)\S+'],
    'martial' => [qw(court)],
);

foreach (keys %PL_sb_postfix_adj) {
    $PL_sb_postfix_adj{$_} = enclose
                 enclose(join('|', @{$PL_sb_postfix_adj{$_}}))
                   . "(?=(?:-|\\s+)$_)";
}

my $PL_sb_postfix_adj = '(' . join('|', values %PL_sb_postfix_adj) . ')(.*)';

my $PL_prep = enclose join '|', qw (
    about above across after against amid amidst among around as at athwart atop
    barring before behind below beneath beside besides between betwixt beyond but by
    circa
    despite down during
    except
    failing for from
    given
    in inside into
    like
    minus
    near next
    of off on onto out outside over
    pace past per plus pro
    qua
    round
    sans save since
    than through throughout thru thruout till times to toward towards
    under underneath unlike until unto up upon
    versus via vs
    with within without worth
);

my $PL_sb_prep_dual_compound = '(.*?)((?:-|\s+)(?:'.$PL_prep.'|d[eua])(?:-|\s+))a(?:-|\s+)(.*)';

my $PL_sb_prep_compound = '(.*?)((-|\s+)('.$PL_prep.'|d[eua])((-|\s+)(.*))?)';


my %PL_pron_nom =
(
#   NOMINATIVE      REFLEXIVE

"i" => "we",    "myself"   =>   "ourselves",
"you"   => "you",   "yourself" =>   "yourselves",
"she"   => "they",  "herself"  =>   "themselves",
"he"    => "they",  "himself"  =>   "themselves",
"it"    => "they",  "itself"   =>   "themselves",
"they"  => "they",  "themself" =>   "themselves",

#   POSSESSIVE

"mine"   => "ours",
"yours"  => "yours",
"hers"   => "theirs",
"his"    => "theirs",
"its"    => "theirs",
"theirs" => "theirs",
);

my %PL_pron_acc =
(
#   ACCUSATIVE      REFLEXIVE

"me"    => "us",    "myself"   =>   "ourselves",
"you"   => "you",   "yourself" =>   "yourselves",
"her"   => "them",  "herself"  =>   "themselves",
"him"   => "them",  "himself"  =>   "themselves",
"it"    => "them",  "itself"   =>   "themselves",
"them"  => "them",  "themself" =>   "themselves",
);

my $PL_pron_acc = enclose join '|', keys %PL_pron_acc;

my %PL_v_irregular_pres =
(
#   1st PERS. SING.     2ND PERS. SING.     3RD PERS. SINGULAR
#               3RD PERS. (INDET.)

"am"    => "are",   "are"   => "are",   "is"     => "are",
"was"   => "were",  "were"  => "were",  "was"    => "were",
"have"  => "have",  "have"  => "have",  "has"    => "have",
"do"    => "do",    "do"    => "do",    "does"   => "do",
);

my $PL_v_irregular_pres = enclose join '|', keys %PL_v_irregular_pres;

my %PL_v_ambiguous_pres =
(
#   1st PERS. SING.     2ND PERS. SING.     3RD PERS. SINGULAR
#               3RD PERS. (INDET.)

"act"   => "act",   "act"   => "act",   "acts"    => "act",
"blame" => "blame", "blame" => "blame", "blames"  => "blame",
"can"   => "can",   "can"   => "can",   "can"     => "can",
"must"  => "must",  "must"  => "must",  "must"    => "must",
"fly"   => "fly",   "fly"   => "fly",   "flies"   => "fly",
"copy"  => "copy",  "copy"  => "copy",  "copies"  => "copy",
"drink" => "drink", "drink" => "drink", "drinks"  => "drink",
"fight" => "fight", "fight" => "fight", "fights"  => "fight",
"fire"  => "fire",  "fire"  => "fire",  "fires"   => "fire",
"like"  => "like",  "like"  => "like",  "likes"   => "like",
"look"  => "look",  "look"  => "look",  "looks"   => "look",
"make"  => "make",  "make"  => "make",  "makes"   => "make",
"reach" => "reach", "reach" => "reach", "reaches" => "reach",
"run"   => "run",   "run"   => "run",   "runs"    => "run",
"sink"  => "sink",  "sink"  => "sink",  "sinks"   => "sink",
"sleep" => "sleep", "sleep" => "sleep", "sleeps"  => "sleep",
"view"  => "view",  "view"  => "view",  "views"   => "view",
);

my $PL_v_ambiguous_pres = enclose join '|', keys %PL_v_ambiguous_pres;


my $PL_v_irregular_non_pres = enclose join '|',
(
"did", "had", "ate", "made", "put",
"spent", "fought", "sank", "gave", "sought",
"shall", "could", "ought", "should",
);

my $PL_v_ambiguous_non_pres = enclose join '|',
(
"thought", "saw", "bent", "will", "might", "cut",
);

# "..oes" -> "..oe" (the rest are "..oes" -> "o")

my $PL_v_oes_oe = enclose join "|",
qw(
    .*shoes  .*hoes  .*toes
    canoes   floes   oboes  roes  throes  woes
);

my $PL_count_zero = enclose join '|',
(
0, "no", "zero", "nil"
);

my $PL_count_one = enclose join '|',
(
1, "a", "an", "one", "each", "every", "this", "that",
);

my %PL_adj_special =
(
"a"    => "some",   "an"   =>  "some",
"this" => "these",  "that" => "those",
);
my $PL_adj_special = enclose join '|', keys %PL_adj_special;

my %PL_adj_poss =
(
"my"    => "our",
"your"  => "your",
"its"   => "their",
"her"   => "their",
"his"   => "their",
"their" => "their",
);
my $PL_adj_poss = enclose join '|', keys %PL_adj_poss;


sub checkpat
{
local $SIG{__WARN__} = sub {0};
do {$@ =~ s/at.*?$//;
    die "\nBad user-defined singular pattern:\n\t$@\n"}
    if (!eval "'' =~ m/$_[0]/; 1;" or $@);
return @_;
}

sub checkpatsubs
{
checkpat($_[0]);
if (defined $_[1])
{
    local $SIG{__WARN__} = sub {0};
    do {$@ =~ s/at.*?$//;
        die "\nBad user-defined plural string: '$_[1]'\n\t$@\n"}
        if (!eval "qq{$_[1]}; 1;" or $@);
}
return @_;
}

my @PL_sb_user_defined = ();
my @PL_v_user_defined  = ();
my @PL_adj_user_defined  = ();
my @A_a_user_defined   = ();

sub def_noun
{
    unshift @PL_sb_user_defined, checkpatsubs(@_);
    return 1;
}

sub def_verb
{
    unshift @PL_v_user_defined, checkpatsubs(@_[4,5]);
    unshift @PL_v_user_defined, checkpatsubs(@_[2,3]);
    unshift @PL_v_user_defined, checkpatsubs(@_[0,1]);
    return 1;
}

sub def_adj
{
    unshift @PL_adj_user_defined, checkpatsubs(@_);
    return 1;
}

sub def_a
{
unshift @A_a_user_defined, checkpat(@_,'a');
return 1;
}

sub def_an
{
unshift @A_a_user_defined, checkpat(@_,'an');
return 1;
}

sub ud_match
{
my $word = shift;
for (my $i=0; $i < @_; $i+=2)
{
    if ($word =~ /^(?:$_[$i])$/i)
    {
        last unless defined $_[$i+1];
        return eval '"'.$_[$i+1].'"';
    }
}
return undef;
}

do
{
local $SIG{__WARN__} = sub {0};
my $rcfile;

$rcfile = $INC{'Lingua//EN/Inflect.pm'} || '';
$rcfile =~ s/Inflect.pm$/.inflectrc/;
do $rcfile or die "\nBad .inflectrc file ($rcfile):\n\t$@\n"
if $rcfile && -r $rcfile && -s $rcfile;

$rcfile = "$ENV{HOME}/.inflectrc" || '';
do $rcfile or die "\nBad .inflectrc file ($rcfile):\n\t$@\n"
if $rcfile && -r $rcfile && -s $rcfile;
};

sub postprocess     # FIX PEDANTRY AND CAPITALIZATION :-)
{
my ($orig, $inflected) = @_;
$inflected =~ s/([^|]+)\|(.+)/ $classical{all}?$2:$1 /e;
return $orig =~ /^I$/   ? $inflected
 : $orig =~ /^[A-Z]+$/  ? uc $inflected
 : $orig =~ /^[A-Z]/    ? ucfirst $inflected
 :            $inflected;
}

sub PL
#   PL($word,$number)
{
my ($str, $count) = @_;
my ($pre, $word, $post) = ($str =~ m/\A(\s*)(.+?)(\s*)\Z/);
return $str unless $word;
my $plural = postprocess $word,  _PL_special_adjective($word,$count)
              || _PL_special_verb($word,$count)
              || _PL_noun($word,$count);
return $pre.$plural.$post;
}

sub PL_N
#   PL_N($word,$number)
{
my ($str, $count) = @_;
my ($pre, $word, $post) = ($str =~ m/\A(\s*)(.+?)(\s*)\Z/);
return $str unless $word;
my $plural = postprocess $word, _PL_noun($word,$count);
return $pre.$plural.$post;
}

sub PL_V
#   PL_V($word,$number)
{
my ($str, $count) = @_;
my ($pre, $word, $post) = ($str =~ m/\A(\s*)(.+?)(\s*)\Z/);
return $str unless $word;
my $plural = postprocess $word, _PL_special_verb($word,$count)
              || _PL_general_verb($word,$count);
return $pre.$plural.$post;
}

sub PL_ADJ
#   PL_ADJ($word,$number)
{
my ($str, $count) = @_;
my ($pre, $word, $post) = ($str =~ m/\A(\s*)(.+?)(\s*)\Z/);
return $str unless $word;
my $plural = postprocess $word, _PL_special_adjective($word,$count)
              || $word;
return $pre.$plural.$post;
}

sub PL_eq     { _PL_eq(@_, \&PL_N) || _PL_eq(@_, \&PL_V) || _PL_eq(@_, \&PL_ADJ); }
sub PL_N_eq   { _PL_eq(@_, \&PL_N); }
sub PL_V_eq   { _PL_eq(@_, \&PL_V); }
sub PL_ADJ_eq     { _PL_eq(@_, \&PL_ADJ); }

sub _PL_eq
{
my ( $word1, $word2, $PL ) = @_;
my %classval = %classical;
%classical = %all_classical;
my $result = "";
$result = "eq"  if !$result && $word1 eq $word2;
$result = "p:s" if !$result && $word1 eq &$PL($word2);
$result = "s:p" if !$result && &$PL($word1) eq $word2;
%classical = ();
$result = "p:s" if !$result && $word1 eq &$PL($word2);
$result = "s:p" if !$result && &$PL($word1) eq $word2;
%classical = %classval;

if ($PL == \&PL || $PL == \&PL_N)
{
    $result = "p:p"
        if !$result && _PL_check_plurals_N($word1,$word2);
    $result = "p:p"
        if !$result && _PL_check_plurals_N($word2,$word1);
}
if ($PL == \&PL || $PL == \&PL_ADJ)
{
    $result = "p:p"
        if !$result && _PL_check_plurals_ADJ($word1,$word2,$PL);
}

return $result;
}

sub _PL_reg_plurals
{
    $_[0] =~ /($_[1])($_[2]\|\1$_[3]|$_[3]\|\1$_[2])/
}

sub _PL_check_plurals_N
{
my $pair = "$_[0]|$_[1]";
foreach ( values %PL_sb_irregular_s )   { return 1 if $_ eq $pair; }
foreach ( values %PL_sb_irregular ) { return 1 if $_ eq $pair; }

return 1 if
        _PL_reg_plurals($pair, $PL_sb_U_a_ata,   "as","ata")
     || _PL_reg_plurals($pair, $PL_sb_C_a_ata,   "as","ata")
     || _PL_reg_plurals($pair, $PL_sb_U_is_ides, "is","ides")
     || _PL_reg_plurals($pair, $PL_sb_C_is_ides, "is","ides")
     || _PL_reg_plurals($pair, $PL_sb_C_a_ae,    "s","e")
     || _PL_reg_plurals($pair, $PL_sb_C_en_ina,  "ens","ina")
     || _PL_reg_plurals($pair, $PL_sb_C_um_a,    "ums","a")
     || _PL_reg_plurals($pair, $PL_sb_C_us_i,    "uses","i")
     || _PL_reg_plurals($pair, $PL_sb_C_on_a,    "ons","a")
     || _PL_reg_plurals($pair, $PL_sb_C_o_i,     "os","i")
     || _PL_reg_plurals($pair, $PL_sb_C_ex_ices, "exes","ices")
     || _PL_reg_plurals($pair, $PL_sb_C_ix_ices, "ixes","ices")
     || _PL_reg_plurals($pair, $PL_sb_C_i,       "s","i")
     || _PL_reg_plurals($pair, $PL_sb_C_im,      "s","im")

     || _PL_reg_plurals($pair, '.*eau',       "s","x")
     || _PL_reg_plurals($pair, '.*ieu',       "s","x")
     || _PL_reg_plurals($pair, '.*tri',       "xes","ces")
     || _PL_reg_plurals($pair, '.{2,}[yia]n', "xes","ges");


return 0;
}

sub _PL_check_plurals_ADJ
{
my ( $word1a, $word2a ) = @_;
my ( $word1b, $word2b ) = @_;

$word1a = '' unless $word1a =~ s/'s?$//;
$word2a = '' unless $word2a =~ s/'s?$//;
$word1b = '' unless $word1b =~ s/s'$//;
$word2b = '' unless $word2b =~ s/s'$//;

if ($word1a)
{
    return 1 if $word2a && ( _PL_check_plurals_N($word1a, $word2a)
                || _PL_check_plurals_N($word2a, $word1a) );
    return 1 if $word2b && ( _PL_check_plurals_N($word1a, $word2b)
                || _PL_check_plurals_N($word2b, $word1a) );
}
if ($word1b)
{
    return 1 if $word2a && ( _PL_check_plurals_N($word1b, $word2a)
                || _PL_check_plurals_N($word2a, $word1b) );
    return 1 if $word2b && ( _PL_check_plurals_N($word1b, $word2b)
                || _PL_check_plurals_N($word2b, $word1b) );
}


return "";
}

sub _PL_noun
{
my ( $word, $count ) = @_;
my $value;              # UTILITY VARIABLE

# DEFAULT TO PLURAL

$count = $persistent_count
    if !defined($count) && defined($persistent_count);

$count = (defined $count and $count=~/^($PL_count_one)$/io
         or defined $count and $classical{zero}
         and $count=~/^($PL_count_zero)$/io)
            ? 1
            : 2;

return $word if $count==1;

# HANDLE USER-DEFINED NOUNS

return $value if defined($value = ud_match($word, @PL_sb_user_defined));


# HANDLE EMPTY WORD, SINGULAR COUNT AND UNINFLECTED PLURALS

$word eq ''         and return $word;

$word =~ /^($PL_sb_uninflected)$/i && !exists $PL_sb_irregular{$word} && $word !~ /^($PL_sb_lese_lesen)$/i
                and return $word;

$classical{herd} and $word =~ /^($PL_sb_uninflected_herd)$/i
                and return $word;


# HANDLE ISOLATED IRREGULAR PLURALS

$word =~ /^($PL_sb_irregular)$/i
                and return ( $PL_sb_irregular{$1} || $PL_sb_irregular{lc $1} );
$word =~ /(.*)\b($PL_sb_irregular)$/i
                and return $1 . ( $PL_sb_irregular{$2} || $PL_sb_irregular{lc $2} );


# HANDLE COMPOUNDS ("Governor General", "mother-in-law", "aide-de-camp", ETC.)

$word =~ /^(?:$PL_sb_postfix_adj)$/i
                and $value = $2
                and return _PL_noun($1,2)
                       . $value;

$word =~ /^(?:$PL_sb_prep_dual_compound)$/i
                and $value = [$2,$3]
                and return _PL_noun($1,2)
                       . $value->[0]
                       . _PL_noun($value->[1]);

$word =~ /^(?:$PL_sb_prep_compound)$/i
                and $value = $2
                and return _PL_noun($1,2)
                       . $value;

# HANDLE PRONOUNS

$word =~ /^((?:$PL_prep)\s+)($PL_pron_acc)$/i
                and return $1.$PL_pron_acc{lc($2)};

$value = $PL_pron_nom{lc($word)}
                and return $value;

$word =~ /^($PL_pron_acc)$/i
                and return $PL_pron_acc{lc($1)};


# HANDLE FAMILIES OF IRREGULAR PLURALS

$word =~ /(.*$PL_sb_U_man_mans)$/i
                and return "$1s";
$word =~ /(\S*)quy$/i
                and return "$1quies";
$word =~ /(\S*)(person)$/i and return $classical{persons}?"$1persons":"$1people";
$word =~ /(.*)man$/i        and return "$1men";
$word =~ /(.*[ml])ouse$/i   and return "$1ice";
$word =~ /(.*)goose$/i      and return "$1geese";
$word =~ /(.*)tooth$/i      and return "$1teeth";
$word =~ /(.*)foot$/i       and return "$1feet";

# HANDLE UNASSIMILATED IMPORTS

$word =~ /(.*)ceps$/i       and return $word;
$word =~ /(.*)zoon$/i       and return "$1zoa";
$word =~ /(.*[csx])is$/i    and return "$1es";
$word =~ /(.*$PL_sb_U_a_ata)a$/i  and return "$1ata";
$word =~ /(.*$PL_sb_U_is_ides)is$/i   and return "$1ides";
$word =~ /(.*$PL_sb_U_ch_chs)ch$/i    and return "$1chs";
$word =~ /(.*$PL_sb_U_ex_ices)ex$/i   and return "$1ices";
$word =~ /(.*$PL_sb_U_ix_ices)ix$/i   and return "$1ices";
$word =~ /(.*$PL_sb_U_um_a)um$/i  and return "$1a";
$word =~ /(.*$PL_sb_U_us_i)us$/i  and return "$1i";
$word =~ /(.*$PL_sb_U_on_a)on$/i  and return "$1a";
$word =~ /(.*$PL_sb_U_a_ae)$/i    and return "$1e";
$word =~ /(.*$PL_sb_lese_lesen)$/i    and return "$1n";

# HANDLE INCOMPLETELY ASSIMILATED IMPORTS

if ($classical{ancient})
{
    $word =~ /(.*)trix$/i       and return "$1trices";
    $word =~ /(.*)eau$/i        and return "$1eaux";
    $word =~ /(.*)ieu$/i        and return "$1ieux";
    $word =~ /(.{2,}[yia])nx$/i     and return "$1nges";
    $word =~ /(.*$PL_sb_C_en_ina)en$/i    and return "$1ina";
    $word =~ /(.*$PL_sb_C_ex_ices)ex$/i   and return "$1ices";
    $word =~ /(.*$PL_sb_C_ix_ices)ix$/i   and return "$1ices";
    $word =~ /(.*$PL_sb_C_um_a)um$/i  and return "$1a";
    $word =~ /(.*$PL_sb_C_us_i)us$/i  and return "$1i";
    $word =~ /(.*$PL_sb_C_us_us)$/i   and return "$1";
    $word =~ /(.*$PL_sb_C_a_ae)$/i    and return "$1e";
    $word =~ /(.*$PL_sb_C_a_ata)a$/i  and return "$1ata";
    $word =~ /(.*$PL_sb_C_is_ides)is$/i   and return "$1ides";
    $word =~ /(.*$PL_sb_C_o_i)o$/i    and return "$1i";
    $word =~ /(.*$PL_sb_C_on_a)on$/i  and return "$1a";
    $word =~ /$PL_sb_C_im$/i        and return "${word}im";
    $word =~ /$PL_sb_C_i$/i     and return "${word}i";
}


# HANDLE SINGULAR NOUNS ENDING IN ...s OR OTHER SILIBANTS

$word =~ /^($PL_sb_singular_s)$/i   and return "$1es";
$word =~ /^([A-Z].*s)$/             and $classical{names} and return "$1es";
$word =~ /^($PL_sb_z_zes)$/i        and return "$1es";
$word =~ /^(.*[^z])(z)$/i           and return "$1zzes";
$word =~ /^(.*)([cs]h|x|zz|ss)$/i   and return "$1$2es";
# $word =~ /(.*)(us)$/i             and return "$1$2es";

# HANDLE ...f -> ...ves

$word =~ /(.*[eao])lf$/i    and return "$1lves";
$word =~ /(.*[^d])eaf$/i    and return "$1eaves";
$word =~ /(.*[nlw])ife$/i   and return "$1ives";
$word =~ /(.*)arf$/i        and return "$1arves";

# HANDLE ...y

$word =~ /(.*[aeiou])y$/i   and return "$1ys";
$word =~ /([A-Z].*y)$/      and $classical{names} and return "$1s";
$word =~ /(.*)y$/i      and return "$1ies";

# HANDLE ...o

$word =~ /$PL_sb_U_o_os$/i  and return "${word}s";
$word =~ /[aeiou]o$/i       and return "${word}s";
$word =~ /o$/i          and return "${word}es";


# OTHERWISE JUST ADD ...s

return "${word}s";
}


sub _PL_special_verb
{
my ( $word, $count ) = @_;
$count = $persistent_count
    if !defined($count) && defined($persistent_count);
$count = (defined $count and $count=~/^($PL_count_one)$/io or
      defined $count and $classical{zero} and $count=~/^($PL_count_zero)$/io) ? 1
       : 2;

return undef if $count=~/^($PL_count_one)$/io;

my $value;              # UTILITY VARIABLE

# HANDLE USER-DEFINED VERBS

return $value if defined($value = ud_match($word, @PL_v_user_defined));

# HANDLE IRREGULAR PRESENT TENSE (SIMPLE AND COMPOUND)

$word =~ /^($PL_v_irregular_pres)((\s.*)?)$/i
        and return $PL_v_irregular_pres{lc $1}.$2;

# HANDLE IRREGULAR FUTURE, PRETERITE AND PERFECT TENSES

$word =~ /^($PL_v_irregular_non_pres)((\s.*)?)$/i
        and return $word;

# HANDLE PRESENT NEGATIONS (SIMPLE AND COMPOUND)

$word =~ /^($PL_v_irregular_pres)(n't(\s.*)?)$/i
        and return $PL_v_irregular_pres{lc $1}.$2;

$word =~ /^\S+n't\b/i
        and return $word;

# HANDLE SPECIAL CASES

$word =~ /^($PL_v_special_s)$/      and return undef;
$word =~ /\s/                       and return undef;
$word =~ /^quizzes$/i               and return "quiz";

# HANDLE STANDARD 3RD PERSON (CHOP THE ...(e)s OFF SINGLE WORDS)

$word =~ /^(.*)([cs]h|[x]|zz|ss)es$/i   and return "$1$2";

$word =~ /^(..+)ies$/i          and return "$1y";

$word =~ /($PL_v_oes_oe)$/      and return substr($1,0,-1);
$word =~ /^(.+)oes$/i           and return "$1o";

$word =~ /^(.*[^s])s$/i         and return $1;

# OTHERWISE, A REGULAR VERB (HANDLE ELSEWHERE)

return undef;
}

sub _PL_general_verb
{
my ( $word, $count ) = @_;
$count = $persistent_count
    if !defined($count) && defined($persistent_count);
$count = (defined $count and $count=~/^($PL_count_one)$/io or
      defined $count and $classical{zero} and $count=~/^($PL_count_zero)$/io) ? 1
       : 2;

return $word if $count=~/^($PL_count_one)$/io;

# HANDLE AMBIGUOUS PRESENT TENSES  (SIMPLE AND COMPOUND)

$word =~ /^($PL_v_ambiguous_pres)((\s.*)?)$/i
        and return $PL_v_ambiguous_pres{lc $1}.$2;

# HANDLE AMBIGUOUS PRETERITE AND PERFECT TENSES

$word =~ /^($PL_v_ambiguous_non_pres)((\s.*)?)$/i
        and return $word;

# OTHERWISE, 1st OR 2ND PERSON IS UNINFLECTED

return $word;

}

sub _PL_special_adjective
{
my ( $word, $count ) = @_;
$count = $persistent_count
    if !defined($count) && defined($persistent_count);
$count = (defined $count and $count=~/^($PL_count_one)$/io or
      defined $count and $classical{zero} and $count=~/^($PL_count_zero)$/io) ? 1
       : 2;

return $word if $count=~/^($PL_count_one)$/io;


# HANDLE USER-DEFINED ADJECTIVES

my $value;
return $value if defined($value = ud_match($word, @PL_adj_user_defined));

# HANDLE KNOWN CASES

$word =~ /^($PL_adj_special)$/i
            and return $PL_adj_special{lc $1};

# HANDLE POSSESSIVES

$word =~ /^($PL_adj_poss)$/i
            and return $PL_adj_poss{lc $1};

$word =~ /^(.*)'s?$/    and do { my $pl = PL_N($1);
                 return "$pl'" . ($pl =~ m/s$/ ? "" : "s");
                   };

# OTHERWISE, NO IDEA

return undef;

}


# 2. INDEFINITE ARTICLES

# THIS PATTERN MATCHES STRINGS OF CAPITALS STARTING WITH A "VOWEL-SOUND"
# CONSONANT FOLLOWED BY ANOTHER CONSONANT, AND WHICH ARE NOT LIKELY
# TO BE REAL WORDS (OH, ALL RIGHT THEN, IT'S JUST MAGIC!)

my $A_abbrev = q{
(?! FJO | [HLMNS]Y.  | RY[EO] | SQU
  | ( F[LR]? | [HL] | MN? | N | RH? | S[CHKLMNPTVW]? | X(YL)?) [AEIOU])
[FHLMNRSX][A-Z]
};

# THIS PATTERN CODES THE BEGINNINGS OF ALL ENGLISH WORDS BEGINING WITH A
# 'y' FOLLOWED BY A CONSONANT. ANY OTHER Y-CONSONANT PREFIX THEREFORE
# IMPLIES AN ABBREVIATION.

my $A_y_cons = 'y(b[lor]|cl[ea]|fere|gg|p[ios]|rou|tt)';

# EXCEPTIONS TO EXCEPTIONS

my $A_explicit_an = enclose join '|',
(
    "euler",
    "hour(?!i)", "heir", "honest", "hono",
);

my $A_ordinal_an = enclose join '|',
(
    "[aefhilmnorsx]-?th",
);

my $A_ordinal_a = enclose join '|',
(
    "[bcdgjkpqtuvwyz]-?th",
);

sub A {
    my ($str, $count) = @_;
    my ($pre, $word, $post) = ( $str =~ m/\A(\s*)(?:an?\s+)?(.+?)(\s*)\Z/i );
    return $str unless $word;
    my $result = _indef_article($word,$count);
    return $pre.$result.$post;
}

sub AN { goto &A }

sub _indef_article {
    my ( $word, $count ) = @_;

    $count = $persistent_count
        if !defined($count) && defined($persistent_count);

    return "$count $word"
        if defined $count && $count!~/^($PL_count_one)$/io;

    # HANDLE USER-DEFINED VARIANTS

    my $value;
    return "$value $word"
        if defined($value = ud_match($word, @A_a_user_defined));

    # HANDLE ORDINAL FORMS

    $word =~ /^($A_ordinal_a)/i         and return "a $word";
    $word =~ /^($A_ordinal_an)/i        and return "an $word";

    # HANDLE SPECIAL CASES

    $word =~ /^($A_explicit_an)/i       and return "an $word";
    $word =~ /^[aefhilmnorsx]$/i        and return "an $word";
    $word =~ /^[bcdgjkpqtuvwyz]$/i      and return "a $word";


    # HANDLE ABBREVIATIONS

    $word =~ /^($A_abbrev)/ox           and return "an $word";
    $word =~ /^[aefhilmnorsx][.-]/i     and return "an $word";
    $word =~ /^[a-z][.-]/i              and return "a $word";

    # HANDLE CONSONANTS

    $word =~ /^[^aeiouy]/i              and return "a $word";

    # HANDLE SPECIAL VOWEL-FORMS

    $word =~ /^e[uw]/i                  and return "a $word";
    $word =~ /^onc?e\b/i                and return "a $word";
    $word =~ /^uni([^nmd]|mo)/i         and return "a $word";
    $word =~ /^ut[th]/i                 and return "an $word";
    $word =~ /^u[bcfhjkqrst][aeiou]/i   and return "a $word";

    # HANDLE SPECIAL CAPITALS

    $word =~ /^U[NK][AIEO]?/            and return "a $word";

    # HANDLE VOWELS

    $word =~ /^[aeiou]/i                and return "an $word";

    # HANDLE y... (BEFORE CERTAIN CONSONANTS IMPLIES (UNNATURALIZED) "i.." SOUND)

    $word =~ /^($A_y_cons)/io           and return "an $word";

    # OTHERWISE, GUESS "a"
    return "a $word";
}

# 2. TRANSLATE ZERO-QUANTIFIED $word TO "no PL($word)"

sub NO
{
    my ($str, $count, $opt_ref) = @_;
    my ($pre, $word, $post) = ($str =~ m/\A(\s*)(.+?)(\s*)\Z/);

    $count = $persistent_count
        if !defined($count) && defined($persistent_count);
    $count = 0 unless $count;

    if ($count =~ /^$PL_count_zero$/) {
        return "${pre}no ". PL($word,0) . $post ;
    }

    $count =~ s{[^\d.e+-]}{}gi;
    1 while $count =~ s{([.].*)[.]}{$1};
    $count = defined $opt_ref->{words_below} && $count < $opt_ref->{words_below}
                 ? NUMWORDS($count)
                 : $count;

    if (defined $opt_ref->{comma} || defined $opt_ref->{comma_every}) {
        $opt_ref->{comma_every} = 3   if !defined $opt_ref->{comma_every};
        $opt_ref->{comma}       = ',' if !defined $opt_ref->{comma}
                                      || $opt_ref->{comma} =~ /^\d+$/;

        $count = _commify($count, @{$opt_ref}{'comma','comma_every'});
    }

    return "$pre$count " . PL($word,$count) . $post
}

sub _commify {
    my ($number, $comma, $every) = @_;
    return if !defined $comma;
    return if !defined $comma;
    $number =~ s{(?:(?<=^)|(?<=^-))(\d\d{$every,})}
                { my $n = $1;
                  $n=~s/(?<=.)(?=(?:.{$every})+$)/$comma/g;
                  $n;
                }e;
    return $number;
}

# PARTICIPLES

sub PART_PRES
{
        local $_ = PL_V(shift,2);
           s/ie$/y/
        or s/ue$/u/
        or s/([auy])e$/$1/
        or s/ski$/ski/
        or s/[^b]i$//
        or s/^(are|were)$/be/
        or s/^(had)$/hav/
        or s/(hoe)$/$1/
        or s/([^e])e$/$1/
        or m/er$/
        or s/([^aeiou][aeiouy]([bdgmnprst]))$/$1$2/;
        return "${_}ing";
}



# NUMERICAL INFLECTIONS

my %nth =
(
    0 => 'th',
    1 => 'st',
    2 => 'nd',
    3 => 'rd',
    4 => 'th',
    5 => 'th',
    6 => 'th',
    7 => 'th',
    8 => 'th',
    9 => 'th',
    11 => 'th',
    12 => 'th',
    13 => 'th',
);


my %ordinal;
@ordinal{qw(ty    one   two    three five  eight  nine  twelve )}=
         qw(tieth first second third fifth eighth ninth twelfth);

my $ordinal_suff = join '|', keys %ordinal, "";

$ordinal{""} = 'th';

sub ORD($)
{
    my $num = shift;
    if ($num =~ /\d/) {
        my $tail = substr($num, -3);
        return $num . ($nth{$tail%100} || $nth{$tail%10});
    }
    else {
        $num =~ s/($ordinal_suff)\Z/$ordinal{$1}/;
        return $num;
    }
}


my %default_args =
(
    'group'   => 0,
    'comma'   => ',',
    'and'     => 'and',
    'zero'    => 'zero',
    'one'     => 'one',
    'decimal' => 'point',
);

my @unit = ('',qw(one two three four five six seven eight nine));
my @teen = qw(ten eleven twelve thirteen fourteen
          fifteen sixteen seventeen eighteen nineteen);
my @ten  = ('','',qw(twenty thirty forty fifty sixty seventy eighty ninety));

## From http://en.wikipedia.org/wiki/Names_of_large_numbers
our %millmap = (
     #num zeros
     '0'    => { US => q(),                       UK => q(),                                       EU => q()},
     '3'    => { US => q(thousand),               UK => q(thousand),                               EU => q(thousand)},
     '6'    => { US => q(million),                UK => q(million),                                EU => q(million)},
     '9'    => { US => q(billion),                UK => q(thousand million),                       EU => q(milliard)},
     '12'   => { US => q(trillion),               UK => q(billion),                                EU => q(billion)},
     '15'   => { US => q(quadrillion),            UK => q(thousand billion),                       EU => q(billiard)},
     '18'   => { US => q(quintillion),            UK => q(trillion),                               EU => q(trillion)},
     '21'   => { US => q(sextillion),             UK => q(thousand trillion),                      EU => q(trilliard)},
     '24'   => { US => q(septillion),             UK => q(quadrillion),                            EU => q(quadrillion)},
     '27'   => { US => q(octillion),              UK => q(thousand quadrillion),                   EU => q(quadrilliard)},
     '30'   => { US => q(nonillion),              UK => q(quintillion),                            EU => q(quintillion)},
     '33'   => { US => q(decillion),              UK => q(thousand quintillion),                   EU => q(quintilliard)},
     '36'   => { US => q(undecillion),            UK => q(sextillion),                             EU => q(sextillion)},
     '39'   => { US => q(duodecillion),           UK => q(thousand sextillion),                    EU => q(sextilliard)},
     '42'   => { US => q(tredecillion),           UK => q(septillion),                             EU => q(septillion)},
     '45'   => { US => q(quattuordecillion),      UK => q(thousand septillion),                    EU => q(septilliard)},
     '48'   => { US => q(quindecillion),          UK => q(octillion),                              EU => q(octillion)},
     '51'   => { US => q(sedecillion),            UK => q(thousand octillion),                     EU => q(octilliard)},
     '54'   => { US => q(septendecillion),        UK => q(nonillion),                              EU => q(nonillion)},
     '57'   => { US => q(octodecillion),          UK => q(thousand nonillion),                     EU => q(nonilliard)},
     '60'   => { US => q(novendecillion),         UK => q(decillion),                              EU => q(decillion)},
     '63'   => { US => q(vigintillion),           UK => q(thousand decillion),                     EU => q(decilliard)},
     '66'   => { US => q(unvigintillion),         UK => q(undecillion),                            EU => q(undecillion)},
     '69'   => { US => q(duovigintillion),        UK => q(thousand undecillion),                   EU => q(undecilliard)},
     '72'   => { US => q(tresvigintillion),       UK => q(duodecillion),                           EU => q(duodecillion)},
     '75'   => { US => q(quattuorvigintillion),   UK => q(thousand duodecillion),                  EU => q(duodecilliard)},
     '78'   => { US => q(quinquavigintillion),    UK => q(tredecillion),                           EU => q(tredecillion)},
     '81'   => { US => q(sesvigintillion),        UK => q(thousand tredecillion),                  EU => q(tredecilliard)},
     '84'   => { US => q(septemvigintillion),     UK => q(quattuordecillion),                      EU => q(quattuordecillion)},
     '87'   => { US => q(octovigintillion),       UK => q(thousand quattuordecillion),             EU => q(quattuordecilliard)},
     '90'   => { US => q(novemvigintillion),      UK => q(quindecillion),                          EU => q(quindecillion)},
     '93'   => { US => q(trigintillion),          UK => q(thousand quindecillion),                 EU => q(quindecilliard)},
     '96'   => { US => q(untrigintillion),        UK => q(sedecillion),                            EU => q(sedecillion)},
     '99'   => { US => q(duotrigintillion),       UK => q(thousand sedecillion),                   EU => q(sedecilliard)},
     '102'  => { US => q(trestrigintillion),      UK => q(septendecillion),                        EU => q(septendecillion)},
     '105'  => { US => q(quattuortrigintillion),  UK => q(thousand septendecillion),               EU => q(septendecilliard)},
     '108'  => { US => q(quinquatrigintillion),   UK => q(octodecillion),                          EU => q(octodecillion)},
     '111'  => { US => q(sestrigintillion),       UK => q(thousand octodecillion),                 EU => q(octodecilliard)},
     '114'  => { US => q(septentrigintillion),    UK => q(novendecillion),                         EU => q(novendecillion)},
     '117'  => { US => q(octotrigintillion),      UK => q(thousand novendecillion),                EU => q(novendecilliard)},
     '120'  => { US => q(noventrigintillion),     UK => q(vigintillion),                           EU => q(vigintillion)},
     '123'  => { US => q(quadragintillion),       UK => q(thousand vigintillion),                  EU => q(vigintilliard)},
     '153'  => { US => q(quinquagintillion),      UK => q(thousand quinquavigintillion),           EU => q(quinquavigintilliard) },
     '183'  => { US => q(sexagintillion),         UK => q(thousand trigintillion),                 EU => q(trigintilliard) },
     '213'  => { US => q(septuagintillion),       UK => q(thousand quinquatrigintillion),          EU => q(quinquatrigintilliard) },
     '243'  => { US => q(octogintillion),         UK => q(thousand quadragintillion),              EU => q(quadragintilliard) },
     '273'  => { US => q(nonagintillion),         UK => q(thousand quinquaquadragintillion),       EU => q(quinquaquadragintilliard) },
     '303'  => { US => q(centillion),             UK => q(thousand quinquagintillion),             EU => q(quinquagintilliard) },
     '306'  => { US => q(uncentillion),           UK => q(unquinquagintillion),                    EU => q(unquinquagintillion) },
     '309'  => { US => q(duocentillion),          UK => q(thousand unquinquagintillion),           EU => q(unquinquagintilliard) },
     '312'  => { US => q(trescentillion),         UK => q(duoquinquagintillion),                   EU => q(duoquinquagintillion) },
     '333'  => { US => q(decicentillion),         UK => q(thousand quinquaquinquagintillion),      EU => q(quinquaquinquagintilliard) },
     '336'  => { US => q(undecicentillion),       UK => q(sesquinquagintillion),                   EU => q(sesquinquagintillion) },
     '363'  => { US => q(viginticentillion),      UK => q(thousand sexagintillion),                EU => q(sexagintilliard) },
     '366'  => { US => q(unviginticentillion),    UK => q(unsexagintillion),                       EU => q(unsexagintillion) },
     '393'  => { US => q(trigintacentillion),     UK => q(thousand quinquasexagintillion),         EU => q(quinquasexagintilliard) },
     '423'  => { US => q(quadragintacentillion),  UK => q(thousand septuagintillion),              EU => q(septuagintilliard) },
     '453'  => { US => q(quinquagintacentillion), UK => q(thousand quinquaseptuagintillion),       EU => q(quinquaseptuagintilliard) },
     '483'  => { US => q(sexagintacentillion),    UK => q(thousand octogintillion),                EU => q(octogintilliard) },
     '513'  => { US => q(septuagintacentillion),  UK => q(thousand quinquaoctogintillion),         EU => q(quinquaoctogintilliard) },
     '543'  => { US => q(octogintacentillion),    UK => q(thousand nonagintillion),                EU => q(nonagintilliard) },
     '573'  => { US => q(nonagintacentillion),    UK => q(thousand quinquanonagintillion),         EU => q(quinquanonagintilliard) },
     '603'  => { US => q(ducentillion),           UK => q(thousand centillion),                    EU => q(centilliard) },
     '903'  => { US => q(trecentillion),          UK => q(thousand quinquagintacentillion),        EU => q(quinquagintacentilliard) },
     '1203' => { US => q(quadringentillion),      UK => q(thousand ducentillion),                  EU => q(ducentilliard) },
     '1503' => { US => q(quingentillion),         UK => q(thousand quinquagintaducentillion),      EU => q(quinquagintaducentilliard) },
     '1803' => { US => q(sescentillion),          UK => q(thousand trecentillion),                 EU => q(trecentilliard) },
     '2103' => { US => q(septingentillion),       UK => q(thousand quinquagintatrecentillion),     EU => q(quinquagintatrecentilliard) },
     '2403' => { US => q(octingentillion),        UK => q(thousand quadringentillion),             EU => q(quadringentilliard) },
     '2703' => { US => q(nongentillion),          UK => q(thousand quinquagintaquadringentillion), EU => q(quinquagintaquadringentilliard) },
     '3003' => { US => q(millinillion),           UK => q(thousand quingentillion),                EU => q(quingentilliard) },
);

my $millchoice = 'US';
my @millkeys = sort {$a <=> $b } keys %millmap;
my $maxmill = (sort {$a <=> $b } keys %millmap)[-1];
our $millast = undef;
our @mill;
for my $numZeros ( 0..$maxmill ) {
    next if $numZeros%3 != 0;
    my $arraySlot = $numZeros/3;
    if( defined( $millmap{$numZeros} ) ) {
        $mill[$arraySlot] = " $millmap{$numZeros}->{$millchoice}";
        $millast = $arraySlot;
    } else {
        my $missing = $arraySlot - $millast;
        $mill[$arraySlot] = $mill[$missing] . $mill[$millast];
    }
}

sub mill { my $ind = $_[0]||0;
       die "Number out of range\n" if $ind > $#mill;
       return $ind<@mill ? $mill[$ind] : ' ???illion'; }

sub unit { return $unit[$_[0]]. mill($_[1]); }

sub ten
{
    return $ten[$_[0]] . ($_[0]&&$_[1]?'-':'') . $unit[$_[1]] . mill($_[2])
        if $_[0] ne '1';
    return $teen[$_[1]]. $mill[$_[2]||0];
}

sub hund
{
    return unit($_[0]) . " hundred" . ($_[1] || $_[2] ? " $_[4] " : '')
         . ten($_[1],$_[2]) . mill($_[3]) . ', ' if $_[0];
    return ten($_[1],$_[2]) . mill($_[3]) . ', ' if $_[1] || $_[2];
    return '';
}


sub enword
{
    my ($num,$group,$zero,$one,$comma,$and) = @_;

    if ($group==1)
    {
        $num =~ s/(\d)/ ($1==1 ? " $one" : $1 ? unit($1) :" $zero")."$comma " /eg;
    }
    elsif ($group==2)
    {
        $num =~ s/(\d)(\d)/ ($1 ? ten($1,$2) : $2 ? " $zero " . unit($2) : " $zero $zero") . "$comma " /eg;
        $num =~ s/(\d)/ ($1 ? unit($1) :" $zero")."$comma " /e;
    }
    elsif ($group==3)
    {
        $num =~ s/(\d)(\d)(\d)/ ($1==1 ? " $one" : $1 ? unit($1) :" $zero")." ".($2 ? ten($2,$3) : $3 ? " $zero " . unit($3) : " $zero $zero") . "$comma " /eg;
        $num =~ s/(\d)(\d)/ ($1 ? ten($1,$2) : $2 ? " $zero " . unit($2) : " $zero $zero") . "$comma " /e;
        $num =~ s/(\d)/ ($1==1 ? " $one" : $1 ? unit($1) :" $zero")."$comma " /e;
    }
    elsif ($num+0==0) {
        $num = $zero;
    }
    elsif ($num+0==1) {
        $num = $one;
    }
    else {
        $num =~ s/\A\s*0+//;
        my $mill = 0;
        1 while $num =~ s/(\d)(\d)(\d)(?=\D*\Z)/ hund($1,$2,$3,$mill++,$and) /e;
        $num =~ s/(\d)(\d)(?=\D*\Z)/ ten($1,$2,$mill)."$comma " /e;
        $num =~ s/(\d)(?=\D*\Z)/ unit($1,$mill) . "$comma "/e;
    }
    return $num;
}

sub NUMWORDS
{
    my $num = shift;

    if (@_ % 2 and require Carp) {
        die "Missing value in option list (odd number of option args) at"
          . join ' line ', (caller)[1,2];
    }

    my %arg = ( %default_args, @_ );
    my $group = $arg{group};

    # Handle "stylistic" conversions (up to a given threshold)...
    if (exists $arg{threshold} && $num > $arg{threshold}) {
        my ($whole, $frac) = split /[.]/, $num;
        while ($arg{comma}) {
            $whole =~ s{ (\d) ( \d{3}(?:,|\z) ) }{$1,$2}xms
                or last;
        }
        return $frac ? "$whole.$frac" : $whole;
    }

    die "Bad chunking option: $group\n" unless $group =~ /\A[0-3]\Z/;
    my $sign = ($num =~ /\A\s*\+/) ? "plus"
         : ($num =~ /\A\s*\-/) ? "minus"
         : '';

    my ($zero, $one) = @arg{'zero','one'};
    my $comma = $arg{comma};
    my $and = $arg{'and'};

    my $ord = $num =~ s/(st|nd|rd|th)\Z//;
    my @chunks = ($arg{decimal})
            ? $group ? split(/\./, $num) : split(/\./, $num, 2)
            : ($num);

    my $first = 1;

    if ($chunks[0] eq '') { $first=0; shift @chunks; }

    foreach ( @chunks )
    {
        s/\D//g;
        $_ = '0' unless $_;

        if (!$group && !$first) { $_ = enword($_,1,$zero,$one,$comma,$and) }
        else                    { $_ = enword($_,$group,$zero,$one,$comma,$and) }

        s/, \Z//;
        s/\s+,/,/g;
        s/, (\S+)\s+\Z/ $and $1/ if !$group and $first;
        s/\s+/ /g;
        s/(\A\s|\s\Z)//g;
        $first = '' if $first;
    }

    my @numchunks = ();
    if ($first =~ /0/)
    {
        unshift @chunks, '';
    }
    else
    {
        @numchunks = split /\Q$comma /, $chunks[0];
    }

    $numchunks[-1] =~ s/($ordinal_suff)\Z/$ordinal{$1}/
        if $ord and @numchunks;

    foreach (@chunks[1..$#chunks])
    {
        push @numchunks, $arg{decimal};
        push @numchunks, split /\Q$comma /;
    }

    if (wantarray)
    {
        unshift @numchunks, $sign if $sign;
        return @numchunks
    }
    elsif ($group)
    {
        return ($sign?"$sign ":'') .  join ", ", @numchunks;
    }
    else
    {
        $num = ($sign?"$sign ":'') . shift @numchunks;
        $first = ($num !~ /$arg{decimal}\Z/);
        foreach ( @numchunks )
        {
            if (/\A$arg{decimal}\Z/)
            {
                $num .= " $_";
                $first = 0;
            }
            elsif ($first)
            {
                $num .= "$comma $_";
            }
            else
            {
                $num .= " $_";
            }
        }
        return $num;
    }
}

# Join words with commas and a trailing 'and' (when appropriate)...

sub WORDLIST {
    my %opt;
    my @words;

    for my $arg (@_) {
        if (ref $arg eq 'HASH' ) {
            %opt = (%opt, %{$arg});
        }
        else {
            push @words, $arg;
        }
    }

    return ""                               if @words == 0;
    return "$words[0]"                      if @words == 1;

    my $conj = exists($opt{conj}) ? $opt{conj} : 'and';
    if (@words == 2) {
        $conj =~ s/^ (?=\S)  |  (?<=\S) $/ /gxms;
        return "$words[0]$conj$words[1]";
    }

    my $sep = exists $opt{sep}  ? $opt{sep}
              : grep(/,/, @words)   ? q{; }
              :                       q{, }
              ;

    my $final_sep = !exists $opt{final_sep}        ? "$sep $conj"
                    : length($opt{final_sep}) == 0 ? $conj
                    :                                "$opt{final_sep} $conj"
                    ;
    $final_sep =~ s/\s+/ /gmxs;
    $final_sep =~ s/^ (?=[^\W\d_])  |  (?<=\S) $/ /gxms;

    return join($sep, @words[0..@words-2]) . "$final_sep$words[-1]";
}



1;

__END__

=head1 NAME

Lingua::EN::Inflect - Convert singular to plural. Select "a" or "an".

=head1 VERSION

This document describes version 1.901 of Lingua::EN::Inflect

=head1 SYNOPSIS

 use Lingua::EN::Inflect qw ( PL PL_N PL_V PL_ADJ NO NUM
                  PL_eq PL_N_eq PL_V_eq PL_ADJ_eq
                  A AN
                  PART_PRES
                  ORD NUMWORDS
                  WORDLIST
                  inflect classical
                  def_noun def_verb def_adj def_a def_an );


 # UNCONDITIONALLY FORM THE PLURAL

      print "The plural of ", $word, " is ", PL($word), "\n";


 # CONDITIONALLY FORM THE PLURAL

      print "I saw $cat_count ", PL("cat",$cat_count), "\n";


 # FORM PLURALS FOR SPECIFIC PARTS OF SPEECH

      print PL_N("I",$N1), PL_V("saw",$N1),
        PL_ADJ("my",$N2), PL_N("saw",$N2), "\n";


 # DEAL WITH "0/1/N" -> "no/1/N" TRANSLATION:

      print "There ", PL_V("was",$errors), NO(" error",$errors), "\n";


 # USE DEFAULT COUNTS:

      print NUM($N1,""), PL("I"), PL_V(" saw"), NUM($N2), PL_N(" saw");
      print "There ", NUM($errors,''), PL_V("was"), NO(" error"), "\n";


 # COMPARE TWO WORDS "NUMBER-INSENSITIVELY":

      print "same\n"      if PL_eq($word1, $word2);
      print "same noun\n" if PL_N_eq($word1, $word2);
      print "same verb\n" if PL_V_eq($word1, $word2);
      print "same adj.\n" if PL_ADJ_eq($word1, $word2);


 # ADD CORRECT "a" OR "an" FOR A GIVEN WORD:

      print "Did you want ", A($thing), " or ", AN($idea), "\n";


 # CONVERT NUMERALS INTO ORDINALS (i.e. 1->1st, 2->2nd, 3->3rd, etc.)

      print "It was", ORD($position), " from the left\n";

 # CONVERT NUMERALS TO WORDS (i.e. 1->"one", 101->"one hundred and one", etc.)
 # IN A SCALAR CONTEXT: GET BACK A SINGLE STRING...

    $words = NUMWORDS(1234);      # "one thousand, two hundred and thirty-four"
    $words = NUMWORDS(ORD(1234)); # "one thousand, two hundred and thirty-fourth"


 # IN A LIST CONTEXT: GET BACK A LIST OF STRINGSi, ONE FOR EACH "CHUNK"...

    @words = NUMWORDS(1234);    # ("one thousand","two hundred and thirty-four")


 # OPTIONAL PARAMETERS CHANGE TRANSLATION:

    $words = NUMWORDS(12345, group=>1);
                # "one, two, three, four, five"

    $words = NUMWORDS(12345, group=>2);
                # "twelve, thirty-four, five"

    $words = NUMWORDS(12345, group=>3);
                # "one twenty-three, forty-five"

    $words = NUMWORDS(1234, 'and'=>'');
                # "one thousand, two hundred thirty-four"

    $words = NUMWORDS(1234, 'and'=>', plus');
                # "one thousand, two hundred, plus thirty-four"

    $words = NUMWORDS(555_1202, group=>1, zero=>'oh');
                # "five, five, five, one, two, oh, two"

    $words = NUMWORDS(555_1202, group=>1, one=>'unity');
                # "five, five, five, unity, two, zero, two"

    $words = NUMWORDS(123.456, group=>1, decimal=>'mark');
                # "one two three mark four five six"

 # LITERAL STYLE ONLY NAMES NUMBERS LESS THAN A CERTAIN THRESHOLD...

    $words = NUMWORDS(   9, threshold=>10);    # "nine"
    $words = NUMWORDS(  10, threshold=>10);    # "ten"
    $words = NUMWORDS(  11, threshold=>10);    # "11"
    $words = NUMWORDS(1000, threshold=>10);    # "1,000"

 # JOIN WORDS INTO A LIST:

    $list = WORDLIST("apple", "banana", "carrot");
                # "apple, banana, and carrot"

    $list = WORDLIST("apple", "banana");
                # "apple and banana"

    $list = WORDLIST("apple", "banana", "carrot", {final_sep=>""});
                # "apple, banana and carrot"


 # REQUIRE "CLASSICAL" PLURALS (EG: "focus"->"foci", "cherub"->"cherubim")

      classical;          # USE ALL CLASSICAL PLURALS

      classical 1;           #  USE ALL CLASSICAL PLURALS
      classical 0;           #  USE ALL MODERN PLURALS (DEFAULT)

      classical 'zero';      #  "no error" INSTEAD OF "no errors"
      classical zero=>1;     #  "no error" INSTEAD OF "no errors"
      classical zero=>0;     #  "no errors" INSTEAD OF "no error"

      classical 'herd';      #  "2 buffalo" INSTEAD OF "2 buffalos"
      classical herd=>1;     #  "2 buffalo" INSTEAD OF "2 buffalos"
      classical herd=>0;     #  "2 buffalos" INSTEAD OF "2 buffalo"

      classical 'persons';   # "2 chairpersons" INSTEAD OF "2 chairpeople"
      classical persons=>1;  # "2 chairpersons" INSTEAD OF "2 chairpeople"
      classical persons=>0;  # "2 chairpeople" INSTEAD OF "2 chairpersons"

      classical 'ancient';   # "2 formulae" INSTEAD OF "2 formulas"
      classical ancient=>1;  # "2 formulae" INSTEAD OF "2 formulas"
      classical ancient=>0;  # "2 formulas" INSTEAD OF "2 formulae"



 # INTERPOLATE "PL()", "PL_N()", "PL_V()", "PL_ADJ()", A()", "AN()"
 # "NUM()" AND "ORD()" WITHIN STRINGS:

      print inflect("The plural of $word is PL($word)\n");
      print inflect("I saw $cat_count PL("cat",$cat_count)\n");
      print inflect("PL(I,$N1) PL_V(saw,$N1) PL(a,$N2) PL_N(saw,$N2)");
      print inflect("NUM($N1,)PL(I) PL_V(saw) NUM($N2,)PL(a) PL_N(saw)");
      print inflect("I saw NUM($cat_count) PL("cat")\nNUM()");
      print inflect("There PL_V(was,$errors) NO(error,$errors)\n");
      print inflect("There NUM($errors,) PL_V(was) NO(error)\n";
      print inflect("Did you want A($thing) or AN($idea)\n");
      print inflect("It was ORD($position) from the left\n");


 # ADD USER-DEFINED INFLECTIONS (OVERRIDING INBUILT RULES):

      def_noun  "VAX"  => "VAXen";  # SINGULAR => PLURAL

      def_verb  "will" => "shall",  # 1ST PERSON SINGULAR => PLURAL
                "will" => "will",   # 2ND PERSON SINGULAR => PLURAL
                "will" => "will",   # 3RD PERSON SINGULAR => PLURAL

      def_adj   "hir"  => "their",  # SINGULAR => PLURAL

      def_a     "h"                 # "AY HALWAYS SEZ 'HAITCH'!"

      def_an    "horrendous.*"      # "AN HORRENDOUS AFFECTATION"


=head1 DESCRIPTION

B<< [I<Note:> This module is strictly in maintenance mode now. If you're
mostly interested in singular/plural and a/an inflections, take a look
at the newer Lingua::EN::Inflexion module, which offers a cleaner and
more convenient interface, has many more features (including
plural->singular inflexions), and is also much better tested.] >>

The exportable subroutines of Lingua::EN::Inflect provide plural
inflections, "a"/"an" selection for English words, and manipulation
of numbers as words

Plural forms of all nouns, most verbs, and some adjectives are
provided. Where appropriate, "classical" variants (for example: "brother" ->
"brethren", "dogma" -> "dogmata", etc.) are also provided.

Pronunciation-based "a"/"an" selection is provided for all English
words, and most initialisms.

It is also possible to inflect numerals (1,2,3) to ordinals (1st, 2nd, 3rd)
and to English words ("one", "two", "three).

In generating these inflections, Lingua::EN::Inflect follows the Oxford
English Dictionary and the guidelines in Fowler's Modern English
Usage, preferring the former where the two disagree.

The module is built around standard British spelling, but is designed
to cope with common American variants as well. Slang, jargon, and
other English dialects are I<not> explicitly catered for.

Where two or more inflected forms exist for a single word (typically a
"classical" form and a "modern" form), Lingua::EN::Inflect prefers the
more common form (typically the "modern" one), unless "classical"
processing has been specified
(see L<"MODERN VS CLASSICAL INFLECTIONS">).

=head1 FORMING PLURALS

=head2 Inflecting Plurals

All of the C<PL_...> plural inflection subroutines take the word to be
inflected as their first argument and return the corresponding inflection.
Note that all such subroutines expect the I<singular> form of the word. The
results of passing a plural form are undefined (and unlikely to be correct).

The C<PL_...> subroutines also take an optional second argument,
which indicates the grammatical "number" of the word (or of another word
with which the word being inflected must agree). If the "number" argument is
supplied and is not C<1> (or C<"one"> or C<"a">, or some other adjective that
implies the singular), the plural form of the word is returned. If the
"number" argument I<does> indicate singularity, the (uninflected) word
itself is returned. If the number argument is omitted, the plural form
is returned unconditionally.

The various subroutines are:

=over 8

=item C<PL_N($;$)>

The exportable subroutine C<PL_N()> takes a I<singular> English noun or
pronoun and returns its plural. Pronouns in the nominative ("I" ->
"we") and accusative ("me" -> "us") cases are handled, as are
possessive pronouns ("mine" -> "ours").


=item C<PL_V($;$)>

The exportable subroutine C<PL_V()> takes the I<singular> form of a
conjugated verb (that is, one which is already in the correct "person"
and "mood") and returns the corresponding plural conjugation.


=item C<PL_ADJ($;$)>

The exportable subroutine C<PL_ADJ()> takes the I<singular> form of
certain types of adjectives and returns the corresponding plural form.
Adjectives that are correctly handled include: "numerical" adjectives
("a" -> "some"), demonstrative adjectives ("this" -> "these", "that" ->
"those"), and possessives ("my" -> "our", "cat's" -> "cats'", "child's"
-> "childrens'", etc.)


=item C<PL($;$)>

The exportable subroutine C<PL()> takes a I<singular> English noun,
pronoun, verb, or adjective and returns its plural form. Where a word
has more than one inflection depending on its part of speech (for
example, the noun "thought" inflects to "thoughts", the verb "thought"
to "thought"), the (singular) noun sense is preferred to the (singular)
verb sense.

Hence C<PL("knife")> will return "knives" ("knife" having been treated
as a singular noun), whereas C<PL("knifes")> will return "knife"
("knifes" having been treated as a 3rd person singular verb).

The inherent ambiguity of such cases suggests that,
where the part of speech is known, C<PL_N>, C<PL_V>, and
C<PL_ADJ> should be used in preference to C<PL>.

=back

Note that all these subroutines ignore any whitespace surrounding the
word being inflected, but preserve that whitespace when the result is
returned. For example, C<S<PL(" cat  ")>> returns S<" cats  ">.


=head2 Numbered plurals

The C<PL_...> subroutines return only the inflected word, not the count that
was used to inflect it. Thus, in order to produce "I saw 3 ducks", it
is necessary to use:

    print "I saw $N ", PL_N($animal,$N), "\n";

Since the usual purpose of producing a plural is to make it agree with
a preceding count, Lingua::EN::Inflect provides an exportable subroutine
(C<NO($;$)>) which, given a word and a(n optional) count, returns the
count followed by the correctly inflected word. Hence the previous
example can be rewritten:

    print "I saw ", NO($animal,$N), "\n";

In addition, if the count is zero (or some other term which implies
zero, such as C<"zero">, C<"nil">, etc.) the count is replaced by the
word "no". Hence, if C<$N> had the value zero, the previous example
would print the somewhat more elegant:

    I saw no animals

rather than:

    I saw 0 animals

Note that the name of the subroutine is a pun: the subroutine
returns either a number (a I<No.>) or a C<"no">, in front of the
inflected word.

=head3 Wordy and comma'd plurals

The C<NO()> subroutine takes an optional third argument: a hash of named
options that configure its behaviour.

The C<'words_below'> option informs C<NO()> what other numbers (i.e.
apart from zero) it should convert to words. For example:S

    for my $count (0..12) {
        print NO('cat', $count, {words_below => 10}), "\n";
    }

would print:

    no cats
    one cat
    two cats
    three cats
    four cats
    five cats
    six cats
    seven cats
    eight cats
    nine cats
    10 cats
    11 cats
    12 cats

The C<'comma'> and C<'comma_every'> options determine whether or
not the numbers produced by C<NO()> have commas in them. That is:

    2001 space odysseys

versus:

    2,001 space odysseys

Normally, numbers are produced without commas, but if C<'comma'> or
C<'comma_every'> is specified, then commas are added as requested.

The C<'comma'> option specifies which character to use as a comma.
It defaults to C<','>, but may be set to anything convenient:

    print NO('Euro', $amount, {comma=>'.'});

    # prints:  1.000.000 Euros

The C<'comma_every'> option specifies how many characters between commas.
It defaults to 3, but may be set to any positive number:

    print NO('Euro', $amount, {comma_every=>4});

    # prints:  100,0000 Euros

Note that you can set both options at once, if you wish:

    print NO('Euro', $amount, {comma_every=>2, comma=>'_'});

    # prints:  1_00_00_00 Euros


=head2 Reducing the number of counts required

In some contexts, the need to supply an explicit count to the various
C<PL_...> subroutines makes for tiresome repetition. For example:

    print PL_ADJ("This",$errors), PL_N(" error",$errors),
          PL_V(" was",$errors), " fatal.\n";

Lingua::EN::Inflect therefore provides an exportable subroutine
(C<NUM($;$)>) that may be used to set a persistent "default number"
value. If such a value is set, it is subsequently used whenever an
optional second "number" argument is omitted. The default value thus set
can subsequently be removed by calling C<NUM()> with no arguments.
Hence we could rewrite the previous example:

    NUM($errors);
    print PL_ADJ("This"), PL_N(" error"), PL_V(" was"), "fatal.\n";
    NUM();

Normally, C<NUM()> returns its first argument, so that it may also
be "inlined" in contexts like:

    print NUM($errors), PL_N(" error"), PL_V(" was"), " detected.\n"
    print PL_ADJ("This"), PL_N(" error"), PL_V(" was"), "fatal.\n"
        if $severity > 1;

However, in certain contexts (see L<"INTERPOLATING INFLECTIONS IN STRINGS">)
it is preferable that C<NUM()> return an empty string. Hence C<NUM()>
provides an optional second argument. If that argument is supplied (that is, if
it is defined) and evaluates to false, C<NUM> returns an empty string
instead of its first argument. For example:

    print NUM($errors,0), NO("error"), PL_V(" was"), " detected.\n";
    print PL_ADJ("This"), PL_N(" error"), PL_V(" was"), "fatal.\n"
        if $severity > 1;



=head2 Number-insensitive equality

Lingua::EN::Inflect also provides a solution to the problem
of comparing words of differing plurality through the exportable subroutines
C<PL_eq($$)>, C<PL_N_eq($$)>, C<PL_V_eq($$)>, and C<PL_ADJ_eq($$)>.
Each  of these subroutines takes two strings, and  compares them
using the corresponding plural-inflection subroutine (C<PL()>, C<PL_N()>,
C<PL_V()>, and C<PL_ADJ()> respectively).

The comparison returns true if:

=over 8

=item *

the strings are C<eq>-equal, or

=item *

one string is C<eq>-equal to a plural form of the other, or

=item *

the strings are two different plural forms of the one word.

=back

Hence all of the following return true:

    PL_eq("index","index")      # RETURNS "eq"
    PL_eq("index","indexes")    # RETURNS "s:p"
    PL_eq("index","indices")    # RETURNS "s:p"
    PL_eq("indexes","index")    # RETURNS "p:s"
    PL_eq("indices","index")    # RETURNS "p:s"
    PL_eq("indices","indexes")  # RETURNS "p:p"
    PL_eq("indexes","indices")  # RETURNS "p:p"
    PL_eq("indices","indices")  # RETURNS "eq"

As indicated by the comments in the previous example, the actual value
returned by the various C<PL_eq> subroutines encodes which of the
three equality rules succeeded: "eq" is returned if the strings were
identical, "s:p" if the strings were singular and plural respectively,
"p:s" for plural and singular, and "p:p" for two distinct plurals.
Inequality is indicated by returning an empty string.

It should be noted that two distinct singular words which happen to take
the same plural form are I<not> considered equal, nor are cases where
one (singular) word's plural is the other (plural) word's singular.
Hence all of the following return false:

    PL_eq("base","basis")       # ALTHOUGH BOTH -> "bases"
    PL_eq("syrinx","syringe")   # ALTHOUGH BOTH -> "syringes"
    PL_eq("she","he")       # ALTHOUGH BOTH -> "they"

    PL_eq("opus","operas")      # ALTHOUGH "opus" -> "opera" -> "operas"
    PL_eq("taxi","taxes")       # ALTHOUGH "taxi" -> "taxis" -> "taxes"

Note too that, although the comparison is "number-insensitive" it is I<not>
case-insensitive (that is, C<PL("time","Times")> returns false. To obtain
both number and case insensitivity, prefix both arguments with C<lc>
(that is, C<PL(lc "time", lc "Times")> returns true).


=head1 OTHER VERB FORMS

=head2 Present participles

C<Lingua::EN::Inflect> also provides the C<PART_PRES> subroutine,
which can take a 3rd person singular verb and
correctly inflect it to its present participle:

    PART_PRES("runs")   # "running"
    PART_PRES("loves")  # "loving"
    PART_PRES("eats")   # "eating"
    PART_PRES("bats")   # "batting"
    PART_PRES("spies")  # "spying"


=head1 PROVIDING INDEFINITE ARTICLES

=head2 Selecting indefinite articles

Lingua::EN::Inflect provides two exportable subroutines (C<A($;$)> and
C<AN($;$)>) which will correctly prepend the appropriate indefinite
article to a word, depending on its pronunciation. For example:

    A("cat")        # -> "a cat"
    AN("cat")       # -> "a cat"
    A("euphemism")      # -> "a euphemism"
    A("Euler number")   # -> "an Euler number"
    A("hour")       # -> "an hour"
    A("houri")      # -> "a houri"

The two subroutines are I<identical> in function and may be used
interchangeably. The only reason that two versions are provided is to
enhance the readability of code such as:

    print "That is ", AN($errortype), " error\n;
    print "That is ", A($fataltype), " fatal error\n;

Note that in both cases the actual article provided depends I<only> on
the pronunciation of the first argument, I<not> on the name of the
subroutine.

C<A()> and C<AN()> will ignore any indefinite article that already
exists at the start of the string. Thus:

    @half_arked = (
        "a elephant",
        "a giraffe",
        "an ewe",
        "a orangutan",
    );

    print A($_), "\n" for @half_arked;

    # prints:
    #     an elephant
    #     a giraffe
    #     a ewe
    #     an orangutan


C<A()> and C<AN()> both take an optional second argument. As with the
C<PL_...> subroutines, this second argument is a "number" specifier. If
its value is C<1> (or some other value implying singularity), C<A()> and
C<AN()> insert "a" or "an" as appropriate. If the number specifier
implies plurality, (C<A()> and C<AN()> insert the actual second argument instead.
For example:

    A("cat",1)      # -> "a cat"
    A("cat",2)      # -> "2 cat"
    A("cat","one")      # -> "one cat"
    A("cat","no")       # -> "no cat"

Note that, as implied by the previous examples, C<A()> and
C<AN()> both assume that their job is merely to provide the correct
qualifier for a word (that is: "a", "an", or the specified count).
In other words, they assume that the word they are given has
already been correctly inflected for plurality. Hence, if C<$N>
has the value 2, then:

      print A("cat",$N);

prints "2 cat", instead of "2 cats". The correct approach is to use:

      print A(PL("cat",$N),$N);

or, better still:

      print NO("cat",$N);

Note too that, like the various C<PL_...> subroutines, whenever C<A()>
and C<AN()> are called with only one argument they are subject to the
effects of any preceding call to C<NUM()>. Hence, another possible
solution is:

      NUM($N);
      print A(PL("cat"));


=head2 Indefinite articles and initialisms

"Initialisms" (sometimes inaccurately called "acronyms") are terms which
have been formed from the initial letters of words in a phrase (for
example, "NATO", "NBL", "S.O.S.", "SCUBA", etc.)

Such terms present a particular challenge when selecting between "a"
and "an", since they are sometimes pronounced as if they were a single
word ("nay-tow", "sku-ba") and sometimes as a series of letter names
("en-eff-ell", "ess-oh-ess").

C<A()> and C<AN()> cope with this dichotomy using a series of inbuilt
rules, which may be summarized as:

=over 8

=item 1.

If the word starts with a single letter, followed by a period or dash
(for example, "R.I.P.", "C.O.D.", "e-mail", "X-ray", "T-square"), then
choose the appropriate article for the I<sound> of the first letter
("an R.I.P.", "a C.O.D.", "an e-mail", "an X-ray", "a T-square").

=item 2.

If the first two letters of the word are capitals,
consonants, and do not appear at the start of any known English word,
(for example, "LCD", "XML", "YWCA"), then once again choose "a" or
"an" depending on the I<sound> of the first letter ("an LCD", "an
XML", "a YWCA").

=item 3.

Otherwise, assume the string is a capitalized word or a
pronounceable initialism (for example, "LED", "OPEC", "FAQ", "UNESCO"), and
therefore takes "a" or "an" according to the (apparent) pronunciation of
the entire word ("a LED", "an OPEC", "a FAQ", "a UNESCO").

=back

Note that rules 1 and 3 together imply that the presence or absence of
punctuation may change the selection of indefinite article for a
particular initialism (for example, "a FAQ" but "an F.A.Q.").


=head2 Indefinite articles and "soft H's"

Words beginning in the letter 'H' present another type of difficulty
when selecting a suitable indefinite article. In a few such words
(for example, "hour", "honour", "heir") the 'H' is not voiced at
all, and so such words inflect with "an". The remaining cases
("voiced H's") may be divided into two categories:
"hard H's" (such as "hangman", "holograph", "hat", etc.) and
"soft H's" (such as "hysterical", "horrendous", "holy", etc.)

Hard H's always take "a" as their indefinite article, and soft
H's normally do so as well. But I<some> English speakers prefer
"an" for soft H's (although the practice is now generally considered an
affectation, rather than a legitimate grammatical alternative).

At present, the C<A()> and C<AN()> subroutines ignore soft H's and use
"a" for any voiced 'H'. The author would, however, welcome feedback on
this decision (envisaging a possible future "soft H" mode).


=head1 INFLECTING ORDINALS

Occasionally it is useful to present an integer value as an ordinal
rather than as a numeral. For example:

    Enter password (1st attempt): ********
    Enter password (2nd attempt): *********
    Enter password (3rd attempt): *********
    No 4th attempt. Access denied.

To this end, Lingua::EN::Inflect provides the C<ORD()> subroutine.
<ORD()> takes a single argument and forms its ordinal equivalent.
If the argument isn't a numerical integer, it just adds "-th".


=head1 CONVERTING NUMBERS TO WORDS

The exportable subroutine C<NUMWORDS> takes a number (cardinal or ordinal)
and returns an English representation of that number. In a scalar context
a string is returned. Hence:

    use Lingua::EN::Inflect qw( NUMWORDS );

    $words = NUMWORDS(1234567);

puts the string:

    "one million, two hundred and thirty-four thousand, five hundred and sixty-seven"

into $words.

In a list context each comma-separated chunk is returned as a separate element.
Hence:

    @words = NUMWORDS(1234567);

puts the list:

    ("one million",
     "two hundred and thirty-four thousand",
     "five hundred and sixty-seven")

into @words.

Note that this also means that:

    print NUMWORDS(1234567);


will (misprint) print:

    one milliontwo hundred and thirty-four thousandfive hundred and sixty-seven

To get readable output, make sure the call in in scalar context:

    print scalar NUMWORDS(1234567);

Non-digits (apart from an optional leading plus or minus sign,
any decimal points, and ordinal suffixes -- see below) are silently
ignored, so the following all produce identical results:

        NUMWORDS(5551202);
        NUMWORDS(5_551_202);
        NUMWORDS("5,551,202");
        NUMWORDS("555-1202");

That last case is a little awkward since it's almost certainly a phone number,
and "five million, five hundred and fifty-one thousand, two hundred and two"
probably isn't what's wanted.

To overcome this, C<NUMWORDS()> takes an optional named argument, 'group',
which changes how numbers are translated. The argument must be a
positive integer less than four, which indicated how the digits of the
number are to be grouped. If the argument is C<1>, then each digit is
translated separately. If the argument is C<2>, pairs of digits
(starting from the I<left>) are grouped together. If the argument is
C<3>, triples of numbers (again, from the I<left>) are grouped. Hence:

        NUMWORDS("555-1202", group=>1)

returns C<"five, five, five, one, two, zero, two">, whilst:

        NUMWORDS("555-1202", group=>2)

returns C<"fifty-five, fifty-one, twenty, two">, and:

        NUMWORDS("555-1202", group=>3)

returns C<"five fifty-five, one twenty, two">.

Phone numbers are often written in words as
C<"five..five..five..one..two..zero..two">, which is also easy to
achieve:

        join '..', NUMWORDS("555-1202", group=>1)

C<NUMWORDS> also handles decimal fractions. Hence:

        NUMWORDS("1.2345")

returns C<"one point two three four five"> in a scalar context
and C<("one","point","two","three","four","five")>) in an array context.
Exponent form (C<"1.234e56">) is not yet handled.

Multiple decimal points are only translated in one of the "grouping" modes.
Hence:

        NUMWORDS(101.202.303)

returns C<"one hundred and one point two zero two three zero three">,
whereas:

        NUMWORDS(101.202.303, group=>1)

returns C<"one zero one point two zero two point three zero three">.

The digit C<'0'> is unusual in that in may be translated to English as "zero",
"oh", or "nought". To cater for this diversity, C<NUMWORDS> may be passed
a named argument, 'zero', which may be set to
the desired translation of C<'0'>. For example:

        print join "..", NUMWORDS("555-1202", group=>3, zero=>'oh')

prints C<"five..five..five..one..two..oh..two">.
By default, zero is rendered as "zero".

Likewise, the digit C<'1'> may be rendered as "one" or "a/an" (or very
occasionally other variants), depending on the context. So there is a
C<'one'> argument as well:

        print NUMWORDS($_, one=>'a solitary', zero=>'no more'),
              PL(" bottle of beer on the wall\n", $_)
                   for (3,2,1,0);

        # prints:
        #     three bottles of beer on the wall
        #     two bottles of beer on the wall
        #     a solitary bottle of beer on the wall
        #     no more bottles of beer on the wall

Care is needed if the word "a/an" is to be used as a C<'one'> value.
Unless the next word is known in advance, it's almost always necessary
to use the C<A> function as well:

        print A( NUMWORDS(1, one=>'a') . " $_\n")
         for qw(cat aardvark ewe hour);

    # prints:
    #     a cat
    #     an aardvark
    #     a ewe
    #     an hour

Another major regional variation in number translation is the use of
"and" in certain contexts. The named argument 'and'
allows the programmer to specify how "and" should be handled. Hence:

        print scalar NUMWORDS("765", 'and'=>'')

prints "seven hundred sixty-five", instead of "seven hundred and sixty-five".
By default, the "and" is included.

The translation of the decimal point is also subject to variation
(with "point", "dot", and "decimal" being the favorites).
The named argument 'decimal' allows the
programmer to how the decimal point should be rendered. Hence:

        print scalar NUMWORDS("666.124.64.101", group=>3, decimal=>'dot')

prints "six sixty-six, dot, one twenty-four, dot, sixty-four, dot, one zero one"
By default, the decimal point is rendered as "point".

C<NUMWORDS> also handles the ordinal forms of numbers. So:

        print scalar NUMWORDS('1st');
        print scalar NUMWORDS('3rd');
        print scalar NUMWORDS('202nd');
        print scalar NUMWORDS('1000000th');

print:

        first
        third
        two hundred and twenty-second
        one millionth

Two common idioms in this regard are:

        print scalar NUMWORDS(ORD($number));

and:

        print scalar ORD(NUMWORDS($number));

These are identical in effect, except when $number contains a decimal:

        $number = 99.09;
        print scalar NUMWORDS(ORD($number));    # ninety-ninth point zero nine
        print scalar ORD(NUMWORDS($number));    # ninety-nine point zero ninth

Use whichever you feel is most appropriate.


=head1 CONVERTING LISTS OF WORDS TO PHRASES

When creating a list of words, commas are used between adjacent items,
except if the items contain commas, in which case semicolons are used.
But if there are less than two items, the commas/semicolons are omitted
entirely. The final item also has a conjunction (usually "and" or "or")
before it. And although it's technically incorrect (and sometimes
misleading), some people prefer to omit the comma before that final
conjunction, even when there are more than two items.

That's complicated enough to warrant its own subroutine: C<WORDLIST()>.
This subroutine expects a list of words, possibly with one or more hash
references containing options. It returns a string that joins the list
together in the normal English usage. For example:

    print "You chose ", WORDLIST(@selected_items), "\n";
    # You chose barley soup, roast beef, and Yorkshire pudding

    print "You chose ", WORDLIST(@selected_items, {final_sep=>""}), "\n";
    # You chose barley soup, roast beef and Yorkshire pudding

    print "Please chose ", WORDLIST(@side_orders, {conj=>"or"}), "\n";
    # Please chose salad, vegetables, or ice-cream

The available options are:

    Option named    Specifies                Default value

    conj            Final conjunction        "and"
    sep             Inter-item separator     ","
    last_sep        Final separator          value of 'sep' option


=head1 INTERPOLATING INFLECTIONS IN STRINGS

By far the commonest use of the inflection subroutines is to
produce message strings for various purposes. For example:

        print NUM($errors), PL_N(" error"), PL_V(" was"), " detected.\n";
        print PL_ADJ("This"), PL_N(" error"), PL_V(" was"), "fatal.\n"
                if $severity > 1;

Unfortunately the need to separate each subroutine call detracts
significantly from the readability of the resulting code. To ameliorate
this problem, Lingua::EN::Inflect provides an exportable string-interpolating
subroutine (C<inflect($)>), which recognizes calls to the various inflection
subroutines within a string and interpolates them appropriately.

Using C<inflect> the previous example could be rewritten:

        print inflect "NUM($errors) PL_N(error) PL_V(was) detected.\n";
        print inflect "PL_ADJ(This) PL_N(error) PL_V(was) fatal.\n"
                if $severity > 1;

Note that C<inflect> also correctly handles calls to the C<NUM()> subroutine
(whether interpolated or antecedent). The C<inflect()> subroutine has
a related extra feature, in that it I<automatically> cancels any "default
number" value before it returns its interpolated string. This means that
calls to C<NUM()> which are embedded in an C<inflect()>-interpolated
string do not "escape" and interfere with subsequent inflections.


=head1 MODERN VS CLASSICAL INFLECTIONS

Certain words, mainly of Latin or Ancient Greek origin, can form
plurals either using the standard English "-s" suffix, or with
their original Latin or Greek inflections. For example:

        PL("stigma")            # -> "stigmas" or "stigmata"
        PL("torus")             # -> "toruses" or "tori"
        PL("index")             # -> "indexes" or "indices"
        PL("millennium")        # -> "millenniums" or "millennia"
        PL("ganglion")          # -> "ganglions" or "ganglia"
        PL("octopus")           # -> "octopuses" or "octopodes"


Lingua::EN::Inflect caters to such words by providing an
"alternate state" of inflection known as "classical mode".
By default, words are inflected using their contemporary English
plurals, but if classical mode is invoked, the more traditional
plural forms are returned instead.

The exportable subroutine C<classical()> controls this feature.
If C<classical()> is called with no arguments, it unconditionally
invokes classical mode. If it is called with a single argument, it
turns all classical inflects on or off (depending on whether the argument is
true or false). If called with two or more arguments, those arguments
specify which aspects of classical behaviour are to be used.

Thus:

        classical;                  # SWITCH ON CLASSICAL MODE
        print PL("formula");        # -> "formulae"

        classical 0;                # SWITCH OFF CLASSICAL MODE
        print PL("formula");        # -> "formulas"

        classical $cmode;           # CLASSICAL MODE IFF $cmode
        print PL("formula");        # -> "formulae" (IF $cmode)
                                    # -> "formulas" (OTHERWISE)

        classical herd=>1;          # SWITCH ON CLASSICAL MODE FOR "HERD" NOUNS
        print PL("wilderbeest");    # -> "wilderbeest"

        classical names=>1;         # SWITCH ON CLASSICAL MODE FOR NAMES
        print PL("sally");          # -> "sallies"
        print PL("Sally");          # -> "Sallys"

Note however that C<classical()> has no effect on the inflection of words which
are now fully assimilated. Hence:

        PL("forum")             # ALWAYS -> "forums"
        PL("criterion")         # ALWAYS -> "criteria"

LEI assumes that a capitalized word is a person's name. So it forms the
plural according to the rules for names (which is that you don't
inflect, you just add -s or -es). You can choose to turn that behaviour
off (it's on by the default, even when the module isn't in classical
mode) by calling C<< classical(names=>0) >>.

=head1 USER-DEFINED INFLECTIONS

=head2 Adding plurals at run-time

Lingua::EN::Inflect provides five exportable subroutines which allow
the programmer to override the module's behaviour for specific cases:

=over 8

=item C<def_noun($$)>

The C<def_noun> subroutine takes a pair of string arguments: the singular and
plural forms of the noun being specified. The singular form
specifies a pattern to be interpolated (as C<m/^(?:$first_arg)$/i>).
Any noun matching this pattern is then replaced by the string in the
second argument. The second argument specifies a string which is
interpolated after the match succeeds, and is then used as the plural
form. For example:

      def_noun  'cow'        => 'kine';
      def_noun  '(.+i)o'     => '$1i';
      def_noun  'spam(mer)?' => '\\$\\%\\@#\\$\\@#!!';

Note that both arguments should usually be specified in single quotes,
so that they are not interpolated when they are specified, but later (when
words are compared to them). As indicated by the last example, care
also needs to be taken with certain characters in the second argument,
to ensure that they are not unintentionally interpolated during comparison.

The second argument string may also specify a second variant of the plural
form, to be used when "classical" plurals have been requested. The beginning
of the second variant is marked by a '|' character:

      def_noun  'cow'        => 'cows|kine';
      def_noun  '(.+i)o'     => '$1os|$1i';
      def_noun  'spam(mer)?' => '\\$\\%\\@#\\$\\@#!!|varmints';

If no classical variant is given, the specified plural form is used in
both normal and "classical" modes.

If the second argument is C<undef> instead of a string, then the
current user definition for the first argument is removed, and the
standard plural inflection(s) restored.

Note that in all cases, later plural definitions for a particular
singular form replace earlier definitions of the same form. For example:

      # FIRST, HIDE THE MODERN FORM....
      def_noun  'aviatrix' => 'aviatrices';

      # LATER, HIDE THE CLASSICAL FORM...
      def_noun  'aviatrix' => 'aviatrixes';

      # FINALLY, RESTORE THE DEFAULT BEHAVIOUR...
      def_noun  'aviatrix' => undef;


Special care is also required when defining general patterns and
associated specific exceptions: put the more specific cases I<after>
the general pattern. For example:

      def_noun  '(.+)us' => '$1i';      # EVERY "-us" TO "-i"
      def_noun  'bus'    => 'buses';    # EXCEPT FOR "bus"

This "try-most-recently-defined-first" approach to matching
user-defined words is also used by C<def_verb>, C<def_a> and C<def_an>.


=item C<def_verb($$$$$$)>

The C<def_verb> subroutine takes three pairs of string arguments (that is, six
arguments in total), specifying the singular and plural forms of the three
"persons" of verb. As with C<def_noun>, the singular forms are specifications of
run-time-interpolated patterns, whilst the plural forms are specifications of
(up to two) run-time-interpolated strings:

       def_verb 'am'       => 'are',
                'are'      => 'are|art',
                'is'       => 'are';

       def_verb 'have'     => 'have',
                'have'     => 'have',
                'ha(s|th)' => 'have';

Note that as with C<def_noun>, modern/classical variants of plurals
may be separately specified, subsequent definitions replace previous
ones, and C<undef>'ed plural forms revert to the standard behaviour.


=item C<def_adj($$)>

The C<def_adj> subroutine takes a pair of string arguments, which specify
the singular and plural forms of the adjective being defined.
As with C<def_noun> and C<def_adj>, the singular forms are specifications of
run-time-interpolated patterns, whilst the plural forms are specifications of
(up to two) run-time-interpolated strings:

       def_adj  'this'     => 'these',
       def_adj  'red'      => 'red|gules',

As previously, modern/classical variants of plurals
may be separately specified, subsequent definitions replace previous
ones, and C<undef>'ed plural forms revert to the standard behaviour.


=item C<def_a($)> and C<def_an($)>

The C<def_a> and C<def_an> subroutines each take a single argument, which
specifies a pattern. If a word passed to C<A()> or C<AN()> matches this
pattern, it will be prefixed (unconditionally) with the corresponding indefinite
article. For example:

      def_a  'error';
      def_a  'in.+';

      def_an 'mistake';
      def_an 'error';

As with the other C<def_...> subroutines, such redefinitions are sequential
in effect so that, after the above example, "error" will be inflected with "an".

=back

=head2 The F<$HOME/.inflectrc> file

When it is imported, Lingua::EN::Inflect executes (as Perl code)
the contents of any file named F<.inflectrc> which it finds in the
in the directory where F<Lingua/EN/Inflect.pm> is installed,
or in the current home directory (C<$ENV{HOME}>), or in both.
Note that the code is executed within the Lingua::EN::Inflect
namespace.

Hence the user or the local Perl guru can make appropriate calls to
C<def_noun>, C<def_verb>, etc. in one of these F<.inflectrc> files, to
permanently and universally modify the behaviour of the module. For example

      > cat /usr/local/lib/perl5/Text/Inflect/.inflectrc

      def_noun  "UNIX"  => "UN*X|UNICES";

      def_verb  "teco"  => "teco",      # LITERALLY: "to edit with TECO"
                "teco"  => "teco",
                "tecos" => "teco";

      def_a     "Euler.*";              # "Yewler" TURNS IN HIS GRAVE


Note that calls to the C<def_...> subroutines from within a program
will take precedence over the contents of the home directory
F<.inflectrc> file, which in turn takes precedence over the system-wide
F<.inflectrc> file.


=head1 DIAGNOSTICS

On loading, if the Perl code in a F<.inflectrc> file is invalid
(syntactically or otherwise), an appropriate fatal error is issued.
A common problem is not ending the file with something that
evaluates to true (as the five C<def_...> subroutines do).

Using the five C<def_...> subroutines directly in a program may also
result in fatal diagnostics, if a (singular) pattern or an interpolated
(plural) string is somehow invalid.

Specific diagnostics related to user-defined inflections are:

=over 8

=item C<"Bad user-defined singular pattern:\n\t %s">

The singular form of a user-defined noun or verb
(as defined by a call to C<def_noun>, C<def_verb>, C<def_adj>,
C<def_a> or C<def_an>) is not a valid Perl regular expression. The
actual Perl error message is also given.

=item C<"Bad user-defined plural string: '%s'">

The plural form(s) of a user-defined noun or verb
(as defined by a call to C<def_noun>, C<def_verb> or C<def_adj>)
is not a valid Perl interpolated string (usually because it
interpolates some undefined variable).

=item C<"Bad .inflectrc file (%s):\n %s">

Some other problem occurred in loading the named local
or global F<.inflectrc> file. The Perl error message (including
the line number) is also given.

=back

There are I<no> diagnosable run-time error conditions for the actual
inflection subroutines, except C<NUMWORDS> and hence no run-time
diagnostics. If the inflection subroutines are unable to form a plural
via a user-definition or an inbuilt rule, they just "guess" the
commonest English inflection: adding "-s" for nouns, removing "-s" for
verbs, and no inflection for adjectives.

C<Lingua::EN::Inflect::NUMWORDS()> can C<die> with the following messages:

=over 8

=item C<"Bad grouping option: %s">

The optional argument to C<NUMWORDS()> wasn't 1, 2 or 3.

=item C<"Number out of range">

C<NUMWORDS()> was passed a number larger than the number represented
by 3006 consecutive nines. The words representing that number are
63,681 characters long, including commas and spaces. If you're
interested in the actual value, see t/numwords.t.

The reference for the names is http://en.wikipedia.org/wiki/Names_of_large_numbers

There are no names for any higher numbers.

=back

=head1 OTHER ISSUES

=head2 2nd Person precedence

If a verb has identical 1st and 2nd person singular forms, but
different 1st and 2nd person plural forms, then when its plural is
constructed, the 2nd person plural form is always preferred.

The author is not currently aware of any such verbs in English, but is
not quite arrogant enough to assume I<ipso facto> that none exist.


=head2 Nominative precedence

The singular pronoun "it" presents a special problem because its plural form
can vary, depending on its "case". For example:

        It ate my homework       ->  They ate my homework
        It ate it                ->  They ate them
        I fed my homework to it  ->  I fed my homework to them

As a consequence of this ambiguity, C<PL()> or C<PL_N> have been implemented
so that they always return the I<nominative> plural (that is, "they").

However, when asked for the plural of an unambiguously I<accusative>
"it" (namely, C<PL("to it")>, C<PL_N("from it")>, C<PL("with it")>,
etc.), both subroutines will correctly return the accusative plural
("to them", "from them", "with them", etc.)


=head2 The plurality of zero

The rules governing the choice between:

      There were no errors.

and

      There was no error.

are complex and often depend more on I<intent> rather than I<content>.
Hence it is infeasible to specify such rules algorithmically.

Therefore, Lingua::EN::Text contents itself with the following compromise: If
the governing number is zero, inflections always return the plural form
unless the appropriate "classical" inflection is in effect, in which case the
singular form is always returned.

Thus, the sequence:

      NUM(0);
      print inflect "There PL(was) NO(choice)";

produces "There were no choices", whereas:

      classical 'zero';     # or: classical(zero=>1);
      NUM(0);
      print inflect "There PL(was) NO(choice)";

it will print "There was no choice".


=head2 Homographs with heterogeneous plurals

Another context in which intent (and not content) sometimes determines
plurality is where two distinct meanings of a word require different
plurals. For example:

      Three basses were stolen from the band's equipment trailer.
      Three bass were stolen from the band's aquarium.

      I put the mice next to the cheese.
      I put the mouses next to the computers.

      Several thoughts about leaving crossed my mind.
      Several thought about leaving across my lawn.

Lingua::EN::Inflect handles such words in two ways:

=over 8

=item *

If both meanings of the word are the I<same> part of speech (for
example, "bass" is a noun in both sentences above), then one meaning
is chosen as the "usual" meaning, and only that meaning's plural is
ever returned by any of the inflection subroutines.

=item *

If each meaning of the word is a different part of speech (for
example, "thought" is both a noun and a verb), then the noun's
plural is returned by C<PL()> and C<PL_N()> and the verb's plural is
returned only by C<PL_V()>.

=back

Such contexts are, fortunately, uncommon (particularly
"same-part-of-speech" examples). An informal study of nearly 600
"difficult plurals" indicates that C<PL()> can be relied upon to "get
it right" about 98% of the time (although, of course, ichthyophilic
guitarists or cyber-behaviouralists may experience higher rates of
confusion).

If the choice of a particular "usual inflection" is considered
inappropriate, it can always be reversed with a preliminary call
to the corresponding C<def_...> subroutine.

=head1 NOTE

I'm not taking any further correspondence on:

=over

=item "octopi".

Despite the populist pandering of certain New World dictionaries, the
plural is "octopuses" or (for the pedantic classicist) "octopodes". The
suffix "-pus" is Greek, not Latin, so the plural is "-podes", not "pi".


=item "virus".

Had no plural in Latin (possibly because it was a mass noun).
The only plural is the Anglicized "viruses".

=back

=head1 AUTHOR

Damian Conway (damian@conway.org)


=head1 BUGS AND IRRITATIONS

The endless inconsistencies of English.

(I<Please> report words for which the correct plural or
indefinite article is not formed, so that the reliability
of Lingua::EN::Inflect can be improved.)



=head1 COPYRIGHT

 Copyright (c) 1997-2009, Damian Conway. All Rights Reserved.
 This module is free software. It may be used, redistributed
     and/or modified under the same terms as Perl itself.