Skip to content

david-w-millar/groovy-pluralize-en

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Groovy Pluralize Module

Build Status Maven Coordinates

A lightweight Groovy extension module that adds the functionality to get plural inflections for words. Suitable for most English applications.

For more robust needs, checkout IBM’s more comprehensive and feature rich International Components for Unicode library.

Installation

Include the jar is in your classpath, or add it as a dependency to your favorite build tool. Groovy does the rest.

Note
Requires groovy 2.0 or later.
Gradle and Grails
compile 'org.millarts:groovy-pluralize-en:0.2.1'
Groovy Grape
@Grapes(
  @Grab(group='org.millarts', module='groovy-pluralize-en', version='0.2.1')
)
Maven
<dependency>
  <groupId>org.millarts</groupId>
  <artifactId>groovy-pluralize-en</artifactId>
  <version>0.2.1</version>
</dependency>

Usage

Example Usages
// Plural Inflection
assert 'mustache'.plural() == 'mustaches'
assert 'wolf'.plural()     == 'wolves'

// Plural Inflection with Cardinality
assert 'codex'.plural(1) == 'codex'
assert 'codex'.plural(2) == 'codices'
assert 'codex'.plural(8) == 'codices'

// Capitalization
assert 'Life'.plural() == 'Lives'

// Unfortunately, capitalization does not behave consistently for certain words. EG:
assert 'Tooth'.plural() == 'teeth'

Building

This project uses gradle for builds, and includes wrapper scripts so that it is not necessary to explicitly install gradle to build and test the project.

Gradle Examples
$ ./gradlew tasks   (1)
$ ./gradlew jar     (2)
$ ./gradlew test    (3)
$ ./gradlew check   (4)
  1. Lists the available tasks for this project

  2. Builds the jar

  3. Runs tests

  4. Runs tests and checks (eg: code quality checks)

Under the Hood

This module uses the evo-inflector project under the hood, which is based off of Damian Conway’s paper An Algorithmic Approach to English Pluralization. It tends to get things right. See the evo-inflector project for more information.

License

This project is licensed under the terms of the Apache License, Version 2.0.

© 2014 David W Millar

About

Groovy extension module - helps pluralize words fairly accurately

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages