4

How can I get the lemma for a given word using Wordnet. I couldn't seem to find in the wordnet documentation what i want. http://wordnet.princeton.edu/wordnet/man/wn.1WN.html

For example for the word "books" i want to get "book" , ashes => ash , booking => book, apples => apple .... etc.

i want to achieve this using wordnet in command line and I cant find exact options to retrieve such case.

A php solution would also be of great help because I originally intend to use the wordnet php API but it seems the current one in their website isn't working.

ralpu
  • 193
  • 3
  • 15

4 Answers4

2

Morphy is a morphological processor native to WordNet. The WordNet interfaces invoke Morphy to lemmatize a word as part of the lookup process (e.g. you query "enlightened", it returns the results for both "enlightened" and, via Morphy, "enlighten").

The interfaces don't include a feature that allows a user to directly access Morphy, so using it in command line is only possible if you write your own program using one of the WordNet APIs. You can find documentation for Morphy at the WordNet site.

As near as I can tell, the PHP interface is still available, although you may need to use WordNet 2.x.

ibadibam
  • 169
  • 8
2

If you can use another tool try TreeTagger.

Aurelio De Rosa
  • 21,856
  • 8
  • 48
  • 71
  • http://stackoverflow.com/questions/15503388/treetagger-installation-successful-but-cannot-open-par-file – alvas Mar 19 '13 at 15:33
1

The WordNetLemmatizer in the nltk library will do what you need. here is python3 code:

#!Python3 -- this is lemmatize_s.py
import nltk
from nltk.stem import WordNetLemmatizer
from nltk.tokenize import word_tokenize
print ("This program will lemmatize your input until you ask for it to 'end'.")
while True:
    sentence = input("Type one or more words (or 'end') and press enter:")
    if (sentence == "end"):
        break
    tokens = word_tokenize(sentence)
    lemmatizer = WordNetLemmatizer()
    Output=[lemmatizer.lemmatize(word) for word in tokens]
    print (Output);

Running this from the command line:

eyeMac2016:james$ python3 lemmatize_s.py
This program will lemmatize your input until you ask for it to 'end'.
Type one or more words  (or 'end') and press enter:books ashes
['book', 'ash']
Type one or more words  (or 'end') and press enter:end
eyeMac2016:james$ 
harry
  • 340
  • 4
  • 13
1

I am not sure that WordNet implements it natively. NLTK has Morphy, which precisely does what you want, but it is implemented in Python though. You can write a small Python program to take input from the command line and return the lemma.

Search for 'Morphy' in the following link: http://nltk.googlecode.com/svn/trunk/doc/api/nltk.corpus.reader.wordnet.WordNetCorpusReader-class.html

nltk.WordNetLemmatizer() also does the job. Search for 'Lemmatization' in the following link: http://nltk.googlecode.com/svn/trunk/doc/book/ch03.html

NLTK website : http://www.nltk.org/

Neodawn
  • 1,086
  • 1
  • 6
  • 9