Skip to content

Commit be331a2

Browse files
authored
Merge pull request #75 from PyThaiNLP/pythainlp1.6
PyThaiNLP 1.6
2 parents e1f1b96 + 53f4783 commit be331a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+12987
-1905
lines changed

AUTHORS.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ Development Lead
77

88
* Wannaphong Phatthiyaphaibun <[email protected]>
99

10+
* Korakot Chaovavanich
11+
12+
* Charin Polpanumas
13+
1014
TCC & THAI SOUNDEX CODE
1115
------------
1216

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ include README.rst
55

66
recursive-include tests *
77
recursive-exclude * __pycache__
8-
recursive-exclude * *.py[co]
8+
recursive-exclude * *.py[co]

README.md

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
![PyThaiNLP Logo](https://avatars0.githubusercontent.com/u/32934255?s=200&v=4)
2+
13
# PyThaiNLP
2-
[![PyPI Downloads](https://img.shields.io/pypi/dm/pythainlp.png)]
3-
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/50fa9d87f4fb4a95aac62b398aa374fa)](https://www.codacy.com/app/wannaphongcom/pythainlp?utm_source=github.com&utm_medium=referral&utm_content=wannaphongcom/pythainlp&utm_campaign=badger)
4-
[![pypi](https://img.shields.io/pypi/v/pythainlp.svg)](https://pypi.python.org/pypi/pythainlp)
5-
[![Build Status](https://travis-ci.org/wannaphongcom/pythainlp.svg?branch=develop)](https://travis-ci.org/wannaphongcom/pythainlp)
6-
[![Build status](https://ci.appveyor.com/api/projects/status/uxerymgggp1uch0p?svg=true)](https://ci.appveyor.com/project/wannaphongcom/pythainlp)
7-
[![Coverage Status](https://coveralls.io/repos/github/wannaphongcom/pythainlp/badge.svg)](https://coveralls.io/github/wannaphongcom/pythainlp)
84

9-
Homepags : https://sites.google.com/view/pythainlp/
5+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/cb946260c87a4cc5905ca608704406f7)](https://www.codacy.com/app/pythainlp/pythainlp_2?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=PyThaiNLP/pythainlp&amp;utm_campaign=Badge_Grade)[![pypi](https://img.shields.io/pypi/v/pythainlp.svg)](https://pypi.python.org/pypi/pythainlp)
6+
[![Build Status](https://travis-ci.org/PyThaiNLP/pythainlp.svg?branch=develop)](https://travis-ci.org/PyThaiNLP/pythainlp)
7+
[![Build status](https://ci.appveyor.com/api/projects/status/9g3mfcwchi8em40x?svg=true)](https://ci.appveyor.com/project/wannaphongcom/pythainlp-9y1ch)
8+
[![Coverage Status](https://coveralls.io/repos/github/PyThaiNLP/pythainlp/badge.svg?branch=dev)](https://coveralls.io/github/PyThaiNLP/pythainlp?branch=dev)
109

1110
Thai natural language processing in Python.
1211

@@ -17,7 +16,7 @@ It supports both Python 2.7 and Python 3.
1716

1817
### Capability
1918

20-
- Thai segmentation
19+
- Thai word segmentation
2120
- Thai wordnet
2221
- Thai Character Clusters (TCC) and ETCC
2322
- Thai stop word
@@ -37,11 +36,9 @@ and much more.
3736
$ pip install pythainlp
3837
```
3938

40-
more read on [https://sites.google.com/view/pythainlp/english/install](https://sites.google.com/view/pythainlp/english/install)
41-
4239
### Documentation
4340

44-
Read on [https://sites.google.com/view/pythainlp/english](https://sites.google.com/view/pythainlp/english)
41+
Read on [https://github.com/PyThaiNLP/pythainlp/tree/dev/docs](https://github.com/PyThaiNLP/pythainlp/tree/dev/docs)
4542

4643
### License
4744

@@ -57,7 +54,7 @@ Natural language processing หรือ การประมวลภาษา
5754
5855
รองรับ Python 2.7 และ Python 3
5956

60-
- หน้าหลัก GitHub : [https://github.com/wannaphongcom/pythainlp](https://github.com/wannaphongcom/pythainlp)
57+
- หน้าหลัก GitHub : [https://github.com/PyThaiNLP/pythainlp/](https://github.com/PyThaiNLP/pythainlp/)
6158

6259
### ความสามารถ
6360
- ตัดคำภาษาไทย
@@ -84,19 +81,19 @@ Natural language processing หรือ การประมวลภาษา
8481
$ pip install pythainlp
8582
```
8683

87-
อ่านเพิ่มเติมใน [https://sites.google.com/view/pythainlp/ภาษาไทย/install](https://sites.google.com/view/pythainlp/ภาษาไทย/install)
88-
89-
9084
### เอกสารการใช้งาน
9185

92-
อ่านได้ที่ [https://sites.google.com/view/pythainlp/ภาษาไทย](https://sites.google.com/view/pythainlp/ภาษาไทย)
86+
อ่านได้ที่ [https://github.com/PyThaiNLP/pythainlp/tree/dev/docs](https://github.com/PyThaiNLP/pythainlp/tree/dev/docs)
9387

9488
### License
9589

9690
Apache Software License 2.0
9791

92+
พัฒนาโดย PyThaiNLP
93+
94+
### Logo
9895

99-
พัฒนาโดย นาย วรรณพงษ์ ภัททิยไพบูลย์
96+
ออกแบบโดยคุณ วรุตม์ พสุธาดล จากการประกวดที่ https://www.facebook.com/groups/408004796247683/permalink/475864542795041/ และ https://www.facebook.com/groups/408004796247683/permalink/474262752955220/
10097

10198
### สนับสนุน
10299

README.rst

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
=========
2-
PyThaiNLP 1.5
3-
=========
1+
================
2+
PyThaiNLP 1.6.0
3+
================
44

55
Thai natural language processing in Python.
66

@@ -15,17 +15,10 @@ It supports both Python 2.7 and Python 3.
1515

1616
pip install pythainlp
1717

18-
Homepags : `https://sites.google.com/view/pythainlp/ <https://sites.google.com/view/pythainlp/>`_
1918

2019
GitHub : https://github.com/wannaphongcom/pythainlp
2120

22-
Development Lead
23-
----------------
2421

25-
* Wannaphong Phatthiyaphaibun <[email protected]>
26-
27-
28-
License
29-
~~~~~~~
22+
**License**
3023

3124
Apache Software License 2.0

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ install:
1818

1919
test_script:
2020
- "%PYTHON%/Scripts/pip.exe --version"
21-
- "%PYTHON%/python.exe setup.py test"
21+
- "%PYTHON%/python.exe setup.py test"

docs/pythainlp-1-5-eng.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,28 @@ d=word_tokenize(text,engine='pylexto') # ['ผม', 'รัก', 'คุณ', '
4141
e=word_tokenize(text,engine='newmm') # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คนไทย', 'รัก', 'ภาษาไทย', 'ภาษา', 'บ้านเกิด']
4242
```
4343

44+
#### dict_word_tokenize
45+
46+
```python
47+
from pythainlp.tokenize import dict_word_tokenize
48+
dict_word_tokenize(text,file,engine)
49+
```
50+
51+
A command for tokenize by using user-defined information.
52+
53+
text : str
54+
55+
file : name file data using in tokenize.
56+
57+
engine
58+
59+
- newmm
60+
- wordcutpy : using wordcutpy (https://github.com/veer66/wordcutpy)
61+
- mm
62+
- longest-matching
63+
64+
Example https://gist.github.com/wannaphongcom/1e862583051bf0464b6ef4ed592f739c
65+
4466
#### sent_tokenize
4567

4668
Thai Sentence Tokenizer
@@ -238,7 +260,7 @@ credit Korakot Chaovavanich (from https://gist.github.com/korakot/0b772e09340cac
238260
**Example**
239261

240262
```python
241-
>>> from pythainlp.soundex import LK82
263+
>>> from pythainlp.soundex import LK82,Udom83
242264
>>> print(LK82('รถ'))
243265
3000
244266
>>> print(LK82('รด'))

docs/pythainlp-1-5-thai.md

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,20 @@ pip install pythainlp
1616

1717
**วิธีติดตั้งสำหรับ Windows**
1818

19-
ให้ทำการติดตั้ง pyicu โดยใช้ไฟล์ .whl จาก [http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyicu](http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyicu)
19+
การติดตั้ง pythainlp บน windows ต้องติดตั้ง pyicu ซึ่งทำได้ยากมาก
20+
วิธีที่ง่ายที่สุดคือใช้ wheel
2021

21-
หากใช้ python 3.5 64 bit ให้โหลด PyICU‑1.9.7‑cp35‑cp35m‑win_amd64.whl แล้วเปิด cmd ใช้คำสั่ง
22+
1. [http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyicu](http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyicu) แล้ว download wheel ตาม python ตัวเองเช่น
23+
ผมใช้ python x64 3.6.1 บน Windows ก็ให้ใช้ PyICU‑1.9.7‑cp36‑cp36m‑win_amd64.whl
2224

23-
```
24-
pip install PyICU‑1.9.7‑cp35‑cp35m‑win_amd64.whl
25-
```
25+
2. `pip install PyICU‑1.9.7‑cp36‑cp36m‑win_amd64.whl`
2626

27-
แล้วจึงใช้
28-
29-
```
30-
pip install pythainlp
31-
```
27+
3. `pip install pythainlp`
3228

3329
**ติดตั้งบน Mac**
3430

31+
** แนะนำให้ใช้ icu 58.2 เนื่องจาก icu 59.1 มาปัญหากับ PyICU **
32+
3533
```sh
3634
$ brew install icu4c --force
3735
$ brew link --force icu4c
@@ -57,7 +55,7 @@ text คือ ข้อความในรูปแบบสตริง str
5755
engine คือ ระบบตัดคำไทย ปัจจุบันนี้ PyThaiNLP ได้พัฒนามี 6 engine ให้ใช้งานกันดังนี้
5856

5957
1. icu - engine ตัวดั้งเดิมของ PyThaiNLP (ความแม่นยำต่ำ) และเป็นค่าเริ่มต้น
60-
2. dict - เป็นการตัดคำโดยใช้พจานุกรมจาก thaiword.txt ใน corpus (ความแม่นยำปานกลาง) จะคืนค่า False หากข้อความนั้นไม่สามารถตัดคำได้
58+
2. dict - เป็นการตัดคำโดยใช้พจานุกรมจาก thaiword.txt ใน corpus (ความแม่นยำปานกลาง) **จะคืนค่า False หากข้อความนั้นไม่สามารถตัดคำได้**
6159
3. longest-matching ใช้ Longest matching ในการตัดคำ
6260
4. mm - ใช้ Maximum Matching algorithm ในการตัดคำภาษาไทย - API ชุดเก่า
6361
5. newmm - ใช้ Maximum Matching algorithm ในการตัดคำภาษาไทย โค้ดชุดใหม่ โดยใช้โค้ดคุณ Korakot Chaovavanich จาก https://www.facebook.com/groups/408004796247683/permalink/431283740586455/ มาพัฒนาต่อ
@@ -77,8 +75,31 @@ b=word_tokenize(text,engine='dict') # ['ผม', 'รัก', 'คุณ', 'น
7775
c=word_tokenize(text,engine='mm') # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คนไทย', 'รัก', 'ภาษาไทย', 'ภาษา', 'บ้านเกิด']
7876
d=word_tokenize(text,engine='pylexto') # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คนไทย', 'รัก', 'ภาษาไทย', 'ภาษา', 'บ้านเกิด']
7977
e=word_tokenize(text,engine='newmm') # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คนไทย', 'รัก', 'ภาษาไทย', 'ภาษา', 'บ้านเกิด']
78+
g=word_tokenize(text,engine='wordcutpy') # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คน', 'ไทย', 'รัก', 'ภาษา', 'ไทย', 'ภาษา', 'บ้านเกิด']
8079
```
8180

81+
#### dict_word_tokenize
82+
83+
```python
84+
from pythainlp.tokenize import dict_word_tokenize
85+
dict_word_tokenize(text,file,engine)
86+
```
87+
88+
เป็นคำสั่งสำหรับตัดคำโดยใช้ข้อมูลที่ผู้ใช้กำหนด
89+
90+
text คือ ข้อความที่ต้องการตัดคำ
91+
92+
file คือ ที่ตั้งไฟล์ที่ต้องการมาเป็นฐานข้อมูลตัดคำ
93+
94+
engine คือ เครื่องมือตัดคำ
95+
96+
- newmm ตัดคำด้วย newmm
97+
- wordcutpy ใช้ wordcutpy (https://github.com/veer66/wordcutpy) ในการตัดคำ
98+
- mm ตัดคำด้วย mm
99+
- longest-matching ตัดคำโดยใช้ longest matching
100+
101+
ตัวอย่างการใช้งาน https://gist.github.com/wannaphongcom/1e862583051bf0464b6ef4ed592f739c
102+
82103
#### sent_tokenize
83104

84105
ใช้ตัดประโยคภาษาไทย
@@ -338,7 +359,7 @@ from pythainlp.change import *
338359
**การใช้งาน**
339360

340361
```python
341-
>>> from pythainlp.soundex import LK82
362+
>>> from pythainlp.soundex import LK82,Udom83
342363
>>> print(LK82('รถ'))
343364
3000
344365
>>> print(LK82('รด'))
@@ -374,7 +395,7 @@ from pythainlp.sentiment import sentiment
374395
sentiment(str)
375396
```
376397

377-
รับค่า str ส่งออกเป็น pos , neg หรือ neutral
398+
รับค่า str ส่งออกเป็น pos , neg
378399

379400
### Util
380401

0 commit comments

Comments
 (0)