Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SimpleNLG - How to get the plural of a noun?

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?

like image 902
Fluffy Avatar asked Oct 28 '15 10:10

Fluffy


People also ask

What are the rules for plural nouns?

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.

How do you make plural nouns end in s?

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.

How do you make a word plural in a sentence?

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’.

How do you change a noun from singular to plural?

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.


1 Answers

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
like image 50
Ken Geis Avatar answered Oct 16 '22 19:10

Ken Geis