0Pricing
NLP Academy · Aula

Criando um vocabulário

Mapeie cada palavra para um índice fixo.

Criando um vocabulário é uma aula grátis de NLP Academy no CoddyKit. Esta é a aula 2 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de NLP Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de NLP Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

What Is a Vocabulary?

A vocabulary is the full set of unique words your model knows. Each word gets one fixed slot in every document vector. 📖

Collect Every Unique Word

To build it, gather all words across your documents and keep only the distinct ones, dropping repeats.

words = set("the cat sat the mat".split())

Give Each Word an Index

Sort the unique words and assign each a number. This word to index map is your vocabulary lookup.

vocab = {w: i for i, w in enumerate(sorted(words))}

The Index Defines the Slot

The index tells a word which position it occupies in every vector, so cat always lands in the same column.

Vocabulary Sets Vector Length

If your vocabulary has 5000 words, every document becomes a vector of 5000 numbers, one slot per word.

Order Must Stay Fixed

Once set, the mapping must never change. A stable order guarantees that column 3 means the same word for every document.

Out-of-Vocabulary Words

A word not in your vocabulary is called out of vocabulary. The simplest choice is to ignore it during counting.

Pruning Rare Words

Words that appear once add noise and size. Dropping very rare terms keeps the vocabulary smaller and cleaner.

Dropping Very Common Words

You can also cut words that appear in nearly every document. These stopwords rarely help tell documents apart.

Look Up an Index

With the map built, finding a word position is instant. Just index the dictionary by the word you want.

print(vocab["cat"])  # the column index for cat

Vocabulary Powers Counting

This map is the backbone of vectorization. Next you fill each slot with how often that word appears in a document.

Quick Check

What does a word index represent?

Recap: Your Vocabulary

You built a vocabulary of unique words, mapped each to a fixed index, and saw how pruning keeps it lean and useful. 🎉

Perguntas Frequentes

A aula “Criando um vocabulário” é grátis?

Sim — o texto completo de “Criando um vocabulário” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de NLP Academy, atualize para CoddyKit PRO. O curso de NLP Academy inclui 4 aulas no total.

O que vou aprender em “Criando um vocabulário”?

Mapeie cada palavra para um índice fixo. Você pratica NLP Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar NLP Academy?

Nenhuma experiência prévia é necessária. NLP Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 2 de 4.

Quanto tempo leva a aula “Criando um vocabulário”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de NLP Academy?

Sim. Cada aula de NLP Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Por que os modelos precisam de números, não palavras
  2. Criando um vocabulário
  3. Contando com CountVectorizer
  4. Lendo a matriz documento-termo
← Voltar para NLP Academy