Commit 9d0d1cd3 authored by Morgan Funtowicz's avatar Morgan Funtowicz
Browse files

Filter out entity for NER task.

parent e4baa68d
...@@ -450,11 +450,12 @@ class NerPipeline(Pipeline): ...@@ -450,11 +450,12 @@ class NerPipeline(Pipeline):
score = np.exp(entities[token_start]) / np.exp(entities[token_start]).sum(-1, keepdims=True) score = np.exp(entities[token_start]) / np.exp(entities[token_start]).sum(-1, keepdims=True)
label_idx = score.argmax() label_idx = score.argmax()
answer += [{ if label_idx > 0:
'word': words[idx], answer += [{
'score': score[label_idx].item(), 'word': words[idx],
'entity': self.model.config.id2label[label_idx] 'score': score[label_idx].item(),
}] 'entity': self.model.config.id2label[label_idx]
}]
# Update token start # Update token start
token_start += len(list(word)) token_start += len(list(word))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment