0
$\begingroup$

I am writing a code to train custom entities in Spacy's NER engine. I am stuck in understanding small part of code from an online tutorial. Here's a link to the tutorial. The following code is line number 12-15. I am new to python so stuck understanding this part of the code;

# add labels
    for _, annotations in TRAIN_DATA:
        for ent in annotations.get('entities'):
            ner.add_label(ent[2])

Apparently, this for loop is adding custom labels to the NER. M questions are;

  1. What is an 'annotation'? (I googled for 'spacy annotation' but couldn't find the answer)
  2. Why are there two variables to the left of 'in', ('_' and 'annotation')?
  3. What does ent[2] return? What's at pos 2?
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.