It's great to have a pluralization capability, but what about singularization?
Sometimes code must pluralize nouns that may already be in plural form. It is more resilient to first singularize it before pluralization. My use-case is that my code pulls nouns from database schema schema objects (table names) that may use plural names, or singular, or a combination of both. My code cannot be opinionated about how the user names their tables.
I guess another approach would be to have an isPlural function to detect whether the noun is already plural.
But then there is also the case where the existing plural form may not be the best or most common, and the process of singularization before pluralization could "clean it up" (e.g. "Gymnasia" -> "Gymnasium" -> "Gymnasiums").
It's great to have a pluralization capability, but what about singularization?
Sometimes code must pluralize nouns that may already be in plural form. It is more resilient to first singularize it before pluralization. My use-case is that my code pulls nouns from database schema schema objects (table names) that may use plural names, or singular, or a combination of both. My code cannot be opinionated about how the user names their tables.
I guess another approach would be to have an isPlural function to detect whether the noun is already plural.
But then there is also the case where the existing plural form may not be the best or most common, and the process of singularization before pluralization could "clean it up" (e.g. "Gymnasia" -> "Gymnasium" -> "Gymnasiums").