textcat.manual "'label' is a required property" error

Hi there!

I'm experiencing an error trying to use the textcat.manual recipe.

As you can see the label property is stated in the command and prodigy recognizes it when initiating the server. However, once I open the web app the label isn't recognized in the incoming example stream and prodigy crashes.

I tried setting "validate": false in prodigy.json (according to @ines suggestion in Error trying to do demo on text_classification: 'label' is a required property, invalid task format). This resulted in being able to run the annotation app, but without a label :thinking:

So clearly there is some problem with prodigy not recognizing the stated label when creating the annotation stream.

Hmm, okey so seems like it was my understanding of the textcat.manual interface that was lacking… I added another label-parameter and now it works. It seems the textcat.manual interface is built to just be able to choose between different labels?

What I really wanted was to take a long chunk of text and manually highlight and classify certain spans of that text with a single label. Kind of like the ner.manual recipe.
Any suggestions @ines?


Thanks for the report – I’ll have a look :+1: This might actually be a bug, because it should work pretty much as you expected: if you provide more than one label, you get a multiple choice interface (most common use case), and if you only add one label, you get the basic classification interface where you accept/reject the single label.

But I think the problem is that the label isn’t correctly added to the stream. Here’s a quick workaround for now – just add this this at the end of the recipe script in recipes/textcat.py:

    def add_label_to_stream(stream, label):
        for eg in stream:
            eg["label"] = label[0]
            yield eg
    if has_options:
        stream = add_label_options(stream, label)
        stream = add_label_to_stream(stream, label)

To find the location of your Prodigy installation, you can run the following command:

python -c "import prodigy; print(prodigy.__file__)"

I’ll also fix this internally and the fix will be included in the next release!

1 Like

@ines what is the status on this fix please?

We'll ship it in the next release! In the meantime, the above code should work and let you fix it locally :slightly_smiling_face: