Hi!
I wrote a custom recipe to annotate sentences from a json file and I want to load a html file which is the spacy dependency analysis of the respective sentence. In the following code, l is a list of html code for each sentence. My idea was to use the validate_answer function to add 1 to a counter after each annotation such that for each sentence, the next html code gets loaded. (I use assert True just to prevent any error message). However, for each sentence, the l[0] gets loaded and I don't understand why - can I not use the validate_answer function to change the counter i? Maybe because nothing can be returned by this function? If it is not possible to do it similarly to my way, is there a work around to load different a different html for each annotation? (As I don't think it is possible to load in two streams and I already need the stream for the sentences from the json file because it is them I want to annotate.
def foo(i):
i += 1
assert True
@prodigy.recipe("custom_recipe")
def custom_recipe(dataset, jsonl_file):
n = 0
stream = JSONL(jsonl_file)
stream = add_tokens(nlp, stream)
blocks = [
{"view_id": "html", "html_template": l[n]},
{"view_id": "ner_manual"}
]
return{
"dataset": dataset,
"stream": stream,
"view_id": "blocks",
"validate_answer": foo(n),
"config": {
"labels": ["LABEL1", "LABEL2", "LABEL3"],
"blocks":blocks
}}
Thanks!