Skip to content
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

อยากเพิ่มคำใน pythainlp.spell ครับ #119

Closed
dewringmaster opened this issue Sep 24, 2018 · 8 comments
Closed
Labels
question asking questions/giving suggestions

Comments

@dewringmaster
Copy link

สวัสดีครับผม จากที่ได้ทดสอบ โปรแกรมสามารถแก้คำผิดพวกจังหวัดได้ดีมาก แต่ยังไม่สามารถแก้เขต แขวง ได้ ผมสามารถสร้าง dict ลงให้เพิ่มให้ตัวโปรแกรมได้ไหมคครับ

@wannaphong
Copy link
Member

ทำได้โดยการเพิ่มคำลงไฟล์ https://github.com/PyThaiNLP/pythainlp/blob/dev/pythainlp/corpus/thaiword.txt ครับ

@wannaphong wannaphong added the question asking questions/giving suggestions label Sep 24, 2018
@dewringmaster
Copy link
Author

ในไฟล์ thaiword.txt เราจำเป็นต้องเรียงตามพจนานุกรมไหมครับผม ขอบคุณครับ

@wannaphong
Copy link
Member

ไม่ครับ

@dewringmaster
Copy link
Author

hunspell นี้เราจะไม่สามารถ fix คำที่ต้องการแก้ใช้ไหมครับ

ถ้ามี set คำที่เราต้องการแก้จำกัดอยู่แล้ว ใช้แค่ engine pn เพียงพอแล้วใช้ไหมครับ

@wannaphong
Copy link
Member

ใช่ครับ

@bact
Copy link
Member

bact commented Oct 24, 2018

น่าจะได้คำตอบแล้ว
ปิด issue นี้ได้ไหมครับ

@bact
Copy link
Member

bact commented Oct 27, 2018

จากการแก้ไข #137 จะทำให้การแก้ไขไฟล์ thaiword.txt ไม่มีผลต่อการทำงานของ pythainlp.corpus.pn.spell()

TODO: เพิ่ม spell checker class เพื่อให้ผู้ใช้สามารถระบุรายการคำ (พจนานุกรม) ได้เอง

@bact
Copy link
Member

bact commented Oct 29, 2018

ตอนนี้สามารถเขียนโปรแกรมปรับเปลี่ยนพจนานุกรมได้เองแล้วนะครับ
โดย class NorvigSpellChecker ใน pythainlp.spell.pn จะรับพารามิเตอร์ custom_dict เป็น List ของ Tuple (คำ, ความถี่) เช่น [("นก", 35), ("หนู", 20)]

from pythainlp.spell.pn import NorvigSpellChecker

mydict = [("นก", 35), ("หนู", 20)]
checker = NorvigSpellChecker(custom_dict=mydict)

checker.spell("นภ")

ดูตัวอย่างการใช้งานที่
https://github.com/PyThaiNLP/pythainlp/blob/dev/examples/spell.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question asking questions/giving suggestions
Projects
None yet
Development

No branches or pull requests

3 participants