Skip to content

Commit df2bbde

Browse files
authored
Merge pull request #7 from wannaphongcom/develop
Updata to PyThaiNLP 1.0.0
2 parents d42662a + 8cb3e8b commit df2bbde

31 files changed

+280
-78
lines changed

.travis.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,17 @@ language: python
55
python: 3.5
66

77
env:
8+
- TOXENV=py36
89
- TOXENV=py35
910
- TOXENV=py34
1011
- TOXENV=py33
12+
- TOXENV=py27
13+
- TOXENV=pypy
1114
# command to install dependencies, e.g. pip install -r requirements.txt --use-mirrors
1215
install: pip install -U tox
1316

1417
# command to run tests, e.g. python setup.py test
15-
script: tox -e ${TOXENV}
18+
script: python setup.py test
1619

1720
# After you create the Github repo and add it to Travis, run the
1821
# travis_pypi_setup.py script to finish PyPI deployment setup
@@ -25,4 +28,4 @@ deploy:
2528
on:
2629
tags: true
2730
repo: wannaphongcom/pythainlp
28-
condition: $TOXENV == py35
31+
#condition: $TOXENV == py35

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# PyThaiNLP
22
[![PyPI Downloads](https://img.shields.io/pypi/dm/pythainlp.png)]
33
[![pypi](https://img.shields.io/pypi/v/pythainlp.svg)](https://pypi.python.org/pypi/pythainlp)
4-
[![Build Status](https://travis-ci.org/wannaphongcom/pythainlp.svg?branch=master)](https://travis-ci.org/wannaphongcom/pythainlp)
4+
[![Build Status](https://travis-ci.org/wannaphongcom/pythainlp.svg?branch=develop)](https://travis-ci.org/wannaphongcom/pythainlp)
55

66
Thai NLP in python package.
77

88
Natural language processing หรือ การประมวลภาษาธรรมชาติ โมดูล PyThaiNLP เป็นโมดูลที่ถูกพัฒนาขึ้นเพื่องานวิจัยและพัฒนาการประมวลภาษาธรรมชาติภาษาไทยในภาษา Python
99

10-
รองรับเฉพาะ Python 3 เท่านั้น
10+
รองรับทั้ง Python 2.7 และ Python 3
1111

1212
- เอกสารการใช้งาน : [https://pythonhosted.org/pythainlp/](https://pythonhosted.org/pythainlp/)
1313
- หน้าหลัก GitHub : [https://github.com/wannaphongcom/pythainlp](https://github.com/wannaphongcom/pythainlp)
@@ -17,7 +17,7 @@ Natural language processing หรือ การประมวลภาษา
1717
กำลังพัฒนา
1818

1919
### Version
20-
0.0.9
20+
1.0.0
2121

2222
### ความสามารถ
2323
- ตัดคำภาษาไทย
@@ -31,7 +31,7 @@ Natural language processing หรือ การประมวลภาษา
3131

3232
# ติดตั้ง
3333

34-
รองรับเฉพาะ Python 3
34+
รองรับทั้ง Python 2.7 และ Python 3
3535

3636
รุ่นเสถียร
3737
```sh

README.rst

Lines changed: 97 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,110 @@
1-
===============================
21
PyThaiNLP
3-
===============================
2+
=========
43

5-
.. image:: https://img.shields.io/pypi/v/pythainlp.svg
6-
:target: https://pypi.python.org/pypi/pythainlp
7-
8-
.. image:: https://img.shields.io/travis/wannaphongcom/pythainlp.svg
9-
:target: https://travis-ci.org/wannaphongcom/pythainlp
4+
[|PyPI Downloads|][|pypi|](https://pypi.python.org/pypi/pythainlp)
5+
|Build Status|
106

117
Thai NLP in python package.
128

9+
Natural language processing หรือ การประมวลภาษาธรรมชาติ โมดูล PyThaiNLP
10+
เป็นโมดูลที่ถูกพัฒนาขึ้นเพื่องานวิจัยและพัฒนาการประมวลภาษาธรรมชาติภาษาไทยในภาษา
11+
Python
12+
13+
รองรับทั้ง Python 2.7 และ Python 3
14+
15+
- เอกสารการใช้งาน : https://pythonhosted.org/pythainlp/
16+
- หน้าหลัก GitHub : https://github.com/wannaphongcom/pythainlp
17+
18+
สถานะโครงการ
19+
~~~~~~~~~~~~
20+
21+
กำลังพัฒนา
22+
1323
Version
14-
--------
15-
0.0.9
24+
~~~~~~~
25+
26+
1.0.0
27+
28+
ความสามารถ
29+
~~~~~~~~~~
30+
31+
- ตัดคำภาษาไทย
32+
- ถอดเสียงภาษาไทยเป็น Latin
33+
- Postaggers ภาษาไทย
34+
- อ่านตัวเลขเป็นข้อความภาษาไทย
35+
- เรียงจำนวนคำของประโยค
36+
- แก้ไขปัญหาการพิมพ์ลืมเปลี่ยนภาษา
37+
- เช็คคำผิดในภาษาไทย
38+
- และอื่น ๆ
39+
40+
ติดตั้ง
41+
=======
42+
43+
รองรับทั้ง Python 2.7 และ Python 3
44+
45+
รุ่นเสถียร
46+
47+
.. code:: sh
48+
49+
$ pip3 install pythainlp
50+
51+
รุ่นกำลังพัฒนา
52+
53+
.. code:: sh
54+
55+
$ git clone https://github.com/wannaphongcom/pythainlp.git
56+
$ cd pythainlp
57+
$ python setup.py install
58+
59+
เอกสารการใช้งานเบื้องต้น
60+
========================
61+
62+
ตัวอย่างการใช้งาน
63+
64+
.. code:: python
1665
17-
* Free software: Apache Software License 2.0
18-
* Documentation: https://pythonhosted.org/pythainlp/
66+
# ตัดคำ
67+
from pythainlp.segment import segment
68+
a = 'ฉันรักภาษาไทยเพราะฉันเป็นคนไทย'
69+
b = segment(a)
70+
print(b) # ['ฉัน', 'รัก', 'ภาษาไทย', 'เพราะ', 'ฉัน', 'เป็น', 'คนไทย']
71+
# Postaggers ภาษาไทย
72+
from pythainlp.postaggers import tag
73+
print(tag('คุณกำลังประชุม')) # [('คุณ', 'PPRS'), ('กำลัง', 'XVBM'), ('ประชุม', 'VACT')]
74+
# หาคำที่มีจำนวนการใช้งานมากที่สุด
75+
from pythainlp.rank import rank
76+
aa = rank(b)
77+
print(aa) # Counter({'ฉัน': 2, 'ไทย': 2, 'เป็น': 1, 'รัก': 1, 'ภาษา': 1, 'เพราะ': 1, 'คน': 1})
78+
# ถอดเสียงภาษาไทยเป็น Latin
79+
from pythainlp.romanization import romanization
80+
b=romanization("แมว")
81+
print(b) # mæw
82+
# แก้ไขปัญหาการพิมพ์ลืมเปลี่ยนภาษา
83+
from pythainlp.change import *
84+
a="l;ylfu8iy["
85+
a=texttothai(a)
86+
b="นามรสนอำันี"
87+
b=texttoeng(b)
88+
print(a) # สวัสดีครับ
89+
print(b) # ok,iloveyou
90+
# เปลี่ยนตัวเลขเป็นตัวอักษรภาษาไทย (เงินบาท)
91+
from pythainlp.number import numtowords
92+
print("5611116.50")
93+
print(numtowords(5611116.50)) # ห้าล้านหกแสนหนึ่งหมื่นหนึ่งพันหนึ่งร้อยสิบหกบาทห้าสิบสตางค์
1994
95+
License
96+
~~~~~~~
2097

21-
Features
22-
--------
98+
Apache Software License 2.0
2399

24-
* Thai split words
25-
* Thai postagger
26-
* And more.
100+
พัฒนาโดย นาย วรรณพงษ์ ภัททิยไพบูลย์
27101

102+
สนับสนุน
103+
~~~~~~~~
28104

29-
INSTALL
30-
--------
105+
คุณสามารถร่วมพัฒนาโครงการนี้ได้ โดยการ Fork และส่ง pull requests กลับมา
31106

32-
$ pip3 install pythainlp
107+
.. |PyPI Downloads| image:: https://img.shields.io/pypi/dm/pythainlp.png
108+
.. |pypi| image:: https://img.shields.io/pypi/v/pythainlp.svg
109+
.. |Build Status| image:: https://travis-ci.org/wannaphongcom/pythainlp.svg?branch=develop
110+
:target: https://travis-ci.org/wannaphongcom/pythainlp

build-readme.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pandoc -f markdown -t rst -o README.rst README.md

docs/docs.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,15 @@ pythainlp.postaggers.tag(str)
3636
[('แมว', 'NCMN'), ('กิน', 'VACT'), ('ปลา', 'NCMN')
3737
```
3838

39+
## ตรวจคำผิด
40+
41+
คุณจะต้องติดตั้ง hunspell ( https://github.com/hunspell/hunspell/ )ในเครื่องของคุณก่อนใช้งานความสามารถนี้
42+
43+
```python
44+
pythainlp.spell.spell(str)
45+
```
46+
ส่งออกเป็น list
47+
3948
## หาคำที่มีจำนวนการใช้งานมากที่สุด
4049

4150
```python

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Thai NLP in python package.
77
PyThaiNLP เป็นโมดูลด้าน Natural language processing ภาษาไทยในภาษา Python
88

99
## เวชั่น
10-
0.0.7
10+
1.0.0
1111

1212
- เอกสารการใช้งาน : [https://pythonhosted.org/pythainlp/](https://pythonhosted.org/pythainlp/)
1313
- หน้าหลัก GitHub : [https://github.com/wannaphongcom/pythainlp](https://github.com/wannaphongcom/pythainlp)

pythainlp/12.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pythainlp/__init__.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
from __future__ import print_function
5+
from __future__ import division
6+
from future import standard_library
7+
standard_library.install_aliases()
38
__author__ = 'Wannaphong Phatthiyaphaibun'
49
__email__ = 'wannaphong@yahoo.com'
5-
__version__ = '0.0.9'
6-
from . import romanization
7-
from . import segment
8-
from . import rank
9-
from . import change
10-
from . import number
11-
from . import date
12-
from . import postaggers
13-
from . import collation
14-
from . import spell
10+
__version__ = '1.0.0'
11+
from pythainlp.romanization import *
12+
from pythainlp.segment import *
13+
from pythainlp.rank import *
14+
from pythainlp.change import *
15+
from pythainlp.number import *
16+
from pythainlp.date import *
17+
from pythainlp.postaggers import *
18+
from pythainlp.collation import *
19+
from pythainlp.spell import *

pythainlp/change/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import absolute_import,print_function
3+
from __future__ import unicode_literals
4+
from __future__ import division
5+
from future import standard_library
6+
standard_library.install_aliases()
27
from nine import str,iteritems
38
dictdata={'Z':'(','z':'ผ','X':')','x':'ป','C':'ฉ','c':'แ','V':'ฮ','v':'อ','B':'ฺ','b':'ิ','N':'์','n':'ื','M':'?','m':'ท','<':'ฒ',',':'ม','>':'ฬ','.':'ใ','?':'ฦ','/':'ฝ',
49
'A':'ฤ','a':'ฟ','S':'ฆ','s':'ห','D':'ฏ','d':'ก','F':'โ','f':'ด','G':'ฌ','g':'เ','H':'็','h':'้','J':'๋','j':'j','K':'ษ','k':'า','L':'ศ','l':'ส',':':'ซ','"':'.',"'":"ง",':':'ซ',';':'ว',

pythainlp/collation/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import absolute_import,print_function
3+
from __future__ import unicode_literals
4+
from __future__ import division
5+
from future import standard_library
6+
standard_library.install_aliases()
27
import icu
38
collator1 = icu.Collator.createInstance(icu.Locale('th_TH'))
49
# เรียงลำดับข้อมูล list ภาษาไทย

pythainlp/corpus/__init__.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
from __future__ import absolute_import
2-
from __future__ import print_function
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import,print_function
3+
from __future__ import unicode_literals
4+
from __future__ import division
5+
from future import standard_library
6+
standard_library.install_aliases()
7+
__all__ = ["thaipos", "thaiword"]
38
from .thaipos import get_data
49
from .thaiword import get_data

pythainlp/corpus/thaipos.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pythainlp/corpus/thaipos.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
from __future__ import print_function
5+
from __future__ import division
6+
from builtins import open
7+
from future import standard_library
8+
standard_library.install_aliases()
19
import pythainlp
210
import os
311
from nine import nimport,str

pythainlp/corpus/thaiword.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
from __future__ import print_function
5+
from __future__ import division
6+
from future import standard_library
7+
standard_library.install_aliases()
18
import os
29
from nine import nimport,str
310
codecs= nimport('codecs')

pythainlp/corpus/thaiword.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ก.
1+
ก.
22
ก.ค.
33
ก.ต.
44
ก.ป.ส.

pythainlp/date/__init__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
from __future__ import print_function
5+
from __future__ import division
36
# TODO
47

58
# BE คือ พ.ศ.
69
# AD คือ ค.ศ.
7-
# AH ปีฮิจเราะห์ศักราชเป็นปีพุทธศักราช จะต้องบวกด้วย 1122
10+
# AH ปีฮิจเราะห์ศักราชเป็นปีพุทธศักราช จะต้องบวกด้วย 1122
11+
from future import standard_library
12+
standard_library.install_aliases()

pythainlp/number/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
# -*- coding: utf-8 -*-
12
# ระบบแปลงเลขใน 1- 10 ภาษาไทย
23
from __future__ import absolute_import,division,print_function
4+
from __future__ import unicode_literals
5+
from builtins import dict
6+
from builtins import int
7+
from future import standard_library
8+
standard_library.install_aliases()
39
from nine import str
410
import math
511
p = [['ภาษาไทย', 'ตัวเลข','เลขไทย'],

pythainlp/postaggers/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import absolute_import
3+
from __future__ import unicode_literals
4+
from __future__ import print_function
5+
from __future__ import division
6+
from future import standard_library
7+
standard_library.install_aliases()
8+
__all__ = ["text"]
29
from .text import tag

pythainlp/postaggers/text.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
from __future__ import absolute_import,division,print_function
2+
from __future__ import unicode_literals
3+
from future import standard_library
4+
standard_library.install_aliases()
25
from nine import nimport,str
36
from pythainlp.segment import segment
47
import pythainlp
8+
import codecs
59
import os
610
json= nimport('json')
711
import nltk.tag, nltk.data
812
templates_dir = os.path.join(os.path.dirname(pythainlp.__file__), 'corpus')
913
template_file = os.path.join(templates_dir, 'thaipos.json')
1014
#default_tagger = nltk.data.load(nltk.tag._POS_TAGGER)
1115
def data():
12-
with open(template_file) as handle:
16+
with codecs.open(template_file,'r',encoding='utf-8-sig') as handle:
1317
model = json.load(handle)
1418
return model
1519
data1 =data()

pythainlp/pythainlp.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

pythainlp/rank/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import absolute_import,print_function
3+
from __future__ import unicode_literals
4+
from __future__ import division
25
from future import standard_library
36
standard_library.install_aliases()
47
from collections import Counter

pythainlp/romanization/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
# -*- coding: utf-8 -*-
12
from __future__ import absolute_import,print_function
3+
from __future__ import unicode_literals
4+
from __future__ import division
5+
from future import standard_library
6+
standard_library.install_aliases()
27
import icu
38
# ถอดเสียงภาษาไทยเป็น Latin
49
def romanization(data):

0 commit comments

Comments
 (0)