0Pricing
NLP Academy · Lezione

Assegnare tag alle parole con spaCy

Leggere i tag POS e quelli dettagliati

Assegnare tag alle parole con spaCy è una lezione NLP Academy gratuita su CoddyKit. Questa è la lezione 2 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.

spaCy Tags for You

You do not have to label words by hand. spaCy reads a sentence and assigns a part of speech to every token automatically. ⚡

Load a Model

First load a trained model. The small English model en_core_web_sm knows how to tag, parse, and recognize entities right away.

import spacy
nlp = spacy.load("en_core_web_sm")

Process Your Text

Call nlp() on a string to get a Doc. The Doc holds every token along with the tags spaCy has already worked out for you.

doc = nlp("The cat sleeps quietly")

Loop Over Tokens

A Doc is iterable, so you can walk through it token by token. Each token is a rich object carrying its text and grammatical info.

for token in doc:
    print(token.text)

Read the Coarse Tag

Every token has a pos_ attribute holding its universal tag, such as NOUN or VERB. The trailing underscore gives you the readable string.

for token in doc:
    print(token.text, token.pos_)

The Fine-Grained Tag

For more detail, read token.tag_. It gives a precise label like VBZ for a present-tense verb, beyond the broad pos_ category.

print(doc[2].text, doc[2].tag_)

Explain Any Tag

Forgot what a code means? Call spacy.explain() with a tag and it returns a plain-English description you can read instantly.

print(spacy.explain("VBZ"))

Tags Come From Context

spaCy decides each tag from the whole sentence, not a lookup table. That is why book can be tagged NOUN or VERB depending on how you use it.

Filter by Part of Speech

Once tags exist, filtering is easy. Keep only tokens whose pos_ equals VERB to collect every action word in the text.

verbs = [t.text for t in doc if t.pos_ == "VERB"]

Tagging Is Fast

spaCy tags thousands of words per second, so you can run it over large documents without waiting. It is built for real production work.

One Model, Many Tasks

The same loaded model also handles parsing and entities. Tagging is just one part of spaCy's full pipeline running on each Doc.

Quick Check

Recall how spaCy exposes part-of-speech labels.

Recap

You loaded a model, processed text, and read both pos_ and tag_ for each token. spaCy turns raw sentences into tagged words in just a few lines. 🎉

Domande Frequenti

La lezione «Assegnare tag alle parole con spaCy» è gratuita?

Sì — il testo completo di «Assegnare tag alle parole con spaCy» è 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 «Assegnare tag alle parole con spaCy»?

Leggere i tag POS e quelli dettagliati 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 2 di 4.

Quanto tempo richiede la lezione «Assegnare tag alle parole con spaCy»?

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. Nomi, verbi e importanza dei tag
  2. Assegnare tag alle parole con spaCy
  3. Estrarre frasi in base al pattern dei tag
  4. Basi del dependency parsing
← Torna a NLP Academy