Skip to content

Romanize failed in some examples #485

@tann9949

Description

@tann9949

I was trying to romanize the word
จรวยพร
but the library raise an IndexError

from pythainlp.transliterate import romanize

romanize('จรวยพร')

I was expecting the results to be something like 'jaruayporn' or something similar but there's an error occured

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-214-ffa4a144ac59> in <module>
----> 1 romanize('จรวยพร')

~/.env/lib/python3.7/site-packages/pythainlp/transliterate/core.py in romanize(text, engine)
     50         from .royin import romanize
     51 
---> 52     return romanize(text)
     53 
     54 

~/.env/lib/python3.7/site-packages/pythainlp/transliterate/royin.py in romanize(text)
    224     """
    225     words = word_tokenize(text)
--> 226     romanized_words = [_romanize(word) for word in words]
    227 
    228     return "".join(romanized_words)

~/.env/lib/python3.7/site-packages/pythainlp/transliterate/royin.py in <listcomp>(.0)
    224     """
    225     words = word_tokenize(text)
--> 226     romanized_words = [_romanize(word) for word in words]
    227 
    228     return "".join(romanized_words)

~/.env/lib/python3.7/site-packages/pythainlp/transliterate/royin.py in _romanize(word)
    208         word = "".join(word)
    209 
--> 210     word = _replace_consonants(word, consonants)
    211 
    212     return word

~/.env/lib/python3.7/site-packages/pythainlp/transliterate/royin.py in _replace_consonants(word, consonants)
    167                 )
    168                 i += 1
--> 169         elif consonants[i] == _RO_RUA and word[i] == _RO_RUA:
    170             if i + 1 == len(word):
    171                 word = word.replace(

IndexError: string index out of range

Here's my environment configuration:

  • python 3.7.6
  • mac OS Catalina
  • pythainlp version 2.2.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbugs in the library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions