@@ -16,22 +16,20 @@ pip install pythainlp
16
16
17
17
** วิธีติดตั้งสำหรับ Windows**
18
18
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
20
21
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
22
24
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 `
26
26
27
- แล้วจึงใช้
28
-
29
- ```
30
- pip install pythainlp
31
- ```
27
+ 3 . ` pip install pythainlp `
32
28
33
29
** ติดตั้งบน Mac**
34
30
31
+ ** แนะนำให้ใช้ icu 58.2 เนื่องจาก icu 59.1 มาปัญหากับ PyICU **
32
+
35
33
``` sh
36
34
$ brew install icu4c --force
37
35
$ brew link --force icu4c
@@ -57,7 +55,7 @@ text คือ ข้อความในรูปแบบสตริง str
57
55
engine คือ ระบบตัดคำไทย ปัจจุบันนี้ PyThaiNLP ได้พัฒนามี 6 engine ให้ใช้งานกันดังนี้
58
56
59
57
1 . icu - engine ตัวดั้งเดิมของ PyThaiNLP (ความแม่นยำต่ำ) และเป็นค่าเริ่มต้น
60
- 2 . dict - เป็นการตัดคำโดยใช้พจานุกรมจาก thaiword.txt ใน corpus (ความแม่นยำปานกลาง) จะคืนค่า False หากข้อความนั้นไม่สามารถตัดคำได้
58
+ 2 . dict - เป็นการตัดคำโดยใช้พจานุกรมจาก thaiword.txt ใน corpus (ความแม่นยำปานกลาง) ** จะคืนค่า False หากข้อความนั้นไม่สามารถตัดคำได้**
61
59
3 . longest-matching ใช้ Longest matching ในการตัดคำ
62
60
4 . mm - ใช้ Maximum Matching algorithm ในการตัดคำภาษาไทย - API ชุดเก่า
63
61
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') # ['ผม', 'รัก', 'คุณ', 'น
77
75
c= word_tokenize(text,engine = ' mm' ) # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คนไทย', 'รัก', 'ภาษาไทย', 'ภาษา', 'บ้านเกิด']
78
76
d= word_tokenize(text,engine = ' pylexto' ) # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คนไทย', 'รัก', 'ภาษาไทย', 'ภาษา', 'บ้านเกิด']
79
77
e= word_tokenize(text,engine = ' newmm' ) # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คนไทย', 'รัก', 'ภาษาไทย', 'ภาษา', 'บ้านเกิด']
78
+ g= word_tokenize(text,engine = ' wordcutpy' ) # ['ผม', 'รัก', 'คุณ', 'นะ', 'ครับ', 'โอเค', 'บ่', 'พวกเรา', 'เป็น', 'คน', 'ไทย', 'รัก', 'ภาษา', 'ไทย', 'ภาษา', 'บ้านเกิด']
80
79
```
81
80
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
+
82
103
#### sent_tokenize
83
104
84
105
ใช้ตัดประโยคภาษาไทย
@@ -338,7 +359,7 @@ from pythainlp.change import *
338
359
** การใช้งาน**
339
360
340
361
``` python
341
- >> > from pythainlp.soundex import LK82
362
+ >> > from pythainlp.soundex import LK82 ,Udom83
342
363
>> > print (LK82(' รถ' ))
343
364
ร3000
344
365
>> > print (LK82(' รด' ))
@@ -374,7 +395,7 @@ from pythainlp.sentiment import sentiment
374
395
sentiment(str )
375
396
```
376
397
377
- รับค่า str ส่งออกเป็น pos , neg หรือ neutral
398
+ รับค่า str ส่งออกเป็น pos , neg
378
399
379
400
### Util
380
401
0 commit comments