Disable annotations for part of the text

Hello there,

I just want to ask if there is a way to disable part of the text for NER annotation in the Prodigy interface. For example, I want to annotate an article. I need to display the title (as the information in it is important for annotation) but I don’t want to annotate it. Is there a way to do this?

Thank you and appreciate your help!

You mean in the manual interface, right?

The manual interface supports marking individual tokens as "disabled": true, which will display them greyed out and will make them unselectable. Spans across disabled tokens will also be considered invalid.

So your input data could look like this:

{
    "text": "Hello Apple",
    "tokens": [
        {"text": "Hello", "start": 0, "end": 5, "id": 0, "disabled": true},
        {"text": "Apple", "start": 6, "end": 11, "id": 1}
    ]
}

To tokens to your data, you can use Prodigy’s add_tokens preprocessor (which is also used in the ner.manual recipe):

from prodigy.components.preprocess import add_tokens

nlp = spacy.load(your_model)
stream = add_tokens(nlp, your_data)

Thanks Ines for the quick reply and your helpful response! Your solution will work for me - I’ll let you know if I have any more questions.