adamsamson/HornMorpho2.5

'charmap' codec can't encode characters in position 6-14: character maps to <undefined>

Closed this issue · 2 comments

Hay Adam, first of all I would like to thank you for this wounder full job you did.

I installed python 3.1, and installed HornMorph and do one example on README.md.

I created a python file.

 import l3

 l3.anal('am', 'የማያስፈልጋትስ')

When I tried to run it, it showed the following error.

Traceback (most recent call last):
  File "Test.py", line 3, in <module>
    l3.anal('am', '\u12e8\u121b\u12eb\u1235\u1348\u120d\u130b\u1275\u1235')
  File "C:\Python31\lib\site-packages\l3\__init__.py", line 156, in anal_word
    string=not raw, print_out=not raw)
  File "C:\Python31\lib\site-packages\l3\morpho\language.py", line 894, in anal_word
    print(self.analyses2string(word, analyses, form_only=segment and not gram))
  File "C:\Python31\lib\encodings\cp437.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_map)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 6-14: character maps to <undefined>

It seems to me that the error is coming from the source code.
Thanks in advance for your help.

Thanks for your kind words.

I have Python 3.5.2, and it works like a charm.

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import l3
>>>>> This is L3Morpho, version 3.0 <<<<<
>>>>> and HornMorpho, version 2.5 <<<<<
>>> l3.anal('am', 'የማያስፈልጋትስ')
Loading morphological data for Amharic ...

word: የማያስፈልጋትስ
POS: verb, root: <fl_g>, citation: አስፈለገ
subject: 3, sing, masc
object: 3, sing, fem
grammar: imperfective, causative, relative, definite, negative
conjunctive suffix: s

Maybe this can help? http://stackoverflow.com/questions/14630288/unicodeencodeerror-charmap-codec-cant-encode-character-maps-to-undefined

Thanks for your reply.

With your recommendation, the problem is solved.
I was using windows command prompt to run the script. The problem was I had to active Unicode Unicode characters. And it worked.

And also when I tried to run it on Python Interpreter, it worked. I had to try this before making this issue.
Any how, thanks for your time.