atteo / evo-inflector Goto Github PK
View Code? Open in Web Editor NEWSingular to plural english word converter
License: Apache License 2.0
Singular to plural english word converter
License: Apache License 2.0
Why not?
Capability to check if word is singular or plural
assertTrue(English.isSingular("word"));
assertFalse(English.isPlural("word"));
assertFalse(English.isSingular("words"));
assertTrue(English.isPlural("words"));
Would be interesting to have the capability to transform plurals to singular:
System.out.println(English.singular("words")); // == "word"
System.out.println(English.singular("words", 1)); // == "word"
System.out.println(English.singular("words", 2)); // == "words"
Thank you for working on this challenging problem! I found some uppercase words that are pluralized to lowercase. Instead, I expect a singular like "Foot" would pluralize to "Feet" and not to "feet". Here is a table of some words that preserve case and others that do not.
Singular | Plural | Preserved |
---|---|---|
Axis | Axes | yes |
Child | Children | yes |
Foot | feet | no |
Goose | geese | no |
Leaf | Leaves | yes |
Man | men | no |
Mouse | Mice | yes |
Tooth | teeth | no |
Wife | Wives | yes |
To demonstrate, I have attached a small tar-ball containing a command line program to invoke org.atteo.evo.inflector.English.plural("arg")
for arbitrary arguments (words): evo-inflector-main.tar.gz
The latest release is more than two years old and a couple of fixes have piled up but can't be used as there's no official release containing those.
assertThat(English.plural("todo"), is("todos"));
This one fails as the value returned is todoes
.
It could be great to have this as an online tool!
Version 1.1 is compiled against Java 7, but after a quick look at the source code I don't think this is necessary.
I'm using 1.0.1 in a project that must be able to run on Java 6, so I'm not able to upgrade.
I am thinking about using this to a project of mine. Should I consider it as a viable option?
Hi,
if I call English.plural("")
I get "s". This maybe is related to this line:
categoryRule(CATEGORY_MAN_MANS, "", "s");
BR,
Kai
What do you say? Is it easy to do?
Thanks!
First off, thank you for this rather handy little library, it's made my code much prettier. I use evo-infector, and other similar libraries, with a ternary operator . A common use case might be:
String comments = (amount == 1) ? "comment" : English.plural("comment");
With evo-inflector, I created a helper overloaded method which neatens up my application code::
public plural(String word, int n) {
return (n == 1) ? word : inflector.getPlural("comment");
}
...
String.format("%d %s commented.", amount, plural("person", amount));
Is this something that could be added to evo-inflector? I've added the method on my local copy so I will be happy to send a pull request if that makes it easier.
What license is evo-inflector?
Can we have a license file / declaration somewhere prominent?
The plural form for word "is" is "ises" instead of "are".
If the input is plural already, it fails to recognize it and returns a wrong word. Example for "Client" it returns "Clients" but for "Clients" it returns "Clientses".
this library is almost what I need although I wish it could also return the singular versions of plural words. Shouldn't be too hard. I did find an issue though. When passed a word that is already plural, it tries to pluralize it instead of just returning the same string. This is a problem as I'm handling user input and will have no idea if the users have typed in singular or plural to start with.
Ideally I'd want a method that returns a plural if a singular has been input and a singular if a plural has been input.
btw, on the atteo.org page the xml block for maven needs editing, groupid should have an uppercase 'I'. it will cause maven to fail.
The call English.plural("loaf")
returns the String loafs
. It should be loaves
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.