I am a complete beginner to NLP and NLTK.
I was not able to understand the exact difference between lemmas and synsets in wordnet, because both are producing nearly the same output. for example for the word cake it produce this output.
lemmas : [Lemma('cake.n.01.cake'), Lemma('patty.n.01.cake'), Lemma('cake.n.03.cake'), Lemma('coat.v.03.cake')]
synsets : [Synset('cake.n.01'), Synset('patty.n.01'), Synset('cake.n.03'), Synset('coat.v.03')]
please help me to understand this concept.
Thank you.
The terms are based on the general sense of the words "lemma" and "synonym".
A lemma is wordnet's version of an entry in a dictionary: A word in canonical form, with a single meaning. E.g., if you wanted to look up "banks" in the dictionary, the canonical form would be "bank" and there would be separate lemmas for the nouns meaning "financial institution" and "side of the river", a separate one for the verb "to bank (on)", etc.
The term synset stands for "set of synonyms". A set of synonyms is a set of words with similar meaning, e.g. ship, skiff, canoe, kayak might all be synonyms for boat. In the nltk, a synset
is in fact a set of lemmas with related meaning. Taking your example (the results of wn.synsets("cake")
and wn.lemmas("cake")
), we can also write:
>>> synsets[0]
Synset('cake.n.01')
>>> synsets[0].lemmas()
[Lemma('cake.n.01.cake'), Lemma('cake.n.01.bar')]
These are the lemmas making up the first synset given for "cake".
Wordnet provides a lot of methods that allow you to explore relationships like hypernyms/hyponyms, usage domains, and more. For more information, you should look directly in the Wordnet documentation; the nltk just provides an interface for it. Here is the Wordnet glossary.