asahi417 / tner

Language model fine-tuning on NER with an easy interface and cross-domain evaluation. "T-NER: An All-Round Python Library for Transformer-based Named Entity Recognition, EACL 2021"
https://aclanthology.org/2021.eacl-demos.7/
MIT License
373 stars 41 forks source link

Fix handling empty mentions while predicting. #8

Closed sayef closed 3 years ago

sayef commented 3 years ago

Handling empty mentions are throwing following error:

File "...../lib/python3.7/site-packages/tner/model_prediction.py", line 95, in predict
    if sentence[start_char] == ' ':
IndexError: string index out of range

For example, the following sentence creates empty mentions:

'The 1901 Villanova Wildcats football team represented the Villanova University during the 1901 college football season.'

Colab prediction example environment is sufficient for recreating the issue with the given example.

Solution: Ignore empty mentions, and with loop continuation.

asahi417 commented 3 years ago

@sayef Thanks a lot to find the bug! I've confirmed and merged to master now.