Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
a702618
Initial plan
Copilot Jan 6, 2026
a73cc76
Add Complete Soundex for Thai Words Similarity Analysis
Copilot Jan 6, 2026
5bf63fb
Fix indentation issues in complete_soundex.py
Copilot Jan 6, 2026
e797163
Remove overrides and implement algorithmic Complete Soundex (17/20 te…
Copilot Jan 6, 2026
c2f646f
Address code review feedback: improve exception handling and maintain…
Copilot Jan 6, 2026
98264f4
Fix: Remove fallback for syllable_tokenize to ensure correct behavior
Copilot Jan 6, 2026
13ed201
Fix complete_soundex bugs and remove syllable_tokenize dependency
Copilot Jan 6, 2026
9092437
Update complete_soundex.py
wannaphong Jan 6, 2026
4c56fcc
Refactor process_syllable to reduce complexity
Copilot Jan 7, 2026
ad49f98
Fix code quality issues: remove trailing whitespace and non-ASCII fun…
Copilot Jan 7, 2026
39b34d9
Changes before error encountered
Copilot Jan 11, 2026
291c5c9
Revert "Changes before error encountered"
bact Jan 12, 2026
c86a3a1
Fix whitespace
bact Jan 12, 2026
5480dd5
Merge branch 'dev' into copilot/add-complete-soundex-thai
bact Jan 12, 2026
6644dd1
Remove trailing spaces
bact Jan 12, 2026
b1e77ac
Complete algorithm validation and add Python 3.9+ type hints
Copilot Jan 12, 2026
5f96a39
Add complete_soundex_similarity function for phonetic similarity calc…
Copilot Jan 12, 2026
1ed48e7
Add documentation for complete_soundex and complete_soundex_similarit…
Copilot Jan 12, 2026
570b498
Improve documentation readability in soundex.rst
Copilot Jan 12, 2026
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
32 changes: 32 additions & 0 deletions docs/api/soundex.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,36 @@ prayut_and_somchaip

The `prayut_and_somchaip` module is designed for Thai-English cross-language transliterated word retrieval using the Soundex technique. It is particularly useful for matching transliterated words in both languages.

complete_soundex
~~~~~~~~~~~~~~~~
.. autofunction:: complete_soundex

The `complete_soundex` function implements the Complete Soundex algorithm for Thai word phonetic encoding based on Tapsai et al. (2020). Unlike traditional Soundex methods, it generates variable-length codes representing every syllable in a word.

Each syllable is encoded using a 7-character block structure:

* Initial Consonant (2 chars) - Phonetic grouping
* Vowel (2 chars) - Including length markers
* Final Consonant (1 char) - Sonorant clustering
* Tone (1 char) - Tone mark encoding
* Cluster Symbol (1 char) - Second consonant in clusters

The algorithm handles complex Thai phonetic patterns including ทร transformation, รร special rules, cluster detection, and implicit vowels. Multi-syllable words are automatically tokenized and encoded. This soundex is particularly effective for handling misspelled words, character variations, and similar pronunciations.

complete_soundex_similarity
~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autofunction:: complete_soundex_similarity

The `complete_soundex_similarity` function calculates the similarity between two Complete Soundex codes using character-wise comparison.

The similarity is computed using the formula:

S(X,Y) = Σ(sim(c_xi, c_yi)) / max(len(X), len(Y))

where sim = 1 if characters match at position i, else 0.

The result is normalized by the maximum length of the two codes, returning a float between 0.0 (no match) and 1.0 (perfect match). This function is useful for finding phonetically similar Thai words and handling spelling variations.

pythainlp.soundex.sound.word_approximation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. autofunction:: pythainlp.soundex.sound.word_approximation
Expand Down Expand Up @@ -66,4 +96,6 @@ References

.. [#prayut_and_somchaip] Prayut Suwanvisat, Somchai Prasitjutrakul. Thai-English Cross-Language Transliterated Word Retrieval using Soundex Technique. In 1998 [cited 2022 Sep 8]. Available from: https://www.cp.eng.chula.ac.th/~somchai/spj/papers/ThaiText/ncsec98-clir.pdf.

.. [#complete_soundex] Chalermpol Tapsai, Phayung Meesad, and Choochart Haruechaiyasak. 2020. `Complete Soundex for Thai Words Similarity Analysis <https://ph01.tci-thaijo.org/index.php/IT_Journal/article/view/241562/164358>`_. Information Technology Journal KMUTNB. 2020 June 30;16(1):46–59.

.. This enhanced documentation provides clear descriptions of all the modules within the `pythainlp.soundex` module, including their purposes and functionalities. Users can now better understand how to leverage these soundex algorithms for various phonetic matching tasks in the Thai language.
6 changes: 6 additions & 0 deletions pythainlp/soundex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@
"""

__all__ = [
"complete_soundex",
"complete_soundex_similarity",
"lk82",
"metasound",
"prayut_and_somchaip",
"soundex",
"udom83",
]

from pythainlp.soundex.complete_soundex import (
complete_soundex,
complete_soundex_similarity,
)
from pythainlp.soundex.lk82 import lk82
from pythainlp.soundex.metasound import metasound
from pythainlp.soundex.prayut_and_somchaip import prayut_and_somchaip
Expand Down
Loading
Loading