HumanSignal / label-studio

Label Studio is a multi-type data labeling and annotation tool with standardized output format
https://labelstud.io
Apache License 2.0
17.38k stars 2.16k forks source link

Add "required" field for tag results in exported data #6036

Open shisaru292 opened 1 week ago

shisaru292 commented 1 week ago

Is your feature request related to a problem? Please describe. I use one template with different "required" settings of tags for different projects. This is designed to reduce the burden of tagging tasks and to give different emphasis each time. But when I analyze the results, I need to distinguish whether a certain tag is required or not, such as filtering the post processed results with elasticsearch.

Describe the solution you'd like

# FROM
"result": [
    {
        "value": {
            "choices": [
                "No"
            ]
        },
        "id": "8264eY7_8D",
        "from_name": "_1003",
        "to_name": "dialogue_html",
        "type": "choices",
        "origin": "manual"
    },
    ...
]

# TO
"result": [
    {
        "value": {
            "choices": [
                "No"
            ]
        },
        "id": "8264eY7_8D",
        "from_name": "_1003",
        "to_name": "dialogue_html",
        "type": "choices",
        "origin": "manual",
        "required": false  // add this new field
    },
    ...
]

Describe alternatives you've considered I have considerd put the information into "from_name" for now, wihch is the name of a tag like Choices. For example when I generate the template for a new project, I might be able to:

if item.get("required", False):
        name = name + "_r" # r for required
    else:
        name = name + "_o" # o for optional

But such code with pre and post process looks very ...irregular. And what's more, old projects cannot add the information with updating the new generated template directly.

Consider more, "required" information is only one of many meta-information. Perhaps a more flexible string array of meta information could be used to augment such information?

Additional context No

shisaru292 commented 1 week ago

Another alternative now im using is to request label_config XML through the project read API (api/projects/1/?include=id%2Ctitle%2Clabel_config) and get the "required" settings before processing and storing the exported data (e.g. via api/projects/1/export) into analytics engine.