Skip to content

thanatchakromsang/pythainlp

 
 

Repository files navigation

PyThaiNLP Logo

PyThaiNLP

Codacy Badgepypi Downloads Build Status Build status Coverage Status License FOSSA Status

Thai Natural Language Processing in Python.

PyThaiNLP is a Python package for text processing and linguistic analysis, similar to nltk but with focus on Thai language.

This is a document for development branch (post 1.7.x). Things will break. For a stable branch document, see master.

Capabilities

  • Convenient character and word classes, like Thai consonants (pythainlp.thai_consonants), vowels (pythainlp.thai_vowels), digits (pythainlp.thai_digits), and stop words (pythainlp.corpus.thai_stopwords) -- comparable to constants like string.letters, string.digits, and string.punctuation
  • Thai word segmentation (word_tokenize), including subword segmentation based on Thai Character Cluster (tcc) and ETCC (etcc)
  • Thai romanization and transliteration (romanize, transliterate)
  • Thai part-of-speech taggers (pos_tag)
  • Read out number to Thai words (bahttext, num_to_thaiword)
  • Thai collation (sort by dictionoary order) (collate)
  • Thai-English keyboard misswitched fix (eng_to_thai, thai_to_eng)
  • Thai misspellings detection and spelling correction (spell)
  • Thai soundex (lk82, udom83, metasound)
  • Thai WordNet wrapper
  • and much more - see examples.

Installation

PyThaiNLP uses PyPI as its main distribution channel, see https://pypi.org/project/pythainlp/

Stable release

Standard installation:

$ pip install pythainlp

Development release:

$ pip install https://github.com/PyThaiNLP/pythainlp/archive/dev.zip

For some advanced functionalities, like word vector, extra packages may be needed. Install them with these options during pip install:

$ pip install pythainlp[extra1,extra2,...]

where extras can be

  • artagger (to support artagger part-of-speech tagger)*
  • deepcut (to support deepcut machine-learnt tokenizer)
  • icu (for ICU support in transliteration and tokenization)
  • ipa (for International Phonetic Alphabet support in transliteration)
  • ml (to support fastai 1.0.22 ULMFiT models)
  • ner (for named-entity recognizer)
  • thai2fit (for Thai word vector)
  • thai2rom (for machine-learnt romanization)
  • full (install everything)
  • Note: standard artagger package from PyPI will not work on Windows, please pip install https://github.com/wannaphongcom/artagger/tarball/master#egg=artagger instead.

** see extras and extras_require in setup.py for package details.

Documentation

See https://thainlp.org/pythainlp/docs/1.7/

License

FOSSA Status

Contribute to PyThaiNLP

Please do fork and create a pull request :)

For style guide and other information, including references to algorithms we use, please refer to our contributing page.

ภาษาไทย

ประมวลภาษาไทยในภาษา Python

PyThaiNLP เป็นไลบารีภาษาไพทอนเพื่อการประมวลผลภาษาธรรมชาติ โดยเน้นการสนับสนุนภาษาไทย แจกจ่ายฟรี (ตลอดไป) เพื่อคนไทยและชาวโลกทุกคน!

เพราะโลกขับเคลื่อนต่อไปด้วยการแบ่งปัน

รองรับ Python 3.6 ขึ้นไป

  • ตั้งแต่รุ่น 1.7 PyThaiNLP จะเลิกสนับสนุน Python 2 (บางฟังก์ชันอาจยังทำงานได้ แต่จะไม่ได้รับการสนับสนุน)
  • ตั้งแต่รุ่น 2.0 จะยุติการรองรับ Python 2 ทั้งหมด
  • ผู้ใช้ Python 2 ยังสามารถใช้ PyThaiNLP 1.6 ได้

เอกสารนี้สำหรับรุ่นพัฒนา (หลัง 1.7.x) อาจมีการเปลี่ยนแปลงได้ตลอด สำหรับเอกสารรุ่นเสถียร ดูที่ master.

ความสามารถ

  • ชุดค่าคงที่ตัวอักษระและคำไทยที่เรียกใช้ได้สะดวก เช่น พยัญชนะ (pythainlp.thai_consonants), สระ (pythainlp.thai_vowels), ตัวเลขไทย (pythainlp.thai_digits), และ stop word (pythainlp.corpus.thai_stopwords) -- เหมือนกับต่าคงที่อย่าง string.letters, string.digits, และ string.punctuation
  • Thai word segmentation (word_tokenize), including subword segmentation based on Thai Character Cluster (tcc) and ETCC (etcc)
  • ตัดคำภาษาไทย (word_tokenize) และรองรับ Thai Character Clusters (tcc) และ ETCC (etcc)
  • ถอดเสียงภาษาไทยเป็นอักษรละตินและสัทอักษร (romanize, transliterate)
  • ระบุชนิดคำ (part-of-speech) ภาษาไทย (pos_tag)
  • อ่านตัวเลขเป็นข้อความภาษาไทย (bahttext, num_to_thaiword)
  • เรียงลำดับคำตามพจนานุกรมไทย (collate)
  • แก้ไขปัญหาการพิมพ์ลืมเปลี่ยนภาษา (eng_to_thai, thai_to_eng)
  • ตรวจคำสะกดผิดในภาษาไทย (spell)
  • soundex ภาษาไทย (lk82, udom83, metasound)
  • Thai WordNet wrapper
  • และอื่น ๆ ดูตัวอย่าง

ติดตั้ง

รุ่นเสถียร

$ pip install pythainlp

รุ่นกำลังพัฒนา

$ pip install https://github.com/PyThaiNLP/pythainlp/archive/dev.zip

สำหรับความสามารถเพิ่มเติมบางอย่าง เช่น word vector จำเป็นต้องติดตั้งแพคเกจสนับสนุนเพิ่มเติม ติดตั้งแพคเพจเหล่านั้นได้ ด้วยการระบุออปชันเหล่านี้ตอน pip install:

$ pip install pythainlp[extra1,extra2,...]

โดยที่ extras คือ

  • artagger (สำหรับตัวติดป้ายกำกับชนิดคำ artagger)*
  • deepcut (สำหรับตัวตัดคำ deepcut)
  • icu (สำหรับการถอดตัวสะกดเป็นสัทอักษรและการตัดคำด้วย ICU)
  • ipa (สำหรับการถอดตัวสะกดเป็นสัทอักษรสากล (IPA))
  • ml (สำหรับการรองรับโมเดล ULMFiT)
  • ner (สำหรับการติดป้ายชื่อเฉพาะ (named-entity))
  • thai2fit (สำหรับ word vector)
  • thai2rom (สำหรับการถอดตัวสะกดเป็นอักษรละติน)
  • full (ติดตั้งทุกอย่าง)
  • หมายเหตุ: แพคเกจ artagger มาตรฐานจาก PyPI อาจมีปัญหาการถอดรหัสข้อความบน Windows กรุณาติดตั้ง artagger รุ่นแก้ไขด้วยคำสั่ง pip install https://github.com/wannaphongcom/artagger/tarball/master#egg=artagger แทน ก่อนจะติดตั้ง PyThaiNLP

** นักพัฒนาสามารถดู extras และ extras_require ใน setup.py สำหรับรายละเอียดแพคเกจของเสริม

เอกสารการใช้งาน

อ่านที่ https://thainlp.org/pythainlp/docs/1.7/

สัญญาอนุญาต

  • โค้ด PyThaiNLP ใช้สัญญาอนุญาต Apache Software License 2.0
  • คลังคำและข้อมูลที่สร้างโดยโครงการ PyThaiNLP ใช้สัญญาอนุญาตครีเอทีฟคอมมอนส์แบบแสดงที่มา-อนุญาตแบบเดียวกัน 4.0 Creative Commons Attribution-ShareAlike 4.0 International License
  • คลังคำและข้อมูลอื่นๆ ที่อาจแจกจ่ายไปพร้อมกับแพคเกจ PyThaiNLP อาจใช้สัญญาอนุญาตอื่น โปรดดูเอกสาร Corpus License

ตราสัญลักษณ์

ออกแบบโดยคุณ วรุตม์ พสุธาดล จากการประกวดที่ https://www.facebook.com/groups/408004796247683/permalink/475864542795041/ และ https://www.facebook.com/groups/408004796247683/permalink/474262752955220/

สนับสนุนและร่วมพัฒนา

คุณสามารถร่วมพัฒนาโครงการนี้ได้ โดยการ fork และส่ง pull request กลับมา

About

Thai Natural Language Processing in Python.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Jupyter Notebook 55.0%
  • Python 44.4%
  • Other 0.6%