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.

from gatenlp import Document
from gatenlp.lib_spacy import AnnSpacy
import spacy

# 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')
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:

spacy_pipeline = spacy.load("en_core_web_sm")
spacy_annotator = AnnSpacy(pipeline=spacy_pipeline)
doc = spacy_annotator(doc)