[PYTHON] Conversion between singular and plural of words

inflection is convenient

install

pip install inflection

How to use

import inflection as i


print("pluralize", i.pluralize("dog"))
print("singularize", i.singularize("dogs"))

# pluralize dogs
# singularize dog

Usage example

When you want to create something like a class name from a plural table name

print(i.camelize(i.singularize("cats")))
# Cat

Recommended Posts

Conversion between singular and plural of words
Conversion between unixtime and datetime
[Python] Summary of conversion between character strings and numerical values (ascii code)
Mutual conversion between Qiita articles and Jupyter notebook
Relationship between Firestore and Go data type conversion
Conversion between Julian day and Gregorian calendar date
Summary of the differences between PHP and Python
The answer of "1/2" is different between python2 and 3
[Python] Conversion memo between time data and numerical data
Mutual conversion between fixed point and binary numbers
I tried morphological analysis and vectorization of words
Consideration of the difference between ROC curve and PR curve
Proposal of multi-speaker voice conversion and voice morphing by RelGAN-VM
Difference between Ruby and Python in terms of variables
Indent behavior of json.dumps is different between python2 and python3
Mutual conversion between JSON and YAML / TOML in Python
Visualization of the connection between malware and the callback server
Between parametric and nonparametric
Hexadecimal string and string conversion
[python] plot the values ​​before and after the conversion of yeojohnson conversion
Relationship between Bound / Unbound and initial value of Django2 Form
Summary of Differences Between Ruby on Rails and Django ~ Basics ~