How to create a custom recipe with multiple choice interfaces?

Hi,

I want to create a custom recipe that has multiple 3 choice interfaces with different HTML titles. How can I do this?

Thanks

Hi @ale ,

If your options and HTML titles are static then using multiple options blocks each with each own set of options specified in the view_id definition.

In this example I used ner_manual as the interface on top of the options:

import prodigy
from prodigy.core import Arg, recipe
from prodigy.components.stream import get_stream
from prodigy.components.preprocess import add_tokens
import spacy
from pathlib import Path


@prodigy.recipe(
    "test-recipe",
    dataset = Arg(help="Dataset to save answers to."),
    file_path=Arg(help="Path to texts")
)
def test_recipe(dataset: str, file_path):
    stream = get_stream(file_path) # load in the JSON file
    nlp = spacy.blank("en")
    stream.apply(add_tokens, stream=stream, nlp=nlp)
    blocks = [
        {"view_id": "ner_manual"},
        {"view_id": "html", "html": "<p>This is a fixed html 1</p>"},
        {"view_id": "choice", "options":[{"id": "option_1", "text": "Option 1"}, {"id":"option_2", "text": "Option 2"}],"text": None},
        {"view_id": "html", "html": "<p>This is a fixed html 2</p>"},
        {"view_id": "choice","options":[{"id": "option_3", "text": "Option 3"}, {"id":"option_4", "text": "Option 4"}],"text": None},
        {"view_id": "html", "html": "<p>This is a fixed html 3</p>"},
        {"view_id": "choice", "options":[{"id": "option_4", "text": "Option 4"}, {"id":"option_5", "text": "Option 5"}],"text": None},
    ]

    return {
        "dataset": dataset,
        "view_id": "blocks",
        "stream": stream,
        "config": {
            "labels": ["LABEL"],
            "blocks": blocks,
            "choice_style": "single"
        }
    }

This should result in the interface like this one:<