-
Notifications
You must be signed in to change notification settings - Fork 287
Improved custom dict tokenization #77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved custom dict tokenization #77
Conversation
1 similar comment
|
ความคิดเห็นผมนะครับ ตรงข้อ 3 เป็นไปได้ไหมครับ ที่จะไม่ต้องสร้าง class Tokenizer ใหม่ขึ้นมาครับ |
|
@wannaphongcom ผมได้ลองหา workaround มาแล้ว และก็ได้วิธีที่สามารถให้ไม่ต้องสร้าง class ใหม่แล้วก็ได้ อาจจะให้เป็น temporary solution ไปก่อนก็ได้นะครับ แต่ในระยะยาว ผมสนับสนุนให้สร้าง class ดีกว่าครับ เพราะหากดูตาม design แล้ว ตัว engine แทบทุกตัวต้องใช้ Trie เป็น source ในการตัดคำ ฉะนั้นการสร้าง class ที่มี property ถ้าน้องต้นตาล ok กับ workaround นี้แล้ว เดี๋ยวผมจะช่วยแก้ engines ที่เหลือ ให้ compatible กับทางออกใหม่นี้ให้ครับ ขอบคุณครับ |
|
ขอบคุณครับ ผมลองแล้ว ok กับ workaround นี้ 👍 |
…roved_custom_dict_tokenization
…ew method of using custom dict to tokenize words
|
@wannaphongcom น้องต้นตาลครับพอดีจากแนวทางที่แล้วที่ได้นำเสนอไป มันแอบมีประเด็นเรื่องของที่ว่า ในกรณีที่สมมุติไปเรียกใช้ pythainlp ใน jupyter notebook แล้วถ้าผมทำการแก้ไขคำศัพท์หรือเพิ่มเข้าไปในไฟล์ สุดท้ายผมก็เลยคิดว่าแนวทางล่าสุดนี้น่าจะดีที่สุด หากไม่ต้องการสร้าง class ก็คือผมได้สร้าง function ยังไงลองดู code ที่แก้ไขแล้วคิดเห็นยังไงบอกนะครับ |
|
@smeeklai ถ้าดูที่ dict_word_tokenize(text,file='',engine="newmm",data=[''],data_type="file")จะเห็นว่า มีส่วนพารามิเตอร์ data กับ data_type ครับ ผมว่าจะเขียนให้สามารถตัดคำที่ต้องการได้จากข้อมูล list ที่ใส่เข้าไปใน api ตัวนี้ด้วยครับ แต่ผมยังไม่มีเวลาทำต่อครับ น่าจะแก้ไขประเด็นข้างบนได้ด้วยการใช้ list แทนไฟล์ครับ |
wannaphong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
สวัสดีครับน้องต้นตาล
ผมปรับจุดที่แก้ไขได้ให้นิดหน่อยและช่วย improve ตรงส่วนของการตัดคำโดยใช้ custom dict ให้นิดหน่อยน่ะครับ
สิ่งที่แก้ไข:
f.close()ออกไป เพราะหากใช้ open แล้ว f จะปิดเองอัตโนมัต หลังออกจาก with statementผมก็เลยแก้ไขไฟล์ init.py ใน folder tokenize โดยเพิ่ม class Tokenizer ขึ้นมา ซึ่ง user จะ initiate object นี้แค่ครั้งเดียว พร้อมส่ง custom dict หรือใหม่ก็ได้ จากนั้นก็เรียกใช้ word_tokenize() ไปตัดคำได้เลย ตอนนี้ผมทำแค่ newmm ก่อน เพราะผมไม่กล้าแก้ code เก่ามากเกินไป เพราะมันค่อนข้างเปลี่ยน behevior ของตัว tokenize ไปเลย จากเมื่อก่อนแค่ import function แล้วก็สามารถเรียกใช้ได้เลย อยากจะฟังความเห็นน้องต้นตาลก่อนว่ายังไงดีแล้วค่อยช่วยแก้ไขให้ต่อไปครับ
ยังไงรบกวนน้องต้นตาล review อีกที ก็ได้ครับ ขอบคุณครับ ไม่เคย pull request มาก่อน ถ้าทำไรผิดยังไงก็ขอโทษด้วยนะครับ ยังไม่ได้ test กับ python2 ด้วยนะครับ