Can't import custom recipe

I have a custom recipe. My test is passing

from recipes import custom_period_cat_teach

def test_recipe():
    components = custom_period_cat_teach('my_dataset', 'en', 'QUARTER')
    assert 'dataset' in components
    assert 'stream' in components
    assert 'view_id' in components
    assert components['dataset'] == 'my_dataset'
    assert components['view_id'] == 'classification'
    assert hasattr(components['stream'], '__iter__')

But I get

(venv) ➜  Annotator prodigy custom_period_cat_teach -F

✨  ERROR: Can't import recipe 'custom_period_cat_teach'.

I have no clue where to look for the error?

Gosh typo in @prodigy.recipe()

1 Like

Thanks for updating – and sounds like a classic case of “did all the complicated stuff right, bug was a typo” :sweat_smile:

1 Like

Haha yeah but you made it pretty easy I must say!

Btw, right now I am detecting periods like Q1 2011, Jan-Jun, June - September 2013 as DATE entity. Then I want apply a classifier to determine if the period is QUARTER, HALFYEAR, YEAR etc.

My question is, should I:

  1. preprocess the entity span before applying the classifier, e.g. to change June - September 2013 into June - September since I do not care about the absolute periods? Or can I rely that the classifier will figure that out?
  2. or should I improve my NER model by creating a new label PERIOD entity that would exclude any year-specifics? I suppose I’d have to retrain DATE instead - otherwise I would end up with a lot of overlapping.

Also; should I have the classifier as a standalone model, i.e. not part of the other spacy model?

Are you sure you want a classifier to do things like QUARTER, HALFYEAR etc? The model’s going to have to learn that on a substring basis, it can’t do the maths itself. I think you’ll be better off resolving the dates and implementing the period logic yourself.

Yeah thats what I ended up doing as well. Works well and thanks for your response.