@@ -14,83 +14,41 @@ class Inflectible
1414 /** @return iterable<Transformation> */
1515 public static function getSingular (): iterable
1616 {
17- // Reverse of -sce → -scia (fasce → fascia)
18- yield new Transformation (new Pattern ('([aeiou])sce$ ' ), '\\1scia ' );
17+ // Advanced ending rules
18+ yield new Transformation (new Pattern ('sce ' ), 'scia ' ); // fasce → fascia
19+ yield new Transformation (new Pattern ('sci$ ' ), 'scio ' ); // fasci → fascio
20+ yield new Transformation (new Pattern ('chi$ ' ), 'co ' ); // bachi → baco
21+ yield new Transformation (new Pattern ('che$ ' ), 'ca ' ); // fotografiche → fotografica
22+ yield new Transformation (new Pattern ('ghi$ ' ), 'go ' ); // laghi → lago
23+ yield new Transformation (new Pattern ('ghe$ ' ), 'ga ' ); // targhe → targa
24+ yield new Transformation (new Pattern ('esi$ ' ), 'ese ' ); // paesi → paese
25+ yield new Transformation (new Pattern ('ali$ ' ), 'ale ' ); // ministeriali → ministeriale
26+ yield new Transformation (new Pattern ('ari$ ' ), 'ario ' ); // questionari → questionario
27+ yield new Transformation (new Pattern ('eri$ ' ), 'ero ' ); // numeri → numero
28+ yield new Transformation (new Pattern ('li$ ' ), 'lio ' ); // cimeli → cimelio
1929
20- // Reverse of -cie → -cia (farmacia → farmacie)
21- yield new Transformation (new Pattern ('cie$ ' ), 'cia ' );
22-
23- // Reverse of -gie → -gia (bugia → bugie)
24- yield new Transformation (new Pattern ('gie$ ' ), 'gia ' );
25-
26- // Reverse of -ce → -cia (arance → arancia)
27- yield new Transformation (new Pattern ('([aeiou])ce$ ' ), '\1cia ' );
28-
29- // Reverse of -ge → -gia (valige → valigia)
30- yield new Transformation (new Pattern ('([aeiou])ge$ ' ), '\1gia ' );
31-
32- // Reverse of -chi → -co (bachi → baco)
33- yield new Transformation (new Pattern ('([bcdfghjklmnpqrstvwxyz][aeiou])chi$ ' ), '\1co ' );
34-
35- // Reverse of -chi → -co (fotografiche → fotografica)
36- yield new Transformation (new Pattern ('([bcdfghjklmnpqrstvwxyz][aeiou])che$ ' ), '\1ca ' );
37-
38- // Reverse of -ghi → -go (laghi → lago)
39- yield new Transformation (new Pattern ('([bcdfghjklmnpqrstvwxyz][aeiou])ghi$ ' ), '\1go ' );
40-
41- // Reverse of -ci → -co (medici → medico)
42- yield new Transformation (new Pattern ('([aeiou][bcdfghjklmnpqrstvwxyz])ci$ ' ), '\1o ' );
43-
44- // Reverse of -i → -io (zii → zio, negozi → negozio)
45- // This is more complex due to Italian's stress patterns, but we'll handle the basic case
46- yield new Transformation (new Pattern ('([aeiou])i$ ' ), '\1io ' );
47-
48- // Handle words that end with -i but should go to -co/-go (amici → amico, not amice)
49- yield new Transformation (new Pattern ('([cgmrt])i$ ' ), '\1o ' );
50-
51- // Reverse of -a → -e
52- yield new Transformation (new Pattern ('e$ ' ), 'a ' );
53-
54- // Reverse of -e → -i
55- yield new Transformation (new Pattern ('i$ ' ), 'e ' );
56-
57- // Reverse of -o → -i
58- yield new Transformation (new Pattern ('i$ ' ), 'o ' );
30+ // Standard ending rules
31+ yield new Transformation (new Pattern ('e$ ' ), 'a ' ); // case → casa
32+ yield new Transformation (new Pattern ('i$ ' ), 'o ' ); // libri → libro
33+ yield new Transformation (new Pattern ('i$ ' ), 'e ' ); // studenti → studente
5934 }
6035
6136 /** @return iterable<Transformation> */
6237 public static function getPlural (): iterable
6338 {
64- // Words ending in -scia without stress on 'i' become -sce (e.g. fascia → fasce)
65- yield new Transformation (new Pattern ('([aeiou])scia$ ' ), '\\1sce ' );
66-
67- // Words ending in -cia/gia with stress on 'i' keep the 'i' in plural
68- yield new Transformation (new Pattern ('cia$ ' ), 'cie ' ); // e.g. farmacia → farmacie
69- yield new Transformation (new Pattern ('gia$ ' ), 'gie ' ); // e.g. bugia → bugie
70-
71- // Words ending in -cia/gia without stress on 'i' lose the 'i' in plural
72- yield new Transformation (new Pattern ('([aeiou])cia$ ' ), '\\1ce ' ); // e.g. arancia → arance
73- yield new Transformation (new Pattern ('([aeiou])gia$ ' ), '\\1ge ' ); // e.g. valigia → valige
74-
75- // Words ending in -co/-go with stress on 'o' become -chi/-ghi
76- yield new Transformation (new Pattern ('([bcdfghjklmnpqrstvwxyz][aeiou])co$ ' ), '\\1chi ' ); // e.g. baco → bachi
77- yield new Transformation (new Pattern ('([bcdfghjklmnpqrstvwxyz][aeiou])ca$ ' ), '\\1che ' ); // e.g. fotografica → fotografiche
78- yield new Transformation (new Pattern ('([bcdfghjklmnpqrstvwxyz][aeiou])go$ ' ), '\\1ghi ' ); // e.g. lago → laghi
79-
80- // Words ending in -co/-go with stress on the penultimate syllable become -ci/-gi
81- yield new Transformation (new Pattern ('([aeiou][bcdfghjklmnpqrstvwxyz])co$ ' ), '\\1ci ' ); // e.g. medico → medici
82- yield new Transformation (new Pattern ('([aeiou][bcdfghjklmnpqrstvwxyz])go$ ' ), '\\1gi ' ); // e.g. psicologo → psicologi
83-
84- // Words ending in -io with stress on 'i' keep the 'i' in plural
85- yield new Transformation (new Pattern ('([aeiou])io$ ' ), '\\1i ' ); // e.g. zio → zii
86-
87- // Words ending in -io with stress on 'o' lose the 'i' in plural
88- yield new Transformation (new Pattern ('([aeiou])io$ ' ), '\\1i ' ); // e.g. negozio → negozi
39+ // Advanced ending rules
40+ yield new Transformation (new Pattern ('scia$ ' ), 'sce ' ); // fascia → fasce
41+ yield new Transformation (new Pattern ('scio$ ' ), 'sci ' ); // fascio → fasci
42+ yield new Transformation (new Pattern ('co$ ' ), 'chi ' ); // baco → bachi
43+ yield new Transformation (new Pattern ('ca$ ' ), 'che ' ); // fotografica → fotografiche
44+ yield new Transformation (new Pattern ('go$ ' ), 'ghi ' ); // lago → laghi
45+ yield new Transformation (new Pattern ('ga$ ' ), 'ghe ' ); // targa → targhe
46+ yield new Transformation (new Pattern ('io$ ' ), 'i ' ); // cimelio → cimeli
8947
9048 // Standard ending rules
91- yield new Transformation (new Pattern ('a$ ' ), 'e ' ); // -a → -e
92- yield new Transformation (new Pattern ('e $ ' ), 'i ' ); // -e → -i
93- yield new Transformation (new Pattern ('o $ ' ), 'i ' ); // -o → -i
49+ yield new Transformation (new Pattern ('a$ ' ), 'e ' ); // casa → case
50+ yield new Transformation (new Pattern ('o $ ' ), 'i ' ); // libro → libri
51+ yield new Transformation (new Pattern ('e $ ' ), 'i ' ); // studente → studenti
9452 }
9553
9654 /** @return iterable<Substitution> */
@@ -118,6 +76,7 @@ public static function getIrregular(): iterable
11876 'capitale ' => 'capitali ' ,
11977 'carcere ' => 'carceri ' ,
12078 'casa ' => 'case ' ,
79+ 'cassaforte ' => 'casseforti ' ,
12180 'cavaliere ' => 'cavalieri ' ,
12281 'centinaio ' => 'centinaia ' ,
12382 'cerchio ' => 'cerchia ' ,
@@ -134,6 +93,7 @@ public static function getIrregular(): iterable
13493 'dito ' => 'dita ' ,
13594 'dottore ' => 'dottori ' ,
13695 'fiore ' => 'fiori ' ,
96+ 'forte ' => 'forti ' ,
13797 'fratello ' => 'fratelli ' ,
13898 'fuoco ' => 'fuochi ' ,
13999 'gamba ' => 'gambe ' ,
0 commit comments