7

I'm writing a text classification system in Python. This is what I'm doing to canonicalize each token:

lem, stem = WordNetLemmatizer(), PorterStemmer()
for doc in corpus:
    for word in doc:
        lemma = stem.stem(lem.lemmatize(word))

The reason I don't want to just lemmatize is because I noticed that WordNetLemmatizer wasn't handling some common inflections. In the case of adverbs, for example, lem.lemmatize('walking') returns walking.

Is it wise to perform both stemming and lemmatization? Or is it redundant? Do researchers typically do one or the other, and not both?

James Ko
  • 32,215
  • 30
  • 128
  • 239
  • 1
    Take a look at https://www.kaggle.com/alvations/basic-nlp-with-nltk ("Stemming and Lemmatization" section) – alvas Mar 19 '18 at 05:27
  • 2
    Duplicate of https://stackoverflow.com/questions/17317418/stemmers-vs-lemmatizers. – alvas Mar 19 '18 at 05:34

3 Answers3

6

From my point of view, doing both stemming and lemmatization or only one will result in really SLIGHT differences, but I recommend for use just stemming because lemmatization sometimes need 'pos' to perform more presicsely.

For example, if you want to lemmatize "better", you should explicitly indicate pos: print(lemmatizer.lemmatize("better", pos="a"))

If not supplied, the default is "noun"

Giang Nguyen
  • 450
  • 8
  • 17
2

The lemmatization of walking is ambiguous. Walking, when used as an adjective, is its own baseform (rather than walk).

Correction: Research has shown that generally stemming outperforms lemmatization in IR tasks. A qualitative comparison between the two and an explanation can be found here.

KonstantinosKokos
  • 3,369
  • 1
  • 11
  • 21
1

I think stemming a lemmatized word is redundant if you get the same result than just stemming it (which is the result I expect). Nevertheless, the decision between stemmer and lemmatizer depends on your need. My intuition said that steamming increses recall and lowers precision and the opposite for a lemmatization. Consider this scores, what matter for your specific problem? Other option talking about this scores is to calculate F-1 score which is the harmonic average of the precision and recall.

Jason Angel
  • 2,233
  • 1
  • 14
  • 14