Integrating tagtog and spaCy: a simple example

By Jorge Campos & tagtog team

Taking the spaCy v3 release opportunity, we wanted to write a small piece about how to integrate tagtog and spaCy.

tagtog is a multi-user text annotation tool designed to build high-quality data efficiently. spaCy is an open-source library for advanced Natural Language Processing (NLP) in Python.

This example uses spaCy to automatically generate NER (Named-Entity Recognition) annotations and display these annotations directly in tagtog.

First, we create a project in tagtog and define a few entity types in the project settings. Bear in mind that these types should map those used by your model. We will use the spaCy’s model en_core_web_sm for English to extract entities representing people, organizations, and money. We review the model label scheme and find these labels: PERSON, ORG, and MONEY. In tagtog, we create similar entity types:

These entity types maps to the labels for the spaCy model

Second, we want to upload to tagtog a text annotated by this model. To do that, first we transform the annotations coming out of the spaCy model and transform them into the annotations tagtog can digest. Below you can find a Python code snippet that does the following:

  1. Given a sample text, it forwards it to the en_core_web_sm model.
  2. It transforms the model response into annotations tagtog can understand.
  3. It pushes the text and annotations (pre-annotated document) to tagtog using its API.

The sample text:

Paypal Holdings Inc (PYPL) President and CEO Daniel Schulman Sold $2.7 million of Shares

🪄Now you can find the annotated text in your tagtog project.

On the right side you find the different entity types found in the text. A user can correct the predictions of your model and then you can use this data for further training.

On top, here is the full GitHub repository (this code is generalized to also work with PDFs!):

I hope you enjoyed the example! The whole project is public so take a look🍃 at: https://www.tagtog.net/jorge/demo-spaCy/

Please reach out for any questions!

Feel free to sign up at tagtog.net, and try this sample with your own model, it's free.

Like birds? Follow us on Twitter 🐦

👏👏👏 if you like the post, and want to share it with others! 💚🧡

The text annotation platform to train #NLP. Easy. 🔗 tagtog.net