การตัดคำ: ตัดให้เหลือรากศัพท์
จับคู่ running และ runs ให้เป็น run
การตัดคำ: ตัดให้เหลือรากศัพท์ เป็นบทเรียน NLP Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน NLP Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
One Word, Many Forms
The verb run shows up as running, runs, and ran. To you they share a meaning, but raw text counts each one separately, splitting the signal. 🌱
Enter Stemming
Stemming chops the endings off a word to reach a rough root called the stem. The goal is to make related forms collapse into one shared token.
Rules, Not a Dictionary
A stemmer follows simple suffix rules instead of looking words up. It strips endings like ing, ed, and s, so it is fast but a bit crude.
The Porter Stemmer
NLTK ships the classic PorterStemmer. You create one instance, then call its stem method on any word you want reduced.
from nltk.stem import PorterStemmer
ps = PorterStemmer()
print(ps.stem('running'))Forms Collapse Together
Feed in several forms of the same verb and they all reduce to the same stem. Now your counts can finally add up.
for w in ['running', 'runs', 'ran']:
print(ps.stem(w))Stems Are Not Real Words
Stemming is blunt. The word studies becomes studi, which is not a real word, but it still matches study and studied as one stem.
print(ps.stem('studies'))Watch for Over-Stemming
Sometimes a stemmer cuts too far and merges unrelated words. This over-stemming can blur meanings, so always sanity-check the output on your text.
print(ps.stem('universal'))
print(ps.stem('university'))Stem a Token List
In practice you stem every token in a document. A comprehension applies the stemmer across the whole list in one clean line.
words = ['cats', 'caring', 'cared']
print([ps.stem(w) for w in words])Other Stemmers Exist
Porter is the default, but NLTK also offers the snappier SnowballStemmer, which supports many languages and fixes some Porter rough edges.
from nltk.stem import SnowballStemmer
sb = SnowballStemmer('english')
print(sb.stem('happily'))Lowercase First
Stemmers expect lowercase input. Fold case before stemming, or Running and running may slip through as two different tokens again.
print(ps.stem('Running'.lower()))When to Reach for It
Stemming trades precision for speed. It shines in search and large pipelines where a rough but fast match beats slow, exact analysis. ⚡
Quick Check
Let's lock in how stemming behaves.
Recap
You learned stemming chops suffixes with simple rules to collapse word forms into one stem. It is fast and rough, sometimes yielding non-words. Nice work! 🎉
คำถามที่พบบ่อย
บทเรียน “การตัดคำ: ตัดให้เหลือรากศัพท์” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “การตัดคำ: ตัดให้เหลือรากศัพท์” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส NLP Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส NLP Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “การตัดคำ: ตัดให้เหลือรากศัพท์”
จับคู่ running และ runs ให้เป็น run คุณปฏิบัติ NLP Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน NLP Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน NLP Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน
บทเรียน “การตัดคำ: ตัดให้เหลือรากศัพท์” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน NLP Academy นี้ได้ไหม
ได้ บทเรียน NLP Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- เหตุใดตัวพิมพ์และการเว้นวรรคจึงสำคัญ
- เปลี่ยนเป็นตัวพิมพ์เล็กและตัดช่องว่าง
- การตัดคำ: ตัดให้เหลือรากศัพท์
- การทำเลมมาไทเซชัน: รูปพื้นฐานที่ฉลาดขึ้น