ตามหลักตามไวยากรณ์ภาษาอังกฤษ คำหนึ่งคำจะแปรไปได้หลายรูปแบบ เช่น organize, organizes, organized, organizing นอกจากนั้นคำยังสามารถแปลงเป็นกลุ่มคำ ที่มาจากรากศัพท์เดียวกันได้อีกหลายรูปแบบ เช่น democracy, democratic, democratization

ในงาน NLP ถ้าเราต้องการค้นหาคำบางคำในกลุ่ม แล้วอยากให้ได้ผลลัพธ์ครอบคลุมทุกคำทั้งกลุ่ม แล้วเราจะทำอย่างไร

เราต้องการกระบวนการที่จะลดรูปคำศัพท์ แปลง word ให้อยู่ในรูปฟอร์มพื้นฐาน เช่น

  • am, are, is ⇒ be
  • car, cars, car’s, cars’ ⇒ car
  • independently ⇒ independent

ตัวอย่าง เมื่อนำมาใช้กับข้อความทั้งประโยค เช่น

  • the boy’s cars are different colors ⇒ the boy car be differ color

วิธีที่เป็นที่นิยมมี 2 อย่าง เรียกว่า Lemmatization และ Stemming

Stemming คืออะไร

Photo of sabumnim Duke Lee courtesy of J. K. Lee Black Belt Academy. Credit https://en.wikipedia.org/wiki/File:Breaking_concrete.jpg
Photo of sabumnim Duke Lee courtesy of J. K. Lee Black Belt Academy. Credit https://en.wikipedia.org/wiki/File:Breaking_concrete.jpg

Stemming คือ กระบวนตัดส่วนท้ายของคำ แบบหยาบ ๆ ด้วย Heuristic ซึ่งได้ผลดีพอควร สำหรับคำในภาษาอังกฤษส่วนใหญ่ แต่ไม่ทุกคำ

Stemming ทำให้คำลดฟอร์มลง เหลือแต่ส่วนหน้าของคำที่เหมือน ๆ กันในคำกลุ่มเดียวกัน ผลลัพธ์ไม่จำเป็นต้องเป็นคำใน Dictionary ซึ่งบางทีทำให้ได้ผลลัพธ์ผิดความหมายไปเลย

Stemming ถือว่าเป็น Poor-man’s Lemmatization

Lemmatization คืออะไร

Lemmatization คือ กระบวนการในการแปลง Word ด้วยรายการคำศัพท์ใน Dictionary, การวิเคราะห์หลักไวยกรณ์ของภาษา อย่างเหมาะสม ในการแปรคำ ผันคำ เพื่อกำจัด Inflection ของคำ เช่น เพศ, Tense, เสียง, อารมณ์, จำนวน, etc.

โดยส่วนใหญ่ Lemmatization จะตัดส่วนท้ายของคำ ให้เหลือแต่รูปฟอร์มพื้นฐาน เป็นคำใน Dictionary เรียกว่า Lemma

A morphology tree of the English word "independently". Credit https://en.wikipedia.org/wiki/File:Independently_morphology_tree.png
A morphology tree of the English word “independently”. Credit https://en.wikipedia.org/wiki/File:Independently_morphology_tree.png

ตัวอย่างเช่น saw ถ้าใช้ Stemming จะทำได้ดีที่สุดแค่ s แต่ถ้าใช้ Lemmatization จะได้ see หรือ saw ขึ้นอยู่กับว่าเป็น Noun หรือ Verb

เรามาเริ่มกันเลยดีกว่า

Open In Colab

แชร์ให้เพื่อน:

Surapong Kanoktipsatharporn on FacebookSurapong Kanoktipsatharporn on LinkedinSurapong Kanoktipsatharporn on Rss
Surapong Kanoktipsatharporn
Solutions Architect at Bua Labs
The ultimate test of your knowledge is your capacity to convey it to another.

Published by Surapong Kanoktipsatharporn

The ultimate test of your knowledge is your capacity to convey it to another.