Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49421
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <d@davea.name> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '16,': 0.03; 'syntax': 0.04; '-*-': 0.07; 'continuation': 0.07; 'linux,': 0.07; 'string': 0.09; 'properly.': 0.09; 'throws': 0.09; 'true)': 0.09; 'python': 0.11; '2.7': 0.14; 'codec': 0.16; 'exited': 0.16; 'fine.': 0.16; 'subject:Problem': 0.16; 'subject:UTF': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'trying': 0.19; "skip:' 30": 0.19; 'example': 0.22; 'import': 0.22; 'print': 0.22; 'header:User-Agent:1': 0.23; 'byte': 0.24; 'bytes': 0.24; 'of.': 0.24; 'text.': 0.24; 'question': 0.24; 'source': 0.25; 'skip:" 40': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'characters': 0.30; 'statement': 0.30; 'prints': 0.31; 'file': 0.32; 'text': 0.33; 'running': 0.33; '(most': 0.33; 'skip:# 10': 0.33; 'maybe': 0.34; 'problem': 0.35; "can't": 0.35; 'display': 0.35; 'something': 0.35; 'editor': 0.35; 'but': 0.35; 'marks': 0.36; 'surely': 0.36; 'hi,': 0.36; 'error.': 0.37; 'to:addr:python- list': 0.38; 'skip:- 10': 0.38; 'recent': 0.39; 'does': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'skip:u 10': 0.60; 'above,': 0.60; 'email addr:gmail.com': 0.63; 'here': 0.66; 'invalid': 0.68; 'received:74.208': 0.68; 'press': 0.70; '8bit%:100': 0.72; 'analysis': 0.75; '8bit%:77': 0.84; 'fare': 0.84; "it'd": 0.84; 'received:74.208.4.194': 0.84; 'skip:\xef 10': 0.84 |
| Date | Sat, 29 Jun 2013 10:02:56 -0400 |
| From | Dave Angel <d@davea.name> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: MeCab UTF-8 Decoding Problem |
| References | <f4fe97e3-5949-4c52-97d7-4995b8891efd@googlegroups.com> |
| In-Reply-To | <f4fe97e3-5949-4c52-97d7-4995b8891efd@googlegroups.com> |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| X-Provags-ID | V02:K0:7zZNs4ZM0re2UauURx+Y2dSuJFnUcXb8RaHwuX/Wp0d 8SLAEAH/7P0XMTW2K5Cb9uuD5/YeeiYMdXDjvdXj2cbh/7cFcY 7dwN9ovxxFGZbFKU3J9G61FYc7pgIblmgm5mRLxxyZmmbAEzXe VXQAXFw2U1W5juuoe3d/bx/UrXbRobAD3mCjHB+e159iWPzUSx sGSOgoRXj9eLtTxwEA7sflNl4GxwzHpR/ucwCSyMInNdjRXMII RLfUmAQA5OtcbkArspTHTX59CR3Y6WjfhQcB8Riz1K5GNkIEKz GRmd+7XOdojKYHOjaK+RRTg0kA5ixFFKj7KO0zZ/jws61V+QHF VFr0t5LN9GyaMYo4tv6o= |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3990.1372514590.3114.python-list@python.org> (permalink) |
| Lines | 55 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1372514590 news.xs4all.nl 15990 [2001:888:2000:d::a6]:46536 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:49421 |
Show key headers only | View raw
On 06/29/2013 07:29 AM, fobos3@gmail.com wrote:
> Hi,
Using Python 2.7 on Linux, presumably? It'd be better to be explicit.
>
> I am trying to use a program called MeCab, which does syntax analysis on Japanese text. The problem I am having is that it returns a byte string and if I try to print it, it prints question marks for almost all characters. However, if I try to use .decide, it throws an error. Here is my code:
What do the MeCab docs say the tagger.parse byte string represents?
Maybe it's not text at all. But surely it's not utf-8.
>
> #!/usr/bin/python
> # -*- coding:utf-8 -*-
>
> import MeCab
> tagger = MeCab.Tagger("-Owakati")
> text = 'MeCabで遊んでみよう!'
>
> result = tagger.parse(text)
> print result
>
> result = result.decode('utf-8')
> print result
>
> And here is the output:
>
> MeCab �� �� ��んで�� �� ��う!
>
> Traceback (most recent call last):
> File "test.py", line 11, in <module>
> result = result.decode('utf-8')
> File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
> return codecs.utf_8_decode(input, errors, True)
> UnicodeDecodeError: 'utf8' codec can't decode bytes in position 6-7: invalid continuation byte
>
>
> ------------------
> (program exited with code: 1)
> Press return to continue
>
> Also my terminal is able to display Japanese characters properly. For example print '日本語' works perfectly fine.
Are your terminal and your text editor using utf-8, or something else?
Can you put your print statement in the source file above, and it'll
also work fine?
Are you actually running it from the terminal, or some GUI? I notice
you get "(program exited with code: 1)" and "Press return to continue".
Neither of those is standard terminal fare on any OS I know of.
--
DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
MeCab UTF-8 Decoding Problem fobos3@gmail.com - 2013-06-29 04:29 -0700 Re: MeCab UTF-8 Decoding Problem Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2013-06-29 13:46 +0000 Re: MeCab UTF-8 Decoding Problem Dave Angel <d@davea.name> - 2013-06-29 10:02 -0400 Re: MeCab UTF-8 Decoding Problem Terry Reedy <tjreedy@udel.edu> - 2013-06-29 11:32 -0400 Re: MeCab UTF-8 Decoding Problem Terry Reedy <tjreedy@udel.edu> - 2013-06-29 11:55 -0400 Re: MeCab UTF-8 Decoding Problem MRAB <python@mrabarnett.plus.com> - 2013-06-29 17:12 +0100 Re: MeCab UTF-8 Decoding Problem Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-06-29 16:20 +0000
csiph-web