Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unicode Error #17

Closed
gwohlgen opened this issue Mar 28, 2017 · 4 comments
Closed

Unicode Error #17

gwohlgen opened this issue Mar 28, 2017 · 4 comments

Comments

@gwohlgen
Copy link

Hi,
thanks for fixing the import error!

tried to run your sample code now,
but still errors.

a) pythainlp/pythainlp/test/init.py", line 36 -- missing closing paranthesis .. easy to fix

but now:

[gerhard@localhost pythainlp]$ python test_gerhard.py
/home/gerhard/pythainlp/pythainlp/segment/dict.py:23: UnicodeWarning: Unicode equal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if string == "":
Traceback (most recent call last):
  File "test_gerhard.py", line 6, in <module>
    b = segment(a)
  File "/home/gerhard/pythainlp/pythainlp/segment/dict.py", line 10, in segment
    result = tokenize(string, lines, "")
  File "/home/gerhard/pythainlp/pythainlp/segment/dict.py", line 27, in tokenize
    if string.startswith(pref):
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe0 in position 0: ordinal not in range(128)

when using:

# -*- coding: utf-8 -*-

# ตัดคำ
from pythainlp.segment import segment
a = 'ฉันรักภาษาไทยเพราะฉันเป็นคนไทย'
b = segment(a)

I am not sure if this is a problem with my system, or general one ..

Cheers, Gerhard

@wannaphong
Copy link
Member

You setting the default encoding of python is utf8. https://stackoverflow.com/a/21190382 and reinstall from https://github.com/wannaphongcom/pythainlp/tree/develop

@gwohlgen
Copy link
Author

gwohlgen commented Mar 30, 2017 via email

@wannaphong
Copy link
Member

@gwohlgen fix in 241a5f7

@wannaphong
Copy link
Member

wannaphong commented Mar 31, 2017

Now , PyThaiNLP support python 2.7 in ad41eff .
test in https://travis-ci.org/wannaphongcom/pythainlp/jobs/217228168

bact added a commit that referenced this issue Nov 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants