Skip to content

Commit 570b498

Browse files
Copilotwannaphong
andcommitted
Improve documentation readability in soundex.rst
Reformatted documentation for better readability: 1. complete_soundex section: - Split long paragraph into multiple sentences - Added bullet list for 7-character block structure - Improved organization of technical details 2. complete_soundex_similarity section: - Separated formula into its own indented block - Better formatting for mathematical formula - Clearer explanation of return values Changes improve documentation readability while maintaining all technical information. Co-authored-by: wannaphong <8536487+wannaphong@users.noreply.github.com>
1 parent 1ed48e7 commit 570b498

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

docs/api/soundex.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,31 @@ complete_soundex
4141
~~~~~~~~~~~~~~~~
4242
.. autofunction:: complete_soundex
4343

44-
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 using a 7-character block structure (Initial Consonant, Vowel, Final Consonant, Tone, Cluster Symbol). 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.
44+
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.
45+
46+
Each syllable is encoded using a 7-character block structure:
47+
48+
* Initial Consonant (2 chars) - Phonetic grouping
49+
* Vowel (2 chars) - Including length markers
50+
* Final Consonant (1 char) - Sonorant clustering
51+
* Tone (1 char) - Tone mark encoding
52+
* Cluster Symbol (1 char) - Second consonant in clusters
53+
54+
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.
4555

4656
complete_soundex_similarity
4757
~~~~~~~~~~~~~~~~~~~~~~~~~~~
4858
.. autofunction:: complete_soundex_similarity
4959

50-
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.
60+
The `complete_soundex_similarity` function calculates the similarity between two Complete Soundex codes using character-wise comparison.
61+
62+
The similarity is computed using the formula:
63+
64+
S(X,Y) = Σ(sim(c_xi, c_yi)) / max(len(X), len(Y))
65+
66+
where sim = 1 if characters match at position i, else 0.
67+
68+
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.
5169

5270
pythainlp.soundex.sound.word_approximation
5371
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)