Skip to content

bug: thai_word_tone_detector #1120

@geebee101

Description

@geebee101

Description

Traceback (most recent call last):
File "/mnt/c/Users/gpr_y/Documents/_z__py4nux/nlp/thainlp/tone_quant.py", line 32, in
print(thai_word_tone_detector('อีก'))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/geebee/anaconda3/lib/python3.11/site-packages/pythainlp/util/thai.py", line 200, in thai_word_tone_detector
return [(i, tone_detector(i.replace("หฺ", "ห"))) for i in _pronunciate]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/geebee/anaconda3/lib/python3.11/site-packages/pythainlp/util/thai.py", line 200, in
return [(i, tone_detector(i.replace("หฺ", "ห"))) for i in _pronunciate]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/geebee/anaconda3/lib/python3.11/site-packages/pythainlp/util/syllable.py", line 282, in tone_detector
consonant_ending = _check_sonorant_syllable(syllable)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/geebee/anaconda3/lib/python3.11/site-packages/pythainlp/util/syllable.py", line 234, in _check_sonorant_syllable
if _sonorant[-1] == consonants[-2]:
~~~~~~~~~^^^^
IndexError: list index out of range
(base)

Expected results

l, m, h, r, f or empty

note that for other words it works as expected in my code

Current results

see stacktrace in description

Steps to reproduce

thai_word_tone_detector('อีก')

PyThaiNLP version

pythainlp-5.1.2

Python version

Python 3.11.7

Operating system and version

Ubuntu 20.04.6 LTS (on wsl2)

More info

No response

Possible solution

No response

Files

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbugs in the libraryhelp wantedno contributor yet

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions