0Pricing
NLP Academy · Lezione

Stemming: ridurre alla radice

Ricondurre running e runs a run

Stemming: ridurre alla radice è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento NLP Academy, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso NLP Academy include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

One Word, Many Forms

The verb run shows up as running, runs, and ran. To you they share a meaning, but raw text counts each one separately, splitting the signal. 🌱

Enter Stemming

Stemming chops the endings off a word to reach a rough root called the stem. The goal is to make related forms collapse into one shared token.

Rules, Not a Dictionary

A stemmer follows simple suffix rules instead of looking words up. It strips endings like ing, ed, and s, so it is fast but a bit crude.

The Porter Stemmer

NLTK ships the classic PorterStemmer. You create one instance, then call its stem method on any word you want reduced.

from nltk.stem import PorterStemmer
ps = PorterStemmer()
print(ps.stem('running'))

Forms Collapse Together

Feed in several forms of the same verb and they all reduce to the same stem. Now your counts can finally add up.

for w in ['running', 'runs', 'ran']:
    print(ps.stem(w))

Stems Are Not Real Words

Stemming is blunt. The word studies becomes studi, which is not a real word, but it still matches study and studied as one stem.

print(ps.stem('studies'))

Watch for Over-Stemming

Sometimes a stemmer cuts too far and merges unrelated words. This over-stemming can blur meanings, so always sanity-check the output on your text.

print(ps.stem('universal'))
print(ps.stem('university'))

Stem a Token List

In practice you stem every token in a document. A comprehension applies the stemmer across the whole list in one clean line.

words = ['cats', 'caring', 'cared']
print([ps.stem(w) for w in words])

Other Stemmers Exist

Porter is the default, but NLTK also offers the snappier SnowballStemmer, which supports many languages and fixes some Porter rough edges.

from nltk.stem import SnowballStemmer
sb = SnowballStemmer('english')
print(sb.stem('happily'))

Lowercase First

Stemmers expect lowercase input. Fold case before stemming, or Running and running may slip through as two different tokens again.

print(ps.stem('Running'.lower()))

When to Reach for It

Stemming trades precision for speed. It shines in search and large pipelines where a rough but fast match beats slow, exact analysis. ⚡

Quick Check

Let's lock in how stemming behaves.

Recap

You learned stemming chops suffixes with simple rules to collapse word forms into one stem. It is fast and rough, sometimes yielding non-words. Nice work! 🎉

Domande Frequenti

La lezione «Stemming: ridurre alla radice» è gratuita?

Sì — il testo completo di «Stemming: ridurre alla radice» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso NLP Academy, passa a CoddyKit PRO. Il corso NLP Academy include 4 lezioni in totale.

Cosa imparerò in «Stemming: ridurre alla radice»?

Ricondurre running e runs a run Eserciti NLP Academy con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.

Ho bisogno di esperienza per iniziare NLP Academy?

Non è richiesta alcuna esperienza precedente. NLP Academy su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.

Quanto tempo richiede la lezione «Stemming: ridurre alla radice»?

La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.

Posso scrivere ed eseguire codice in questa lezione NLP Academy?

Sì. Ogni lezione NLP Academy include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.

Tutte le lezioni di questo corso

  1. Perché maiuscole e spaziatura contano
  2. Convertire in minuscolo e rimuovere gli spazi
  3. Stemming: ridurre alla radice
  4. Lemmatizzazione: forme base più intelligenti
← Torna a NLP Academy