prodigy serve ner manual

Hi,

I am trying to use

prodigy.serve(
‘ner.manual’,
‘prod-new’,
‘en_core_web_sm’,
‘ner_manual/codes_texts.jsonl’,
None,
None,
‘ner_manual/codes.txt’,
port=8080
)

to invoke it from my Python app.

It starts the server though, but I am unable to get the labels which are in ‘ner_manual/codes.txt’. And, the webapp has this error:

What could have possibly gone wrong?

I think the problem here might be this: When you serve a recipe from the command line, Prodigy applies various converter functions to the command-line inputs (like, make sure integers are integers and convert comma-separated strings of labels to a list). If you're running it all from Python, that's not happening or necessary, because Python lets you pass in integers, lists etc.

So try passing in a list of labels instead of just the path to the labels file.

Wow, it exactly works that way. But, what if we have long list of labels? Is that still the right way?

1 Like

You can still load the labels from a file (or from anywhere, really) – but you’d have to do this yourself in Python. For example:

with open("/path/to/labels.txt", "r") as txt_file:
    lines = [line.strip() for line in txt_file]

The nice thing here is that none of this is specific to Prodigy – so you can set up your own Python logic however you like :slightly_smiling_face:

Yeah @ines, that was what came to my mind. Thanks :slight_smile:

1 Like

3 posts were split to a new topic: Feed overlap not working as expected