2016-02-26 41 views
0

stemmer和lemmatizer似乎爲傳遞給我的文本文件的某些句子產生了這個錯誤。他們是什麼意思,我該如何解決它們?我該如何解決這個UnicodeDecodeError?

Traceback (most recent call last): 
     File "preproc.py", line 89, in <module> 
     apos=stem_data(nostop) 
     File "preproc.py", line 51, in stem_data 
     r=stemmer.stem(n) 
     File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/stem/porter.py", line 632, in stem 
     stem = self.stem_word(word.lower(), 0, len(word) - 1) 
     File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/stem/porter.py", line 590, in stem_word 
     word = self._step1ab(word) 
     File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/nltk/stem/porter.py", line 275, in _step1ab 
     if word.endswith("sses"): 
    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 6: ordinal not in range(128) 
+0

哪些是正在生成錯誤的句子? –

+0

[python nltk.sent \ _tokenize錯誤ascii編解碼器無法解碼]的可能重複(http://stackoverflow.com/questions/27212912/python-nltk-sent-tokenize-error-ascii-codec-cant-decode) –

回答

1

你有某種非ASCII字符,所以它是一個編碼問題..這將有助於瞭解哪些句子產生這個錯誤

+0

這個:在2月24日由國際射電天文學研究中心提供的日期圖中顯示了藝術家對銀河系背後的避難區中發現的星系的印象。澳大利亞望遠鏡用於廣播人類視覺1969年在月球上的第一步發現了數百個隱藏在銀河系後面的新星系,使用一個可以測量無線電波的創新接收器 – minks

+0

將您的編碼更改爲utf-8。應該解決這個問題。 – ubadub

+0

但是,我再次得到這個:UnicodeEncodeError:'ascii'編解碼器不能編碼字符u'\ u2019'在位置6:序號不在範圍內(128) – minks