Sub topic 9
Overstemming and Understemming
Assume you know basic Python, regular expressions, and the difference between nouns, verbs, and adjectives. You should also know that stemming removes word endings by rules, while lemmatisation uses vocabulary and grammar to find a valid base form.
The goal of stemming
A stemmer maps related word forms to a shared stem. For example, a search system might want these words to match:
connectconnectedconnectingconnection
The stemmer does not need to produce a real English word. It only needs to create a useful representation for the task.
This creates two possible errors:
- Overstemming merges words that should remain separate.
- Understemming fails to merge words that should be treated as related.
These errors affect the number of matches, the size of a vocabulary, and the accuracy of later models.
Overstemming
Overstemming happens when a stemmer removes too much or applies a rule too broadly. It maps unrelated words to the same stem.
For example, a crude suffix rule might remove -ing and -ly. This could map:
universitytouniversuniversaltouniversuniversetounivers
The shared result does not prove that the words have the same meaning. A search for information about universities might then retrieve documents about the universe.
Another example is the Porter stemmer. It can map relational to relat and relation to relat. That may be helpful when these forms represent the same topic. However, aggressive rules can also merge words whose meanings differ.
Understemming
Understemming happens when related words receive different stems. The rules may be too conservative, or the words may have irregular forms.
For example, a simple suffix stripper might leave these words unrelated:
gowentgone
These forms belong to the same verb, but their spellings do not share a removable suffix.
A stemmer can also understem derived forms. policy and policies may become policy and polici, depending on the algorithm. The words are related, but the resulting strings differ.
Understemming usually reduces recall. Recall is the proportion of all relevant results that a system finds. Overstemming can reduce precision. Precision is the proportion of returned results that are relevant.
| Error | What happens | Common effect |
|---|---|---|
| Overstemming | Unrelated words share a stem | Lower precision |
| Understemming | Related words have different stems | Lower recall |
Compare Porter and Snowball
Porter and Snowball are rule-based English stemmers. Snowball is a framework and also the name commonly used for its English stemmer. The two algorithms can produce different stems because they use different rule sets.
from nltk.stem import PorterStemmer, SnowballStemmer
porter = PorterStemmer()
snowball = SnowballStemmer("english")
words = [
"university", "universal", "relational",
"relation", "studies", "studying"
]
for word in words:
print(
f"{word:12} "
f"Porter={porter.stem(word):10} "
f"Snowball={snowball.stem(word)}"
)Install the dependency first if necessary:
python -m pip install nltkInspect the output rather than assuming that one stemmer is always better. A stem is an intermediate feature, not a grammatical answer.
How the errors arise
Stemming errors are task-dependent. In a small internal search system, extra matches may be acceptable if users prefer broad results. In a classification system, merging unrelated terms can remove useful distinctions. In a legal or medical system, losing distinctions may be more serious.
Evaluate the choices on representative data. Create queries or labelled examples, then compare:
- How many relevant items were retrieved?
- How many retrieved items were irrelevant?
- Did stemming improve the task metric?
- Are errors concentrated in names, technical terms, or a particular language variety?
Reducing the risk
Use lemmatisation when valid dictionary forms and grammatical information matter. Use stemming when speed and compact features matter more than linguistic accuracy. Use neither when the original word forms carry important meaning, such as in named-entity recognition or sentiment analysis.
Subword tokenisation is another option. It can represent unseen words through smaller pieces without forcing every word into one questionable stem.
Exercise
A search system misses documents containing "studies" when the query contains "study". Is this an example of overstemming or understemming, and why?
Show answer
It is understemming. Related forms received different representations, so the system loses relevant matches and recall falls.