Package nltk :: Package stem :: Module wordnet
[hide private]
[frames] | no frames]

Source Code for Module nltk.stem.wordnet

 1  # Natural Language Toolkit: Wordnet stemmer interface 
 2  # 
 3  # Copyright (C) 2001-2008 NLTK Project 
 4  # Author: Steven Bird <[email protected]> 
 5  #         Edward Loper <[email protected]> 
 6  # URL: <http://nltk.org> 
 7  # For license information, see LICENSE.TXT 
 8   
 9  from nltk.wordnet import morphy 
10   
11  from api import * 
12   
13 -class WordnetStemmer(StemmerI):
14 """ 15 A stemmer that uses Wordnet's built-in morphy function. 16 """
17 - def __init__(self):
18 """ 19 Create a new wordnet stemmer. 20 """ 21 pass
22
23 - def stem(self, word):
24 return morphy(word)
25
26 - def __repr__(self):
27 return '<WordnetStemmer>'
28 29 if __name__ == '__main__': 30 from nltk import stem 31 stemmer = stem.WordnetStemmer() 32 print 'dogs ->', stemmer.stem('dogs') 33 print 'churches ->', stemmer.stem('churches') 34 print 'aardwolves ->', stemmer.stem('aardwolves') 35 print 'abaci ->', stemmer.stem('abaci') 36 print 'hardrock ->', stemmer.stem('hardrock') 37