# Inflector for Python
The Inflector is used for getting the plural and singular form of nouns. This piece of code helps on creating code that favors convention over configuration.
Only English and Spanish nouns are supported. The English version is a port of Ruby on Rails Inflector, while the Spanish Version has been developed from scratch with the help of Carles SadurnĂ.
Apart from converting singulars and plurals, this module also handles necessary string conversion for convention based applications like:
Available methods are:
## pluralize(word)
Pluralizes nouns.
## singularize(word)
Singularizes nouns.
## conditionalPlural(numer_of_records, word)
Returns the plural form of a word if first parameter is greater than 1
## titleize(word, uppercase = '')
Converts an underscored or CamelCase word into a sentence.
The titleize function converts text like "WelcomePage",
"welcome_page" or "welcome page" to this "Welcome Page".
If the "uppercase" parameter is set to 'first' it will only
capitalize the first character of the title.
## camelize(word):
Returns given word as CamelCased
Converts a word like "send_email" to "SendEmail". It
will remove non alphanumeric character from the word, so
"who's online" will be converted to "WhoSOnline"
## underscore(word)
Converts a word "into_it_s_underscored_version"
Convert any "CamelCased" or "ordinary Word" into an
"underscored_word".
This can be really useful for creating friendly URLs.
## humanize(word, uppercase = '')
Returns a human-readable string from word
Returns a human-readable string from word, by replacing
underscores with a space, and by upper-casing the initial
character by default.
If you need to uppercase all the words you just have to
pass 'all' as a second parameter.
## variablize(word)
Same as camelize but first char is lowercased
Converts a word like "send_email" to "sendEmail". It
will remove non alphanumeric character from the word, so
"who's online" will be converted to "whoSOnline"
return self.Inflector.variablize(word)
## tableize(class_name)
Converts a class name to its table name according to rails
naming conventions. Example. Converts "Person" to "people"
## classify(table_name)
Converts a table name to its class name according to rails
naming conventions. Example: Converts "people" to "Person"
## ordinalize(number)
Converts number to its ordinal form.
This method converts 13 to 13th, 2 to 2nd ...
## unaccent(text)
Transforms a string to its unaccented version.
This might be useful for generating "friendly" URLs
## urlize(text)
Transform a string its unaccented and underscored
version ready to be inserted in friendly URLs
## foreignKey(class_name, separate_class_name_and_id_with_underscore = 1)
Returns class_name in underscored form, with "_id" tacked on at the end.
This is for use in dealing with the database.
Raw data
{
"_id": null,
"home_page": "https://github.com/ixmatus/inflector",
"name": "Inflector",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "inflector text language english",
"author": "Parnell Springmeyer",
"author_email": "parnell@digitalmentat.com",
"download_url": "https://files.pythonhosted.org/packages/45/be/21de73919b8c34ffaee6ba3bd3e3bd9b83f684b1ae89db3d3c756daa6c35/Inflector-3.1.1.tar.gz",
"platform": null,
"description": "# Inflector for Python\n\nThe Inflector is used for getting the plural and singular form of nouns. This piece of code helps on creating code that favors convention over configuration.\n\nOnly English and Spanish nouns are supported. The English version is a port of Ruby on Rails Inflector, while the Spanish Version has been developed from scratch with the help of Carles Sadurn\u00ed.\n\nApart from converting singulars and plurals, this module also handles necessary string conversion for convention based applications like:\n\nAvailable methods are:\n\n## pluralize(word)\n\nPluralizes nouns.\n\n## singularize(word)\n\nSingularizes nouns.\n\n## conditionalPlural(numer_of_records, word)\n\nReturns the plural form of a word if first parameter is greater than 1\n\n## titleize(word, uppercase = '')\n\nConverts an underscored or CamelCase word into a sentence.\nThe titleize function converts text like \"WelcomePage\",\n\"welcome_page\" or \"welcome page\" to this \"Welcome Page\".\nIf the \"uppercase\" parameter is set to 'first' it will only\ncapitalize the first character of the title.\n\n## camelize(word):\n\nReturns given word as CamelCased\nConverts a word like \"send_email\" to \"SendEmail\". It\nwill remove non alphanumeric character from the word, so\n\"who's online\" will be converted to \"WhoSOnline\"\n\n## underscore(word)\n\nConverts a word \"into_it_s_underscored_version\"\nConvert any \"CamelCased\" or \"ordinary Word\" into an\n\"underscored_word\".\nThis can be really useful for creating friendly URLs.\n\n## humanize(word, uppercase = '')\n\nReturns a human-readable string from word\nReturns a human-readable string from word, by replacing\nunderscores with a space, and by upper-casing the initial\ncharacter by default.\nIf you need to uppercase all the words you just have to\npass 'all' as a second parameter.\n\n\n## variablize(word)\n\nSame as camelize but first char is lowercased\nConverts a word like \"send_email\" to \"sendEmail\". It\nwill remove non alphanumeric character from the word, so\n\"who's online\" will be converted to \"whoSOnline\"\nreturn self.Inflector.variablize(word)\n\n## tableize(class_name)\n\nConverts a class name to its table name according to rails\nnaming conventions. Example. Converts \"Person\" to \"people\" \n\n## classify(table_name)\n\nConverts a table name to its class name according to rails\nnaming conventions. Example: Converts \"people\" to \"Person\" \n\n## ordinalize(number)\nConverts number to its ordinal form.\nThis method converts 13 to 13th, 2 to 2nd ...\n\n## unaccent(text)\n\nTransforms a string to its unaccented version. \nThis might be useful for generating \"friendly\" URLs\n\n## urlize(text)\n\nTransform a string its unaccented and underscored\nversion ready to be inserted in friendly URLs\n\n## foreignKey(class_name, separate_class_name_and_id_with_underscore = 1)\n\nReturns class_name in underscored form, with \"_id\" tacked on at the end. \nThis is for use in dealing with the database.\n",
"bugtrack_url": null,
"license": "",
"summary": "Inflector for Python",
"version": "3.1.1",
"project_urls": {
"Homepage": "https://github.com/ixmatus/inflector"
},
"split_keywords": [
"inflector",
"text",
"language",
"english"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "efd4e4f0d1b76e04502b393f34191d8dedf48a2b48c784b9a41400ac466f7516",
"md5": "a5a2fa7281a0ac283e6c6a186afa9df6",
"sha256": "b158010b9c400382a9792dcaa05a02c198b27d17fb52a23262e8226c91b13c97"
},
"downloads": -1,
"filename": "Inflector-3.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "a5a2fa7281a0ac283e6c6a186afa9df6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 12986,
"upload_time": "2024-01-12T03:07:19",
"upload_time_iso_8601": "2024-01-12T03:07:19.143715Z",
"url": "https://files.pythonhosted.org/packages/ef/d4/e4f0d1b76e04502b393f34191d8dedf48a2b48c784b9a41400ac466f7516/Inflector-3.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "45be21de73919b8c34ffaee6ba3bd3e3bd9b83f684b1ae89db3d3c756daa6c35",
"md5": "d36b95ac755cdffa572699d6d8117677",
"sha256": "1835ccc74ea8b5bea93cee9f7802b5cbbaaa937e268a197a937394aa47dee6d5"
},
"downloads": -1,
"filename": "Inflector-3.1.1.tar.gz",
"has_sig": false,
"md5_digest": "d36b95ac755cdffa572699d6d8117677",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 10317,
"upload_time": "2024-01-12T03:07:20",
"upload_time_iso_8601": "2024-01-12T03:07:20.830958Z",
"url": "https://files.pythonhosted.org/packages/45/be/21de73919b8c34ffaee6ba3bd3e3bd9b83f684b1ae89db3d3c756daa6c35/Inflector-3.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-01-12 03:07:20",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "ixmatus",
"github_project": "inflector",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "inflector"
}