Pluralize and ‘Singularize’ Any (English) Word
Tools are provided to create plural, singular and regular forms of English words along with tools to augment the built-in rules to fit specializied needs. Core functionality is based on a JavaScript library, https://github.com/blakeembrey/pluralize.
The following functions are implemented:
add_irregular_rule
: Add a custom rule for making “deregularizing”
a wordadd_plural_rule
: Add a custom rule for making a word pluraladd_singular_rule
: Add a custom rule for making a word singularadd_uncountable_rule
: Make a word “uncountable”is_plural
: Test plural state of a wordpluralize
: Pluralize a wordsingularize
: Singularize a wordremotes::install_gitlab("hrbrmstr/pluralize")
# or
remotes::install_github("hrbrmstr/pluralize")
NOTE: To use the ‘remotes’ install options you will need to have the {remotes} package installed.
library(pluralize)
# current version
packageVersion("pluralize")
## [1] '0.2.0'
pluralize('test')
## [1] "tests"
singularize('test')
## [1] "test"
singularize(c("boats", "houses", "cats", "rivers"))
## [1] "boat" "house" "cat" "river"
pluralize(singularize(c("boats", "houses", "cats", "rivers")))
## [1] "boats" "houses" "cats" "rivers"
singularize(c("buses", "wishes", "pitches", "boxexs"))
## [1] "bus" "wish" "pitch" "boxex"
pluralize(singularize(c("buses", "wishes", "pitches", "boxexs")))
## [1] "buses" "wishes" "pitches" "boxexes"
singularize(c("pennies", "spies", "babies", "cities", "daisies"))
## [1] "penny" "spy" "baby" "city" "daisie"
pluralize(singularize(c("pennies", "spies", "babies", "cities", "daisies")))
## [1] "pennies" "spies" "babies" "cities" "daisies"
singularize(c("sheep", "fish", "deer", "species", "aircraft"))
## [1] "sheep" "fish" "deer" "specie" "aircraft"
pluralize(singularize(c("sheep", "fish", "deer", "species", "aircraft")))
## [1] "sheep" "fish" "deer" "species" "aircraft"
pluralize('test', 5)
## [1] "tests"
pluralize('test', 5, TRUE)
## [1] "5 tests"
pluralize('regex')
## [1] "regexes"
add_plural_rule("gex", "gexii")
pluralize('regex')
## [1] "regexii"
singularize('singles')
## [1] "single"
add_singular_rule("singles", "singular")
singularize('singles')
## [1] "singular"
pluralize("irregular")
## [1] "irregulars"
pluralize(c("woman", "man", "child", "tooth", "foot", "person", "leaf"))
## [1] "women" "men" "children" "teeth" "feet" "people" "leaves"
singularize(c("woman", "man", "child", "tooth", "foot", "person", "leaf"))
## [1] "woman" "man" "child" "tooth" "foot" "person" "leaf"
add_irregular_rule("irregular", "regular")
pluralize("irregular")
## [1] "regular"
pluralize("paper")
## [1] "papers"
add_uncountable_rule("paper")
pluralize("paper")
## [1] "paper"
| Lang | # Files | (%) | LoC | (%) | Blank lines | (%) | # Lines | (%) | | :--- | -------: | --: | --: | ---: | ----------: | ---: | -------: | ---: | | HTML | 1 | 0.1 | 367 | 0.79 | 33 | 0.28 | 2 | 0.01 | | Rmd | 2 | 0.2 | 58 | 0.12 | 72 | 0.61 | 71 | 0.39 | | R | 7 | 0.7 | 40 | 0.09 | 13 | 0.11 | 108 | 0.60 |
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.