Skip to content

knowledge_mining of nptag has a "list index out of range" error #2002

@loahi

Description

@loahi
  • 版本、环境信息
    1)PaddleNLP和PaddlePaddle版本:
    PaddlePaddle 2.2.2, compiled with
    with_avx: ON
    with_gpu: OFF
    with_mkl: ON
    with_mkldnn: ON
    with_python: ON
    PaddleNLP 2.2.6

2)系统环境:
Linux jupyter-306844-3858354 4.4.0-166-generic #195-Ubuntu SMP Tue Oct 1 09:35:25 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Python 3.7.4

  • 复现信息:如为报错,请给出复现环境、复现步骤
  • 执行内容

from paddlenlp import Taskflow
nptag = Taskflow("knowledge_mining", model="nptag", linking=True)
nptag('支会')

  • 错误信息
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/taskflow/taskflow.py in __call__(self, *inputs)
    289         The main work function in the taskflow.
    290         """
--> 291         results = self.task_instance(inputs)
    292         return results
    293 
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/taskflow/task.py in __call__(self, *args)
    270         inputs = self._preprocess(*args)
    271         outputs = self._run_model(inputs)
--> 272         results = self._postprocess(outputs)
    273         return results
/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddlenlp/taskflow/knowledge_mining.py in _postprocess(self, inputs)
    765                     else:
    766                         labels_can = self._tree.search_similar_word(cls_label)
--> 767                         result['label'] = labels_can[0][0]
    768 
    769             if self._linking:
IndexError: list index out of range

  • 报错原因
    第766行 labels_can 返回的是一个空数组 []
    类似会返回空数组的词语还有“村合”,“世协”

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions