Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]ValueError: [E090] Extension 'similarity' already exists on Span. To overwrite the existing extension, set force=True on Span.set_extension. #94

Open
nitzanbar29 opened this issue Jan 3, 2024 · 4 comments

Comments

@nitzanbar29
Copy link

Describe the bug
Hi, I use the example in the demo.

I'm facing this error:

ValueError: [E090] Extension 'similarity' already exists on Span. To overwrite the existing extension, set force=True on Span.set_extension.

To Reproduce

common English pipeline

nlp = spacy.load('en_core_web_sm')

@Language.component('quickumls_component')
def quickumls_component(doc):
return SpacyQuickUMLS(nlp, umls_path1)(doc)

quickumls_component = SpacyQuickUMLS(nlp, umls_path1)
nlp.add_pipe('quickumls_component', last=True)

doc = nlp('Pt c/o shortness of breath, chest pain, nausea, vomiting, diarrrhea')

for ent in doc.ents:
print('Entity text : {}'.format(ent.text))
print('Label (UMLS CUI) : {}'.format(ent.label_))
print('Similarity : {}'.format(ent..similarity))
print('Semtypes : {}'.format(ent.
.semtypes))

**Environment **

  • OS: Unbuntu
  • QuickUMLS version 1.4.0
  • UMLS version 2023

Thanks :)

@rmalla1
Copy link

rmalla1 commented Mar 31, 2024

I am facing the same issue.

@JuneHou
Copy link

JuneHou commented May 20, 2024

Got the same error code here.

@msegar
Copy link

msegar commented Aug 3, 2024

Same issue

@RuiqiTu
Copy link

RuiqiTu commented Dec 24, 2024

You define multiple SpacyQuickUMLS instances in your code:

@Language.component('quickumls_component')
def quickumls_component(doc):
quickumls_component = SpacyQuickUMLS(nlp, umls_path1)

The Span.set_extension method is called repeatedly during each instantiation, and Spacy does not allow repeated definition of the same extension attributes (like similarity and semtypes), so delete quickumls_component.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants