Skip to content

Commit 8f7ac10

Browse files
authored
Use Keep A Changelog style (#1310)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent c6d19d6 commit 8f7ac10

5 files changed

Lines changed: 185 additions & 124 deletions

File tree

CHANGELOG.md

Lines changed: 175 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -4,116 +4,180 @@ SPDX-FileType: DOCUMENTATION
44
SPDX-License-Identifier: CC0-1.0
55
---
66

7+
<!-- markdownlint-disable MD024 -->
8+
79
# Changelog
810

9-
Notable changes between versions.
10-
11-
- For full release notes, see:
12-
<https://github.com/PyThaiNLP/pythainlp/releases>
13-
- For detailed commit changes, see:
14-
<https://github.com/PyThaiNLP/pythainlp/compare/v5.2.0...dev>
15-
(select tags to compare)
16-
17-
## Version 5.2.0 -> dev
18-
19-
Minimum required version is now 3.9.
20-
Support for Python 3.7 and 3.8 has been removed.
21-
Added official support and CI testing for Python 3.14.
22-
23-
Some features and fixes in this version are AI-assisted.
24-
See PR for prompt and details.
25-
26-
- Fix `royin` romanization #1172
27-
- Fix final consonant classification in `check_marttra()` #1173
28-
- Lazy load dictionaries to reduce memory usage #1186
29-
- Fix Kho Khon alphabet issue in `tltk` transliteration #1187
30-
- Migrate configurations to pyproject.toml #1188 #1226 #1239
31-
- Update type hints; Use Python 3.9 features #1189 #1190 & etc.
32-
- Remove duplicated entries in volubilis dictionary #1200
33-
- Remove star imports #1207
34-
- Remove `requests` dependency #1211
35-
- Make package zip-safe #1212
36-
- Ensure thread-safety for tokenizers #1213
37-
- Add Thai-NNER integration with top-level entity filtering #1221
38-
- Reorganize noauto test suite by dependency groups
39-
(torch, tensorflow, onnx, cython, network) #1290
40-
- Add BLEU, ROUGE, WER, and CER metrics to pythainlp.benchmarks #1295
41-
- Add `check_khuap_klam` to `pythainlp.util` for checking
42-
Thai consonant clusters #1308
43-
- Add Attaparse engine to dependency parser
44-
(`dependency_parsing`, engine="attaparse") #1303
45-
- `get_corpus_path()` now respects `PYTHAINLP_OFFLINE` env var (same semantics
46-
as `HF_HUB_OFFLINE`): when set, raises `FileNotFoundError` if the corpus is
47-
not already cached locally; when unset, auto-downloads as before #1306
48-
- Added `pythainlp.is_offline_mode()` helper function (mirrors
49-
`huggingface_hub.is_offline_mode()`) #1306
50-
- `PYTHAINLP_DATA` is now the preferred env var for the data directory
51-
(same pattern as `NLTK_DATA`); `PYTHAINLP_DATA_DIR` is deprecated
52-
and will emit a `DeprecationWarning` #1306
53-
- Callers raise `FileNotFoundError` with download instructions when a corpus
54-
path cannot be resolved (e.g. download failed) #1306
55-
- Improved documentation; code cleanup; more tests
56-
57-
## Version 5.1.2 -> 5.2.0
58-
59-
- Add pythainlp.translate.word_translate #1102
60-
- Update Dockerfile #1049
61-
- Add Words Spelling Correction using Char2Vec #1075
62-
- Add Thailand Ancient Currency Converter #1113
63-
- Add B-K/umt5-thai-g2p-v2-0.5k #1140
64-
- Add budoux #1161
65-
- Remove conceptnet #1103
66-
- fix the connectivity of cli commands #1154
67-
- Fix Docker build failure, add docker compose file
68-
for convenience #1132
69-
70-
## Version 5.1.1 -> 5.1.2
71-
72-
- Update romanize docs and keep space #1110
73-
74-
## Version 5.1.0 -> 5.1.1
75-
76-
- PR Description: Refactor thai_consonants_all to
77-
use set in syllable.py #1087
78-
- ThaiTransliterator: Select 1D CPU int64 tensor device #1089
79-
80-
## Version 5.0.5 -> 5.1.0
81-
82-
- Add Thai Discourse Treebank postag #910
83-
- Add Thai Universal Dependency Treebank postag #916
84-
- Add Thai G2P v2 Grapheme-to-Phoneme model #923
85-
- Add support for list of strings as input
86-
to sent_tokenize() #927
87-
- Add pythainlp.tools.safe_print to handle UnicodeEncodeError
88-
on console #969
89-
- Fix collate() to consider tonemark in ordering #926
90-
- Fix nlpo3.load_dict() that never print error msg when
91-
not success #979
92-
- Add Thai Solar Date convert to Thai Lunar Date #998
93-
- Add Thai pangram text #1045
94-
- Remove clause_tokenize #1024
95-
96-
## Version 5.0.4 -> 5.0.5
97-
98-
- Add clause_tokenize warnings #1026
99-
- Fix maiyamok() that expanding the wrong word #962
100-
101-
## Version 5.0.3 -> 5.0.4
102-
103-
- Fix: pythainlp.util.maiyamok does not duplicate words
104-
when more than one Maiyamok is used #917
105-
106-
## Version 5.0.2 -> 5.0.3
107-
108-
- Fix: empty string ('') added when using word_tokenize with
109-
join_broken_num=True #912
110-
111-
## Version 5.0.1 -> 5.0.2
112-
113-
- Fix: crfcut: Ensure splitting of sentences using terminal
114-
punctuation #905
115-
116-
## Version 5.0.0 -> 5.0.1
117-
118-
- Fix: delay calling syllable_tokenize to avoid
119-
pycrfsuite ImportError #901
11+
All notable changes to this project are documented in this file.
12+
13+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
14+
and this project adheres to
15+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
16+
17+
- Full release notes: <https://github.com/PyThaiNLP/pythainlp/releases>
18+
- Commit history: <https://github.com/PyThaiNLP/pythainlp/compare/v5.2.0...HEAD>
19+
20+
## [Unreleased]
21+
22+
This release focuses on stability and performance, featuring optimized memory
23+
efficiency and standardized error messaging. We’ve expanded our test suite to
24+
include Python 3.14 and broadened type hint support for a better developer
25+
experience.
26+
27+
The minimum requirement is now Python 3.9.
28+
29+
### Added
30+
31+
- Tapsai et al. 2020 soundex (#1175)
32+
- Thai-NNER integration with top-level entity filtering (#1221)
33+
- BLEU, ROUGE, WER, and CER metrics to `pythainlp.benchmarks` (#1295)
34+
- Attaparse engine to dependency parser
35+
(`dependency_parsing`, engine="attaparse") (#1303)
36+
- `pythainlp.is_offline_mode()` helper function (#1306)
37+
- Thai consonant cluster detection (`check_khuap_klam`) (#1308)
38+
39+
### Changed
40+
41+
- Lazy load dictionaries to reduce memory usage (#1186)
42+
- Migrate configurations to `pyproject.toml` (#1188, #1226, #1239)
43+
- Update type hints; use Python 3.9 features (#1189, #1190)
44+
- Make package zip-safe (#1212)
45+
- Ensure thread-safety for tokenizers (#1213)
46+
- Reorganize "noauto" test suite by dependency groups
47+
(torch, tensorflow, onnx, cython, network) (#1290)
48+
- `get_corpus_path()` now respects `PYTHAINLP_OFFLINE` env var
49+
(follows `HF_HUB_OFFLINE` convention from Hugging Face):
50+
raises `FileNotFoundError` if the corpus is not cached locally
51+
when the var is set; auto-downloads otherwise (#1306)
52+
- Callers raise `FileNotFoundError` with download instructions when
53+
a corpus path cannot be resolved (#1306)
54+
55+
### Deprecated
56+
57+
- `PYTHAINLP_DATA_DIR` env var; use `PYTHAINLP_DATA` instead
58+
(follows `NLTK_DATA` convention from NLTK) (#1306)
59+
60+
### Removed
61+
62+
- Duplicated entries in Volubilis dictionary (#1200)
63+
- Star imports (#1207)
64+
- `requests` dependency (#1211)
65+
66+
### Fixed
67+
68+
- Consonant cluster boundary issue in `royin` romanization (#1172)
69+
- Final consonant classification in `check_marttra()` (#1173)
70+
- Kho Khon alphabet issue in `tltk` transliteration (#1187)
71+
72+
## [5.2.0] - 2025-12-20
73+
74+
### Added
75+
76+
- `pythainlp.translate.word_translate` (#1102)
77+
- Words spelling correction using Char2Vec (#1075)
78+
- Thailand ancient currency converter (#1113)
79+
- B-K/umt5-thai-g2p-v2-0.5k model (#1140)
80+
- budoux integration (#1161)
81+
- Docker Compose file for convenience (#1132)
82+
83+
### Changed
84+
85+
- Update Dockerfile (#1049)
86+
87+
### Removed
88+
89+
- ConceptNet integration (#1103)
90+
91+
### Fixed
92+
93+
- Connectivity of CLI commands (#1154)
94+
- Docker build failure (#1132)
95+
96+
## [5.1.2] - 2025-05-09
97+
98+
### Changed
99+
100+
- Romanize docs; keep space (#1110)
101+
102+
## [5.1.1] - 2025-03-31
103+
104+
### Changed
105+
106+
- Refactor `thai_consonants_all` to use set in `syllable.py` (#1087)
107+
- `ThaiTransliterator`: select 1D CPU int64 tensor device (#1089)
108+
109+
## [5.1.0] - 2025-02-25
110+
111+
### Added
112+
113+
- Thai Discourse Treebank POS tag (#910)
114+
- Thai Universal Dependency Treebank POS tag (#916)
115+
- Thai G2P v2 grapheme-to-phoneme model (#923)
116+
- Support for list of strings as input to `sent_tokenize()` (#927)
117+
- `pythainlp.tools.safe_print` to handle `UnicodeEncodeError`
118+
on console (#969)
119+
- Thai Solar Date to Thai Lunar Date conversion (#998)
120+
- Thai pangram text (#1045)
121+
122+
### Removed
123+
124+
- `clause_tokenize` (#1024)
125+
126+
### Fixed
127+
128+
- `collate()` to consider tone mark in ordering (#926)
129+
- `nlpo3.load_dict()` not printing error when unsuccessful (#979)
130+
131+
## [5.0.5] - 2024-12-14
132+
133+
### Changed
134+
135+
- Add `clause_tokenize` deprecation warnings (#1026)
136+
137+
### Fixed
138+
139+
- `maiyamok()` expanding the wrong word (#962)
140+
141+
## [5.0.4] - 2024-06-02
142+
143+
### Fixed
144+
145+
- `pythainlp.util.maiyamok` not duplicating words when more
146+
than one Maiyamok is used (#917)
147+
148+
## [5.0.3] - 2024-05-12
149+
150+
### Fixed
151+
152+
- Empty string added when using `word_tokenize` with
153+
`join_broken_num=True` (#912)
154+
155+
## [5.0.2] - 2024-04-03
156+
157+
### Fixed
158+
159+
- `crfcut`: ensure splitting of sentences using terminal
160+
punctuation (#905)
161+
162+
## [5.0.1] - 2024-02-10
163+
164+
### Fixed
165+
166+
- Delay calling `syllable_tokenize` to avoid
167+
`pycrfsuite` import error (#901)
168+
169+
## [5.0.0] - 2024-02-10
170+
171+
- See <https://github.com/PyThaiNLP/pythainlp/releases/tag/v5.0.0>
172+
173+
[Unreleased]: https://github.com/PyThaiNLP/pythainlp/compare/v5.2.0...HEAD
174+
[5.2.0]: https://github.com/PyThaiNLP/pythainlp/compare/v5.1.2...v5.2.0
175+
[5.1.2]: https://github.com/PyThaiNLP/pythainlp/compare/v5.1.1...v5.1.2
176+
[5.1.1]: https://github.com/PyThaiNLP/pythainlp/compare/v5.1.0...v5.1.1
177+
[5.1.0]: https://github.com/PyThaiNLP/pythainlp/compare/v5.0.5...v5.1.0
178+
[5.0.5]: https://github.com/PyThaiNLP/pythainlp/compare/v5.0.4...v5.0.5
179+
[5.0.4]: https://github.com/PyThaiNLP/pythainlp/compare/v5.0.3...v5.0.4
180+
[5.0.3]: https://github.com/PyThaiNLP/pythainlp/compare/v5.0.2...v5.0.3
181+
[5.0.2]: https://github.com/PyThaiNLP/pythainlp/compare/v5.0.1...v5.0.2
182+
[5.0.1]: https://github.com/PyThaiNLP/pythainlp/compare/v5.0.0...v5.0.1
183+
[5.0.0]: https://github.com/PyThaiNLP/pythainlp/releases/tag/v5.0.0

pythainlp/braille/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
_v1: list[str] = ["เ-tอ", "เ-ีtย", "เ-ืtอ", "-ัtว", "เ-tา", "เ-tาะ"]
139139

140140
# Create trie for efficient pattern matching
141-
char_trie = Trie(list(thai_braille_mapping_dict.keys()) + _v1 + [" ", "<N>"])
141+
char_trie: Trie = Trie(list(thai_braille_mapping_dict.keys()) + _v1 + [" ", "<N>"])
142142

143143
# Build vowel replacement patterns
144144
_vowel_patterns: list[str] = [

pythainlp/generate/thai2fit.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@
6868
" CLI: thainlp data get wiki_itos_lstm"
6969
)
7070

71-
# Security Note: This loads a pickle file from PyThaiNLP's trusted corpus.
72-
# The file is downloaded from PyThaiNLP's official repository with MD5 verification.
73-
# Users should only use corpus files from trusted sources.
74-
# WARNING: Pickle deserialization can execute arbitrary code if the file is malicious.
71+
# Loads a pickle file from PyThaiNLP's official repository with MD5 verification.
72+
# WARNING:
73+
# Pickle deserialization can execute arbitrary code if the file is malicious.
74+
# Users should only use files from trusted sources.
7575
with open(thwiki["itos_fname"], "rb") as f:
7676
thwiki_itos: list[str] = pickle.load(f) # noqa: S301
7777
thwiki_vocab: "Vocab" = fastai.text.transform.Vocab(thwiki_itos)

pythainlp/transliterate/iso_11940.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,10 @@
9797
}
9898

9999
_punctuation_and_digits: dict[str, str] = {
100-
# ฯ can has two meanings in ISO 11940.
101-
# If it is for abbreviation, it is paiyan noi.
102-
# If it is for sentence termination, it is angkhan diao.
103-
# Without semantic analysis, they cannot be distinguished from each other.
104-
# In this simple implementation, we decided to always treat ฯ as paiyan noi.
105-
# We commented out angkhan diao line to remove it from the dictionary
106-
# and avoid having duplicate keys.
100+
# ฯ can mean abbreviation (paiyan noi) or sentence termination (angkhan diao).
101+
# Without semantic analysis, they cannot be distinguished.
102+
# Treat ฯ as paiyan noi here; angkhan diao entry is excluded to avoid
103+
# duplicate keys.
107104
"ๆ": "«",
108105
"ฯ": "ǂ", # paiyan noi: U+01C2 ǂ Alveolar Click; ICU uses ‡ (double dagger)
109106
"๏": "§",

pythainlp/util/syllable.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
pattern: Pattern[str] = re.compile("เ(.*)า", re.U) # เ-า is live syllable
3838

3939
_check_1: list[str] = []
40-
# These spelling consonant ares live syllables.
40+
# These spelling consonants are live syllables.
4141
for i in ["กง", "กน", "กม", "เกย", "เกอว"]:
4242
_check_1.extend(spelling_class[i])
4343

0 commit comments

Comments
 (0)