Runtime error for overlapping span
When I use TargetMatcher to try to overwrite a span, I get
Traceback (most recent call last):
File "/home/jmugan/anaconda3/lib/python3.8/site-packages/medspacy/target_matcher/target_matcher.py", line 163, in __call__
doc.ents += (span,)
File "spacy/tokens/doc.pyx", line 762, in spacy.tokens.doc.Doc.ents.__set__
File "spacy/tokens/doc.pyx", line 799, in spacy.tokens.doc.Doc.set_ents
ValueError: [E1010] Unable to set entity information for token 4 which is included in more than one span in entities, blocked, missing or outside.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/jmugan/Dropbox/consulting/Billenote/billenote_exp/umls/medspacy_rules.py", line 84, in <module>
doc = nlp(text)
File "/home/jmugan/anaconda3/lib/python3.8/site-packages/spacy/language.py", line 1031, in __call__
error_handler(name, proc, [doc], e)
File "/home/jmugan/anaconda3/lib/python3.8/site-packages/spacy/util.py", line 1670, in raise_error
raise e
File "/home/jmugan/anaconda3/lib/python3.8/site-packages/spacy/language.py", line 1026, in __call__
doc = proc(doc, **component_cfg.get(name, {})) # type: ignore[call-arg]
File "/home/jmugan/anaconda3/lib/python3.8/site-packages/medspacy/target_matcher/target_matcher.py", line 167, in __call__
raise RuntimeWarning(
RuntimeWarning: The result ""reviewed"" conflicts with a pre-existing entity in doc.ents. This result has been skipped.
The code says that just the RuntimeWarning should be raised. But that's not what appears to be happening. Version 0.2.0 just had pass https://github.com/medspacy/medspacy/blob/0.2.0.0/medspacy/target_matcher/target_matcher.py.
Is this just my machine? (Linux) Does it work for anyone else and just give a warning?
I think the problem is we are not there to catch the warning. Maybe it should be something like warnings.warn("can't overwrite entity")?
If I comment out lines 167 through 170 of target_matcher.py and replace them with pass things works as before.
Came here to write exactly about this issue. I guess the author intended to just issue a warning, but it actually does stop the code from running. So it does not behave as a warning.
+1