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

Module stemmer

source code

Functions [hide private]
 
morphy(form, pos='noun')
Identify the base forms for a given word-form with a given POS.
source code
 
_morphy(form, pos='noun') source code
 
p(word) source code
 
demo() source code
Variables [hide private]
  MORPHOLOGICAL_SUBSTITUTIONS = {'adj': [('er', ''), ('est', '')...
  abbreviations = 'adverb adv adv. r'
  pos = 'adv'
  token = 'r'
  tokens = ['adverb', 'adv', 'adv.', 'r']
Function Details [hide private]

morphy(form, pos='noun')

source code 

Identify the base forms for a given word-form with a given POS. First it checks if the word is found in the exception list for this POS. If so, it identifies all the exception's base forms. Next it recurses with the word-form and a list of suffix substitutions for that POS. For every (old,new) pair of strings in the substitution list, if the form ends with old, a new form is created by replacing old with new and doing a recursive call.

>>> morphy('dogs')
'dog'
>>> morphy('churches')
'church'
>>> morphy('aardwolves')
'aardwolf'
>>> morphy('abaci')
'abacus'
>>> morphy('hardrock', ADVERB)

Variables Details [hide private]

MORPHOLOGICAL_SUBSTITUTIONS

Value:
{'adj': [('er', ''), ('est', ''), ('er', 'e'), ('est', 'e')],
 'adv': [],
 'noun': [('s', ''),
          ('ses', 's'),
          ('ves', 'f'),
          ('xes', 'x'),
          ('zes', 'z'),
          ('ches', 'ch'),
...