I'm using spaCy to analyze a large set of medical text for commentary about diagnoses, which was working fine when I left it last week.
Now when I try to load the scispaCy library en_ner_bc5cdr_md I am getting the type error TypeError: issubclass() arg 1 must be a class
I used this exact library to analyze the same text last week and the only thing that has changed is that I've restarted my computer.
I'm running an anaconda distribution with python 3.8.8 on OSX Version 13.5.2 (22G91)
Any ideas what's going on?
This is the code, it never gets past importing the model.
import spacy
import scispacy
import pandas as pd
text = """The patient was diagnosed with pneumonia last year. He has a history of asthma and hypertension.
His COPD symptoms have worsened over the last 2 months. The patient also suffers from migraines."""
nlp = spacy.load("en_ner_bc5cdr_md")
doc = nlp(text)
labels = []
counts = []
for ent in doc.ents:
if ent.label_ == 'DISEASE':
if ent.text not in labels:
labels.append(ent.text)
counts.append(1)
else:
idx = labels.index(ent.text)
counts[idx] += 1
df = pd.DataFrame({'Diagnosis': labels, 'Count': counts})
print(df)
If you are able to run on you machine please let me know the parameters. You will also need to run - !pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.4.0/en_ner_bc5cdr_md-0.4.0.tar.gz
import scispacyor atnlp = spacy.load("en_ner_bc5cdr_md")?nlp = spacy.load("en_ner_bc5cdr_md")