使用一段时间报错IndexError: string index out of range
Created by: ningshixian
Traceback (most recent call last):
.....
File "/data/ningshixian/work/extract/info_extract.py", line 65, in run_lac
results = self.lac.lexical_analysis(data=data) # 词法分析
File "/data/ningshixian/software/anaconda3/lib/python3.7/site-packages/paddlehub/module/module.py", line 497, in __call__
sub_data, **kwargs)
File "/home/ningshixian/.paddlehub/modules/lac/python/a62c5d015111daae0dbd8719b0293c1b.py", line 304, in postprocess
cur_word = words[word_index]
**IndexError: string index out of range**
code is following:
main.py
# load Baidu LAC service
import paddlehub as hub
lac = hub.Module(name='lac')
slot_extractor = info_extractor(lac)
for i in range(len(xx)):
slot_extractor.run_lac('text')
...
info_extract.py
class info_extractor:
def __init__(self, lac, logger):
self.lac = lac
def run_lac(self, text): # text是一句话
data = {'text':[text]}
results = self.lac.lexical_analysis(data=data) # IndexError: string index out of range
...
main.py 会调用多次info_extract.py,每隔一段时间就会报错IndexError: string index out of range,请各路大神帮忙看看,谢谢