Pluralize

Pluralize and singularize any word.

Лицензия

Лицензия

Группа

Группа

io.github.encryptorcode
Идентификатор

Идентификатор

pluralize
Последняя версия

Последняя версия

1.0.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

Pluralize
Pluralize and singularize any word.
Ссылка на сайт

Ссылка на сайт

https://github.com/encryptorcode/pluralize
Система контроля версий

Система контроля версий

https://github.com/encryptorcode/pluralize/tree/master

Скачать pluralize

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.encryptorcode/pluralize/ -->
<dependency>
    <groupId>io.github.encryptorcode</groupId>
    <artifactId>pluralize</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.encryptorcode/pluralize/
implementation 'io.github.encryptorcode:pluralize:1.0.0'
// https://jarcasting.com/artifacts/io.github.encryptorcode/pluralize/
implementation ("io.github.encryptorcode:pluralize:1.0.0")
'io.github.encryptorcode:pluralize:jar:1.0.0'
<dependency org="io.github.encryptorcode" name="pluralize" rev="1.0.0">
  <artifact name="pluralize" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.encryptorcode', module='pluralize', version='1.0.0')
)
libraryDependencies += "io.github.encryptorcode" % "pluralize" % "1.0.0"
[io.github.encryptorcode/pluralize "1.0.0"]

Зависимости

test (2)

Идентификатор библиотеки Тип Версия
junit : junit jar 4.13
pl.pragmatists : JUnitParams jar 1.0.5

Модули Проекта

Данный проект не имеет модулей.

Pluralize

Maven Central Build Status Coverage Status GitHub license

Pluralize and singularize any word.

Installation

Maven

<dependency>
  <groupId>io.github.encryptorcode</groupId>
  <artifactId>pluralize</artifactId>
  <version>${pluralize.version}</version>
</dependency>

Why?

This module uses a pre-defined list of rules, applied in order, to singularize or pluralize a given word. There are many cases where this is useful, such as any automation based on user input. For applications where the word(s) are known ahead of time, you can use a simple ternary (or function) which would be a much lighter alternative.

Usage

  • word: string The word to pluralize
  • count: number How many of the word exist
  • inclusive: boolean Whether to prefix with the number (e.g. 3 ducks)

Examples:

import io.github.encryptorcode.pluralize.Pluralize;
import static io.github.encryptorcode.pluralize.Pluralize.*;

public class Example{
    public static void main(String[] args){
        pluralize("test"); //=> "tests"
        pluralize("test", 0); //=> "tests"
        pluralize("test", 1); //=> "test"
        pluralize("test", 5); //=> "tests"
        pluralize("test", 1, true); //=> "1 test"
        pluralize("test", 5, true); //=> "5 tests"
        pluralize("蘋果", 2, true); //=> "2 蘋果"

        // Example of new plural rule:
        Pluralize.plural("regex"); //=> "regexes"
        Pluralize.addPluralRule(p("gex$"), "gexii");
        Pluralize.plural("regex"); //=> "regexii"

        // Example of new singular rule:
        Pluralize.singular("singles"); //=> "single"
        Pluralize.addSingularRule(p("singles"), "singular");
        Pluralize.singular("singles"); //=> "singular"

        // Example of new irregular rule, e.g. "I" -> "we":
        Pluralize.plural("irregular"); //=> "irregulars"
        Pluralize.addIrregularRule("irregular", "regular");
        Pluralize.plural("irregular"); //=> "regular"

        // Example of uncountable rule (rules without singular/plural in context):
        Pluralize.plural("paper"); //=> "papers"
        Pluralize.addUncountableRule("paper");
        Pluralize.plural("paper"); //=> "paper"

        // Example of asking whether a word looks singular or plural:
        Pluralize.isPlural("test"); //=> false
        Pluralize.isSingular("test"); //=> true
    }
}

Credits

The actual javascript version of this library is maintained at blakeembrey/pluralize. I've only helped to translate the code to Java. Also, I assure to have the least deviations from the actual code written and maintained by @blakeembrey

License

MIT

io.github.encryptorcode

Encryptor Code

Версии библиотеки

Версия
1.0.0