I'm using SimpleNLG 4.4.2
to get plural form for a noun:
final XMLLexicon xmlLexicon = new XMLLexicon();
final WordElement word = xmlLexicon.getWord("apple", LexicalCategory.NOUN);
System.out.println(word);
System.out.println(word.getFeature(LexicalFeature.PLURAL));
However even for this simple example, getFeature
returns null
instead of apples
. What am I doing wrong?
There are many rules to form plural nouns. The general rule in English to form plurals is to add an -s. To make the plurals of nouns ending in -s, -x, -sh, -ch, -ss or -z, add an -es. Some nouns ending in -s or -z are made plural by the -s or -z being doubled prior to adding the -es.
To make plurals of nouns ending in the letter -f or -fe, change -f and -fe to -v and add an -es. There are a few exceptions to this rule. The nouns ending in an -ff take an -s in the plural form. The nouns ending in -ief, -oof, eef, ff, or -rf generally take -s to form plurals.
For many nouns, to form the plural, just add the suffix ‘-s’ to the noun. For example: Or, if the word ends with –ss, -x, -ch, or –sh, add the suffix ‘-es’. For example: The next plural rule is that if the noun ends with ‘-y’ and is preceded by a consonant, you add ‘-es’ suffix and change the ‘-y’ to an ‘-i’.
In this case, to change the noun from singular to plural, you just add an ‘-s’. However, that isn’t the rule for every noun. We’ll look in more detail at the different plural rules for nouns below. The first rule is the simplest one and follows the same pattern as the piano – pianos example we listed above.
Thanks for making me aware of this library! Based on the comment from biziclop, I came up with this solution:
final XMLLexicon xmlLexicon = new XMLLexicon();
final WordElement word = xmlLexicon.getWord("apple", LexicalCategory.NOUN);
final InflectedWordElement pluralWord = new InflectedWordElement(word);
pluralWord.setPlural(true);
final Realiser realiser = new Realiser(xmlLexicon);
System.out.println(realiser.realise(pluralWord));
which outputs:
apples
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With