How could I use NLTK module to write both the noun's singular and plural form, or tell it not to differentiate between singular and plural when searching a txt file for a word? Can I use NLTK to make the program case insensitive?
To convert plural to single just import singular module and use singular() function. It handles proper conversions for words with different endings, irregular forms, etc.
1 To make regular nouns plural, add –s to the end. 2 If the singular noun ends in –s, –ss, –sh, –ch, –x, or –z, add -es to the end to make it plural.
The plural form of python is pythons. Find more words!
How do you recognise a singular or plural verb? A singular verb is one that has an s added to it in the present tense, such as writes, plays, runs, and uses forms such as is, was, has, does. A plural verb does not have an s added to it, such as write, play, run, and uses forms such as are, were, have and do.
You can do this by using pattern.en
, not too sure about NLTK
>>> from pattern.en import pluralize, singularize
>>>
>>> print pluralize('child') #children
>>> print singularize('wolves') #wolf
see more
It might be a bit late to answer but just in case someone is still looking for something similar:
There's inflect (also available in github) which support python 2.x and 3.x. You can find the singular or plural form of a given word:
import inflect
p = inflect.engine()
words = "cat dog child goose pants"
print([p.plural(word) for word in words.split(' ')])
# ['cats', 'dogs', 'children', 'geese', 'pant']
Is worth noticing that p.plural
of a plural will give you the singular
form.
In addition, you can provide a POS (Part Of Speech) tag or to provide a number and the lib determines if it needs to be plural or singular:
p.plural('cat', 4) # cats
p.plural('cat', 1) # cat
# but also...
p.plural('cat', 0) # cats
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