api.py 752 B

123456789101112131415161718192021222324252627282930
  1. # Natural Language Toolkit: Stemmer Interface
  2. #
  3. # Copyright (C) 2001-2019 NLTK Project
  4. # Author: Trevor Cohn <tacohn@cs.mu.oz.au>
  5. # Edward Loper <edloper@gmail.com>
  6. # Steven Bird <stevenbird1@gmail.com>
  7. # URL: <http://nltk.org/>
  8. # For license information, see LICENSE.TXT
  9. from abc import ABCMeta, abstractmethod
  10. from six import add_metaclass
  11. @add_metaclass(ABCMeta)
  12. class StemmerI(object):
  13. """
  14. A processing interface for removing morphological affixes from
  15. words. This process is known as stemming.
  16. """
  17. @abstractmethod
  18. def stem(self, token):
  19. """
  20. Strip affixes from the token and return the stem.
  21. :param token: The token that should be stemmed.
  22. :type token: str
  23. """