ติดแท็กคำด้วย spaCy
อ่าน POS และแท็กแบบละเอียด
ติดแท็กคำด้วย spaCy เป็นบทเรียน NLP Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน 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” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส NLP Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “ติดแท็กคำด้วย spaCy”
อ่าน POS และแท็กแบบละเอียด คุณปฏิบัติ NLP Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน NLP Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน NLP Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 4 บทเรียน
บทเรียน “ติดแท็กคำด้วย spaCy” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน NLP Academy นี้ได้ไหม
ได้ บทเรียน NLP Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- คำนาม กริยา และเหตุใดแท็กจึงสำคัญ
- ติดแท็กคำด้วย spaCy
- ดึงวลีตามรูปแบบแท็ก
- พื้นฐานการแยกวิเคราะห์ความสัมพันธ์