Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

nltk
stem.util module

What is the nltk.stem.util module?

Sarvech Qadir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Text normalization (i.e., preparing text, words and documents) is one of the most fundamental tasks of the Natural Language processing field. These text normalization techniques are called Stemming and Lemmatization. nltk.stem is one of the most widely used libraries in Python for Stemming and Lemmatization.

Examples of Stemming and Lemmatization

If you look at the words cars, car’s, CAR, Car, and cars’, you will see that all of them are derived from the rootor stem word car. If we use nltk.stem, all of these words will be mapped to car.

widget

nltk.stem.util is one of the instances of ntlk.stem. It contains two major methods, nltk.stem.util.prefix_replace and nltk.stem.util.suffix_replace.

nltk.stem.util.prefix_replace(original, old, new)

This method shown above is used to replace the old (parameter) prefix of the original string (given as a paramater to the function) by a new (parameter) suffix. It returns a string.

Parameters

  1. original – string

  2. old – string

  3. new – string

nltk.stem.util.suffix_replace(original, old, new)

The method above is used to replace the old (parameter) suffix of the original string (given as a parameter to the function) with a new (parameter) suffix. It returns a string.

Parameters

  1. original – string

  2. old – string

  3. new – string

RELATED TAGS

nltk
stem.util module

CONTRIBUTOR

Sarvech Qadir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring