Skip to content

Commit 6235fcd

Browse files
Fix the bug with issues code 8641. (#8880)
1 parent 4cf0806 commit 6235fcd

File tree

1 file changed

+9
-3
lines changed
  • legacy/examples/text_to_knowledge/nptag/deploy/python

1 file changed

+9
-3
lines changed

legacy/examples/text_to_knowledge/nptag/deploy/python/predict.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,15 @@ def predict(self, data, tokenizer):
127127
break
128128
else:
129129
labels_can = bk_tree.search_similar_word(label)
130-
result["label"] = labels_can[0][0]
131-
132-
result["category"] = name_dict[result["label"]]
130+
if len(labels_can) != 0:
131+
result["label"] = labels_can[0][0]
132+
else:
133+
result["label"] = None
134+
135+
if result["label"] in name_dict:
136+
result["category"] = name_dict[result["label"]]
137+
else:
138+
result["category"] = None
133139
results.append(result)
134140
return results
135141

0 commit comments

Comments
 (0)