Is it possible to dynamically render a set of UI elements for each item in an array in Label Studio?

35 views Asked by At

I am currently working on a labeling project using Label Studio (version 1.5.0, and I have no control over the version), where I need to label individual elements in an array (i.e. for each array element, I want to assign one label). To achieve this, I want to dynamically create a view that contains a sub-view with one text widget and a choices group for each element in the array.

Here is a sample of my input data structure as I import it when creating a project (data contains more keys than just "text", but those are not relevant for this labeling task and are thus omitted):

[
    {
        "data": {
            "text": [
                "foo",
                "bar"
            ],
        }
    },
    {
        "data": {
            "text": [
                "lorem",
                "ipsum"
            ],
        }
    }
]

I can display the data as a table (which renders a "Name" column with the array indices and a "Value" column with the actual elements), but I haven't found a way to incorporate the choices widget into the table.
I'm guessing that rendering a widget inside a table may simply be impossible, but I'm hoping there is a way to achieve my goal* anyway (*which doesn't need to use a table, that's just the only widget I've found that nicely renders my data; the appropriately named "List" widget doesn't work for me for some reason).

For reference, here's the code for rendering the table:

<View>
    <Header value="Table"/>
    <Table name="table" value="$text"/>
    <Choices name="choice" toName="table">
        <Choice value="a"/>
        <Choice value="b"/>
        <Choice value="c"/>
    </Choices>
</View>

To summarize: I'm looking for a way to render a dynamic number of text + choices groups, based on an array of strings. I would like to avoid treating each array element as a separate labeling task.

0

There are 0 answers