Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

model.inference_from_dicts does not return an item if no named entity is found in text #326

@renaud

Description

@renaud

Describe the bug
When calling model.inference_from_dicts, does not return an item if no named entity is found in text

To Reproduce
model = Inferencer.load(save_dir) # Connl EN NER
basic_texts = [
{"text": "I love you."},
{"text": "I love Anna."}, # only this sentence has a NE, Anna
{"text": "I love you so much!"},
]
result = model.inference_from_dicts(dicts=basic_texts)

actual output
[{'task': 'ner', 'predictions': [{'start': 7, 'end': 12, 'context': 'Anna.', 'label': 'PER', 'probability': 0.9851147}]}]

expected output
[{'task': 'ner', 'predictions': [{}, {'start': 7, 'end': 12, 'context': 'Anna.', 'label': 'PER', 'probability': 0.9851147}, {}]}]
(note the two empty dicts for the sentences where no NE was found.

Why it's important
Otherwise it's tricky to map it back to the original text...

Thanks!

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions