lac
lac copied to clipboard
rank模式分词报错
IndexError: list index out of range W0111 17:16:55.818279 36152 analysis_predictor.cc:1058] Deprecated. Please use CreatePredictor instead.
想知道什么情况下会出现这样的错误!
能给出更具体的信息吗,比如报错时的所有log信息
能给出更具体的信息吗,比如报错时的所有log信息
File "D:\WorkSpace\BrandExtraction\modle\process.py", line 75, in title_process
res = lac.run(title)
File "D:\WorkSpace\BrandExtraction\venv\lib\site-packages\LAC\lac.py", line 81, in run
return self.model.run(texts)
File "D:\WorkSpace\BrandExtraction\venv\lib\site-packages\LAC\models.py", line 337, in run
weight = self.parse_result(tags_for_rank, rank_decode[0], words_length)
File "D:\WorkSpace\BrandExtraction\venv\lib\site-packages\LAC\models.py", line 371, in parse_result
weight_out[-1] = max(weight_out[-1], weight[ind])
IndexError: list index out of range
能给出更具体的信息吗,比如报错时的所有log信息
我看了开始的很多词标记是O
text里面是不是有空格,把空格去掉试试
https://github.com/baidu/lac/blob/master/python/LAC/models.py 371行,调用weight_out[-1]的时候,weight_out可能为空
https://github.com/baidu/lac/blob/master/python/LAC/models.py
我也碰到这种情况了,在对长文本处理时,第一个片段没有被正确分词并标注词性 (单独对这个片段处理的话是可以正确运行 lac.run() 的)
此时表现为 331行生成的 word_length 与 result 不一致
这就导致 367行 开始循环时,tag 为 ‘O’,进而导致371行 调用 weight_out[-1] 的时候,出现 weight_out 为空的情况
https://github.com/baidu/lac/blob/master/python/LAC/models.py
我也碰到这种情况了,在对长文本处理时,第一个片段没有被正确分词并标注词性 (单独对这个片段处理的话是可以正确运行 lac.run() 的)
此时表现为 331行生成的 word_length 与 result 不一致
这就导致 367行 开始循环时,tag 为 ‘O’,进而导致371行 调用 weight_out[-1] 的时候,出现 weight_out 为空的情况
我也遇到这个问题了,请问最后解决了吗? @yjx4509
已经一年了,是不打算修了吗。。 下面这句话我只要使用rank模式就会报 list index out of range
西江月·夜行黄沙道中 [宋] 辛弃疾 明月别枝惊鹊

您的来信已收悉,我会尽快回复,感谢您的来信。