Replace TNC with Phupha word frequency dataset filtered by ORST words #1284
+62,440
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.



What do these changes do
Replaces Thai National Corpus (TNC) word frequencies in the spell checker with Phupha dataset filtered by Royal Society of Thailand (ORST) word list.
What was wrong
TNC word frequency dictionary captured real-world language usage, including misspelled words. The spell checker trained on this data could suggest incorrect spellings.
How this fixes it
Added Phupha corpus module:
pythainlp/corpus/phupha.py- word frequency accessor functionspythainlp/corpus/phupha_word_freqs.txt- 62,264 words from Common Crawl CorpusModified spell checker:
pythainlp/spell/pn.py- filters Phupha bythai_orst_wordsat initializationExample:
Tests:
test_phupha()- verifies corpus module functionstest_issue_680_orst_filtering()- validates ORST filtering behaviortest_norvig_spell_checker()- checks dictionary size constraintsLimitation: Compound words not in ORST (e.g., "ปลาอินทรีย์") won't be suggested. This is expected when restricting to authoritative dictionary.
Your checklist for this pull request
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.