Python 谷歌colab中的ScispaCy
我正在尝试使用colab中的ScispaCy建立NER临床数据模型。我已经安装了这样的软件包Python 谷歌colab中的ScispaCy,python,nlp,spacy,ner,Python,Nlp,Spacy,Ner,我正在尝试使用colab中的ScispaCy建立NER临床数据模型。我已经安装了这样的软件包 !pip install spacy !pip install scispacy !pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.4/en_core_sci_md-0.2.4.tar.gz #pip install <Model URL>``` 然后使用下面的代码显示句子
!pip install spacy
!pip install scispacy
!pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.4/en_core_sci_md-0.2.4.tar.gz #pip install <Model URL>```
然后使用下面的代码显示句子和实体
nlp = spacy.load("en_core_sci_md")
text ="""Myeloid derived suppressor cells (MDSC) are immature myeloid cells with immunosuppressive activity. They accumulate in tumor-bearing mice and humans with different types of cancer, including hepatocellular carcinoma (HCC)"""
doc = nlp(text)
print(list(doc.sents))
print(doc.ents)
我得到以下错误
OSError: [E050] Can't find model 'en_core_sci_md'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
我不知道为什么会出现这个错误,我遵循了ScispaCy官方GitHub帖子中的所有代码。任何帮助都将不胜感激。
提前谢谢。我希望不会太晚。。。我相信你非常接近正确的方法 我会分步写我的答案,你可以选择停在哪里 步骤1) 步骤2) 步骤3) 步骤4) 步骤5) 步骤6) 步骤7)
OSError: [E050] Can't find model 'en_core_sci_md'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.
#Install en_core_sci_lg package from the website of spacy (large corpus), but you can also use en_core_sci_md for the medium corpus.
!pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.4/en_core_sci_lg-0.2.4.tar.gz
# Import the large dataset
import en_core_sci_lg
# Identify entities
nlp = en_core_sci_lg.load()
doc = nlp(text)
displacy_image = displacy.render(doc, jupyter = True, style = "ent")
#Print only the entities
print(doc.ents)
# Save the result
save_res = [doc.ents]
save_res
#Save the results to a dataframe
df_save_res = pd.DataFrame(save_res)
df_save_res
# In case that you want to visualise the dependency parse
displacy_image = displacy.render(doc, jupyter = True, style = "dep")