PyThaiNLP
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 2.0). Things will break.
- The latest stable release is 2.0.5
- PyThaiNLP 2 supports Python 3.6+. Some functions may work with older version of Python 3, but it is not well-tested and will not be supported. See change log.
- Python 2.7+ users can use PyThaiNLP 1.6.
- ðŦ follow us on Facebook PyThaiNLP
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 likestring.letters,string.digits, andstring.punctuation - Thai word segmentation (
word_tokenize), including subword segmentation based on Thai Character Cluster (subword_tokenize) - Thai transliteration (
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 spelling suggestion and correction (
spellandcorrect) - Thai soundex (
soundex) with three engines (lk82,udom83,metasound) - Thai WordNet wrapper
- and much more - see examples in PyThaiNLP Get Started notebook.
Installation
PyThaiNLP uses PyPI as its main distribution channel, see https://pypi.org/project/pythainlp/
Stable release
Standard installation:
$ pip install pythainlpDevelopment release:
$ pip install https://github.com/PyThaiNLP/pythainlp/archive/dev.zipFor 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, International Components for Unicode, support in transliteration and tokenization)ipa(for IPA, 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
artaggerpackage from PyPI will not work on Windows, pleasepip install https://github.com/wannaphongcom/artagger/tarball/master#egg=artaggerinstead.
** see extras and extras_require in setup.py for package details.
Documentation
See https://thainlp.org/pythainlp/docs/2.0/
License
- PyThaiNLP code uses Apache Software License 2.0
- Corpus data created by PyThaiNLP project use Creative Commons Attribution-ShareAlike 4.0 International License
- For other corpus that may included with PyThaiNLP distribution, please refer to Corpus License.
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 āđāļāđāļāđāļĨāļāļēāļĢāļĩāļ āļēāļĐāļēāđāļāļāļāļāđāļāļ·āđāļāļāļēāļĢāļāļĢāļ°āļĄāļ§āļĨāļāļĨāļ āļēāļĐāļēāļāļĢāļĢāļĄāļāļēāļāļī āđāļāļĒāđāļāđāļāļāļēāļĢāļŠāļāļąāļāļŠāļāļļāļāļ āļēāļĐāļēāđāļāļĒ āđāļāļāļāđāļēāļĒāļāļĢāļĩ (āļāļĨāļāļāđāļ) āđāļāļ·āđāļāļāļāđāļāļĒāđāļĨāļ°āļāļēāļ§āđāļĨāļāļāļļāļāļāļ!
āđāļāļĢāļēāļ°āđāļĨāļāļāļąāļāđāļāļĨāļ·āđāļāļāļāđāļāđāļāļāđāļ§āļĒāļāļēāļĢāđāļāđāļāļāļąāļ
āđāļāļāļŠāļēāļĢāļāļĩāđāļŠāļģāļŦāļĢāļąāļāļĢāļļāđāļāļāļąāļāļāļē āļāļēāļāļĄāļĩāļāļēāļĢāđāļāļĨāļĩāđāļĒāļāđāļāļĨāļāđāļāđāļāļĨāļāļ
- āļĢāļļāđāļāđāļŠāļāļĩāļĒāļĢāļĨāđāļēāļŠāļļāļāļāļ·āļāļĢāļļāđāļ 2.0.5
- PyThaiNLP 2 āļĢāļāļāļĢāļąāļ Python 3.6 āļāļķāđāļāđāļ
- āļāļđāđāđāļāđ Python 2.7+ āļĒāļąāļāļŠāļēāļĄāļēāļĢāļāđāļāđ PyThaiNLP 1.6 āđāļāđ
ðŦ āļāļīāļāļāļēāļĄāļāđāļēāļ§āļŠāļēāļĢāđāļāđāļāļĩāđ Facebook Pythainlp
āļāļ§āļēāļĄāļŠāļēāļĄāļēāļĢāļ
- āļāļļāļāļāđāļēāļāļāļāļĩāđāļāļąāļ§āļāļąāļāļĐāļĢāļ°āđāļĨāļ°āļāļģāđāļāļĒāļāļĩāđāđāļĢāļĩāļĒāļāđāļāđāđāļāđāļŠāļ°āļāļ§āļ āđāļāđāļ āļāļĒāļąāļāļāļāļ° (
pythainlp.thai_consonants), āļŠāļĢāļ° (pythainlp.thai_vowels), āļāļąāļ§āđāļĨāļāđāļāļĒ (pythainlp.thai_digits), āđāļĨāļ° stop word (pythainlp.corpus.thai_stopwords) -- āđāļŦāļĄāļ·āļāļāļāļąāļāļāđāļēāļāļāļāļĩāđāļāļĒāđāļēāļstring.letters,string.digits, āđāļĨāļ°string.punctuation - āļāļąāļāļāļģāļ āļēāļĐāļēāđāļāļĒ (
word_tokenize) āđāļĨāļ°āļĢāļāļāļĢāļąāļāļāļēāļĢāļāļąāļāļĢāļ°āļāļąāļāļāđāļģāļāļ§āđāļēāļāļģāđāļāļĒāđāļāđ Thai Character Clusters (subword_tokenize) - āļāļāļāđāļŠāļĩāļĒāļāļ āļēāļĐāļēāđāļāļĒāđāļāđāļāļāļąāļāļĐāļĢāļĨāļ°āļāļīāļāđāļĨāļ°āļŠāļąāļāļāļąāļāļĐāļĢ (
transliterate) - āļĢāļ°āļāļļāļāļāļīāļāļāļģ (part-of-speech) āļ āļēāļĐāļēāđāļāļĒ (
pos_tag) - āļāđāļēāļāļāļąāļ§āđāļĨāļāđāļāđāļāļāđāļāļāļ§āļēāļĄāļ āļēāļĐāļēāđāļāļĒ (
bahttext,num_to_thaiword) - āđāļĢāļĩāļĒāļāļĨāļģāļāļąāļāļāļģāļāļēāļĄāļāļāļāļēāļāļļāļāļĢāļĄāđāļāļĒ (
collate) - āđāļāđāđāļāļāļąāļāļŦāļēāļāļēāļĢāļāļīāļĄāļāđāļĨāļ·āļĄāđāļāļĨāļĩāđāļĒāļāļ āļēāļĐāļē (
eng_to_thai,thai_to_eng) - āļāļĢāļ§āļāļāļģāļŠāļ°āļāļāļāļīāļāđāļāļ āļēāļĐāļēāđāļāļĒ (
spell,correct) - soundex āļ āļēāļĐāļēāđāļāļĒ (
soundex) 3 āļ§āļīāļāļĩāļāļēāļĢ (lk82,udom83,metasound) - Thai WordNet wrapper
- āđāļĨāļ°āļāļ·āđāļ āđ āļāļđāļāļąāļ§āļāļĒāđāļēāļāđāļāđāđāļ PyThaiNLP Get Started notebook
āļāļīāļāļāļąāđāļ
āļĢāļļāđāļāđāļŠāļāļĩāļĒāļĢ
$ 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/2.0/
āļŠāļąāļāļāļēāļāļāļļāļāļēāļ
- āđāļāđāļ 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 āļāļĨāļąāļāļĄāļē