我在watsondsx上运行了以下Python脚本,但出现了错误。 (索引器错误:列表索引超出范围)
(1)Docker Jupiter notebook env上正常运行的程序相同。你知道吗
(2)在Waston DSX上,如果输入文件大小变化很小,则正常运行。你知道吗
请告诉我是什么原因造成的,我应该怎么做才能不发生错误?你知道吗
!pip install janome
data = get_object_storage_file_with_credentials_8b9fb794cc1049b09563d144c8861966('KITDemo', 'kusa-out.txt')
#data = get_object_storage_file_with_credentials_8b9fb794cc1049b09563d144c8861966('KITDemo', 'kusa2-out.txt')
txt = data.getvalue()
word_list = []
from janome.tokenizer import Tokenizer
t = Tokenizer()
for token in t.tokenize(txt, stream=True):
partOfSpeech = token.part_of_speech.split(',')[0]
if partOfSpeech == u'名詞':
word_list.append(token.surface)
这是完整的堆栈跟踪。你知道吗
IndexError Traceback (most recent call last)
<ipython-input-4-9a7681ae1aa6> in <module>()
2 from janome.tokenizer import Tokenizer
3 t = Tokenizer()
----> 4 for token in t.tokenize(txt, stream=True):
5 partOfSpeech = token.part_of_speech.split(',')[0]
6 if partOfSpeech == u'名詞':
IndexError: list index out of range
在Janome版本0.3.6中被修复。 https://github.com/mocobeta/janome/blob/0.3.6/CHANGES.txt请升级janome。如果升级后仍有问题,请在此处创建问题。 https://github.com/mocobeta/janome/issues
相关问题 更多 >
编程相关推荐