Watson DSX得到“索引错误”,但Docker Jupiter env。别这样

2024-10-04 15:22:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我在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'名詞':

Screenshot


Tags: intxttokendatagetobject错误with

热门问题