flexmeasures.utils.flexmeasures_inflection

FlexMeasures way of handling inflection

Functions

flexmeasures.utils.flexmeasures_inflection.capitalize(x: str, lower_case_remainder: bool = False) str

Capitalize string with control over whether to lower case the remainder.

flexmeasures.utils.flexmeasures_inflection.humanize(word)
flexmeasures.utils.flexmeasures_inflection.join_words_into_a_list(words: list[str]) str
flexmeasures.utils.flexmeasures_inflection.parameterize(word)

Parameterize the word, so it can be used as a python or javascript variable name. For example: >>> word = “Acme® EV-Charger™” “acme_ev_chargertm”

flexmeasures.utils.flexmeasures_inflection.pluralize(word, count: str | int | None = None)
flexmeasures.utils.flexmeasures_inflection.titleize(word)

Acronym exceptions are not yet supported by the inflection package, even though Ruby on Rails, of which the package is a port, does.

In most cases it’s probably better to use our capitalize function instead of titleize, because it has less unintended side effects. For example:

>>> word = "two PV panels"
>>> titleize(word)
"Two Pv Panels"
>>> capitalize(word)
"Two PV panels"