Closed synrg closed 4 years ago
See https://docs.python.org/3/library/stdtypes.html#str.format_map but also consider https://pypi.org/project/inflect/ which may be more intelligent.
Encouraging initial test results:
>>> import inflect
>>> p = inflect.engine()
>>> p.plural("genus",50)
'genera'
>>> p.plural("species",50)
'species'
>>> p.plural("Genus")
'Genera'
There are quite a number of other methods supported for various use cases that go even beyond my simple plans above for format strings. I think we can just use inflect
package instead of hand-coding something of our own.
We've used inflect for this purpose for a long time.
Given an input like
pluralize('genus', 2)
, output a string with plural ending applied, using the format string specified (or default as indicated), e.g. ->"2 genera"
in this case.num
orbool
, defaulting to TrueCapitialization, if provided, should be kept intact, e.g.
pluralize('Genus')
->"Genera"
.See https://github.com/synrg/quaggagriff/issues/42 which will need this formatter when describing the enumeration of child ranks, e.g.
->
"and 50 more species"
->
"and 1 more genus"
->
"and 2 more genera"