Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ Notable changes between versions.
- For full release notes, see:
<https://github.com/PyThaiNLP/pythainlp/releases>
- For detailed commit changes, see:
<https://github.com/PyThaiNLP/pythainlp/compare/v5.1.1...dev> (select tags to compare)
<https://github.com/PyThaiNLP/pythainlp/compare/v5.1.2...dev> (select tags to compare)

## Version 5.1.1 -> Dev
## Version 5.1.2 -> Dev

[WIP]

## Version 5.1.1 -> 5.1.2

- Update romanize docs and keep space #1110

## Version 5.1.0 -> 5.1.1

- PR Description: Refactor thai_consonants_all to Use set in syllable.py #1087
Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ keywords:
- "Thai language"
- "Thai NLP"
license: Apache-2.0
version: 5.1.1
date-released: "2025-03-31"
version: 5.1.2
date-released: "2025-05-09"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pip install pythainlp

| Version | Description | Status |
|:------:|:--:|:------:|
| [5.1.1](https://github.com/PyThaiNLP/pythainlp/releases) | Stable | [Change Log](https://github.com/PyThaiNLP/pythainlp/issues/900) |
| [5.1.2](https://github.com/PyThaiNLP/pythainlp/releases) | Stable | [Change Log](https://github.com/PyThaiNLP/pythainlp/issues/900) |
| [`dev`](https://github.com/PyThaiNLP/pythainlp/tree/dev) | Release Candidate for 5.2 | [Change Log](https://github.com/PyThaiNLP/pythainlp/issues/1080) |

## Getting Started
Expand Down
2 changes: 1 addition & 1 deletion README_TH.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pip install pythainlp

| รุ่น | คำอธิบาย | สถานะ |
|:------:|:--:|:------:|
| [5.1.1](https://github.com/PyThaiNLP/pythainlp/releases) | Stable | [Change Log](https://github.com/PyThaiNLP/pythainlp/issues/900) |
| [5.1.2](https://github.com/PyThaiNLP/pythainlp/releases) | Stable | [Change Log](https://github.com/PyThaiNLP/pythainlp/issues/900) |
| [`dev`](https://github.com/PyThaiNLP/pythainlp/tree/dev) | Release Candidate for 5.2 | [Change Log](https://github.com/PyThaiNLP/pythainlp/issues/1080) |

ติดตามพวกเราบน [PyThaiNLP Facebook page](https://www.facebook.com/pythainlp/) เพื่อรับข่าวสารเพิ่มเติม
Expand Down
2 changes: 1 addition & 1 deletion codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"@type": "SoftwareSourceCode",
"name": "PyThaiNLP",
"description": "Thai Natural Language Processing in Python",
"version": "5.1.1",
"version": "5.1.2",
"author": [
{
"@type": "Person",
Expand Down
2 changes: 1 addition & 1 deletion pythainlp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-FileCopyrightText: 2016-2025 PyThaiNLP Project
# SPDX-FileType: SOURCE
# SPDX-License-Identifier: Apache-2.0
__version__ = "5.1.1"
__version__ = "5.1.2"

thai_consonants = "กขฃคฅฆงจฉชซฌญฎฏฐฑฒณดตถทธนบปผฝพฟภมยรลวศษสหฬอฮ" # 44 chars

Expand Down
17 changes: 11 additions & 6 deletions pythainlp/transliterate/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,19 @@ def romanize(
fallback_engine: str = DEFAULT_ROMANIZE_ENGINE,
) -> str:
"""
This function renders Thai words in the Latin alphabet or "romanization",
This function renders Thai word in the Latin alphabet or "romanization",
using the Royal Thai General System of Transcription (RTGS)
[#rtgs_transcription]_. RTGS is the official system published
by the Royal Institute of Thailand. (Thai: ถอดเสียงภาษาไทยเป็นอักษรละติน)

:param str text: Thai text to be romanized
:param str text: A Thai word to be romanized. \
The input should not include whitespace because \
the function is support subwords by spliting whitespace.
:param str engine: One of 'royin' (default), 'thai2rom', 'thai2rom_onnx, 'tltk', and 'lookup'. See more in options for engine section.
:param str fallback_engine: If engine equals 'lookup', use `fallback_engine` for words that are not in the transliteration dict.
No effect on other engines. Default to 'royin'.

:return: A string of Thai words rendered in the Latin alphabet.
:return: A string of a Thai word rendered in the Latin alphabet.
:rtype: str

:Options for engines:
Expand Down Expand Up @@ -53,6 +55,9 @@ def romanize(
romanize("ภาพยนตร์", engine="royin")
# output: 'phapn'

romanize("รส ดี", engine="royin") # subwords
# output: 'rot di'

romanize("ภาพยนตร์", engine="thai2rom")
# output: 'phapphayon'

Expand Down Expand Up @@ -87,9 +92,9 @@ def select_romanize_engine(engine: str):
else:
rom_engine = select_romanize_engine(engine)
trans_word = []
for word in text.split(' '):
trans_word.append(rom_engine(word))
new_word = ''.join(trans_word)
for subword in text.split(' '):
trans_word.append(rom_engine(subword))
new_word = ' '.join(trans_word)
return new_word


Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 5.1.1
current_version = 5.1.2
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@

setup(
name="pythainlp",
version="5.1.1",
version="5.1.2",
description="Thai Natural Language Processing library",
long_description=LONG_DESC,
long_description_content_type="text/markdown",
Expand Down