語彙を構築する
すべての単語を固定インデックスに対応付ける
「語彙を構築する」はCoddyKit上の無料NLP Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはNLP Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 NLP Academyコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
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 catVocabulary 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. 🎉
よくある質問
「語彙を構築する」レッスンは無料ですか?
はい。「語彙を構築する」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、NLP Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 NLP Academyコースには全4レッスンが含まれています。
「語彙を構築する」で何を学びますか?
すべての単語を固定インデックスに対応付ける ブラウザで直接実行するハンズオンコードでNLP Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
NLP Academyを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのNLP Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。
「語彙を構築する」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このNLP Academyレッスンでコードを書いて実行できますか?
はい。すべてのNLP Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。