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