Spacy pipeline

If gatenlp has been installed with the spacy extra (pip install gatenlp[spacy] or pip install gatenlp[all]) you can run a Spacy pipeline on a document and get the result as gatenlp annotations.

In [1]:
from gatenlp import Document
from gatenlp.lib_spacy import AnnSpacy
import spacy
In [2]:
# In order to use the English pipeline with Spacy, the model has to get downloaded first
from spacy.cli import download as spacy_download
✔ Download and installation successful
You can now load the model via spacy.load('en_core_web_sm')
In [3]:
doc = Document.load("")

Annotating the document using Spacy

In order to annotate one or more documents using Spacy, first create a AnnSpacy annotator object and the run the document(s) through this annotator:

In [4]:
spacy_pipeline = spacy.load("en_core_web_sm")
spacy_annotator = AnnSpacy(pipeline=spacy_pipeline)
In [5]:
doc = spacy_annotator(doc)
In [ ]: