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
19.58k stars 2.43k forks source link

Supports dynamic expansion of the number of objects when extracting structured data #6733

Open tianluling opened 5 days ago

tianluling commented 5 days ago

Is your feature request related to a problem? Please describe. When I extract the required structured object information from a large text, the number of objects is uncertain, and the number of objects cannot be dynamically expanded.

Describe the solution you'd like I hope to provide a way to dynamically expand the number of objects

Describe alternatives you've considered My current solution is to find the maximum number in the document and add object elements one by one in the code according to the maximum number. This is a very stupid method. When the maximum number exceeds 100 or even 1000, it is very difficult to handle.

Additional context image

config.xml:

<View>
    <View className="wrapper">
        <View style="width: 600px;margin-right: 20px;height: 800px; overflow: auto;"><Text name="summary" value="$summary"></Text></View>
        <View style="height: 800px; overflow: auto;">
            <View className="basic-form">
                <View className="form-item">
                    <Text name="date-label" value="date:"></Text>
                    <TextArea name="date" toName="summary" placeholder="date"></TextArea>
                </View>
                <View className="form-item">
                    <Text name="competitionNameLabel" value="Competition Name:"></Text>
                    <TextArea name="competitionName" toName="summary" placeholder="Competition Name"></TextArea>
                </View>
                <View className="form-item">
                    <Text name="winner-label" value="winner:"></Text>
                    <TextArea name="winner" toName="summary" placeholder="winner"></TextArea>
                </View>
                <View className="form-item">
                    <Text name="loser-label" value="loser:"></Text>
                    <TextArea name="loser" toName="summary" placeholder="loser"></TextArea>
                </View>
            </View>
            <View>
                <Header value="object-1"></Header>
                <View className="object-form">
                    <TextArea name="goalTime.1" toName="summary" placeholder="goalTime"></TextArea>
                    <TextArea name="player.1" toName="summary" placeholder="player"></TextArea>
                </View>
                <Header value="object-2"></Header>
                <View className="object-form">
                    <TextArea name="goalTime.2" toName="summary" placeholder="goalTime"></TextArea>
                    <TextArea name="player.2" toName="summary" placeholder="player"></TextArea>
                </View>
                <Header value="object-3"></Header>
                <View className="object-form">
                    <TextArea name="goalTime.3" toName="summary" placeholder="goalTime"></TextArea>
                    <TextArea name="player.3" toName="summary" placeholder="player"></TextArea>
                </View>
                <Header value="object-4"></Header>
                <View className="object-form">
                    <TextArea name="goalTime.4" toName="summary" placeholder="goalTime"></TextArea>
                    <TextArea name="player.4" toName="summary" placeholder="player"></TextArea>
                </View>
            </View>
        </View>
    </View>
    <Style>
        .wrapper {
            display: flex;
            .basic-form {
                display: flex;
                flex-wrap: wrap;
                .form-item {
                    width: 50%;
                    display: flex;
                    align-items: center;
                    input {
                        margin-left: 10px;
                    }
               }
            }
            .object-form {
                display: flex;
                .ant-form-item {
                    margin-right: 10px;
                }
            }
        }
    </Style>
</View>

data.json:

[
  {
    "summary": "On May 18, 2022, the UEFA Champions League Final, the clash between Liverpool and Real Madrid took place at the Stade de France.\nIn the 14th minute, Vinícius Júnior of Real Madrid made a blistering run down the left flank, received a precise through-ball from Luka Modrić, and then coolly slotted the ball past the Liverpool goalkeeper Alisson Becker to break the deadlock, putting Real Madrid ahead 1 - 0. (Note: The assist came from Luka Modrić.)\nAt the 28th minute, Liverpool's Mohamed Salah managed to wriggle free in the penalty area, got on the end of a floated cross from Trent Alexander-Arnold, but his header was saved brilliantly by Thibaut Courtois, denying Liverpool an equalizer.\nIn the 64th minute, Liverpool's Sadio Mané cut in from the right side, unleashed a powerful shot that rattled the crossbar, coming agonizingly close to leveling the scores.\nHowever, in the 69th minute, Federico Valverde of Real Madrid picked up the ball in midfield, drove forward with great pace, and unleashed a long-range shot that took a slight deflection off a Liverpool defender, wrong-footing Alisson Becker and doubling Real Madrid's lead to 2 - 0.\nIn the 80th minute, Liverpool made a desperate push for a goal. Diogo Jota came on as a substitute and almost immediately had an impact, getting a good chance inside the box, but his shot was blocked by the resolute Real Madrid defense.\nReal Madrid held on firmly in the closing minutes, and with their solid defensive display and clinical finishing upfront, they won the match 2 - 0, lifting the UEFA Champions League trophy."
  },
  {
    "summary": "On June 10, 2023, the Copa América Quarterfinals, the encounter between Brazil and Argentina was held at a packed stadium.\nIn the 9th minute, Lionel Messi of Argentina dribbled past multiple Brazilian defenders near the edge of the penalty area, then threaded a perfect pass to Julián Álvarez, who sprinted into the box and tapped the ball into the net, giving Argentina an early 1 - 0 lead. (Assist by Lionel Messi.)\nAt the 32nd minute, Brazil's Neymar tried to spark a comeback, curling a free-kick from just outside the box that skimmed the top of the crossbar, narrowly missing the equalizer.\nIn the 55th minute, Rodrigo of Brazil found some space on the right wing, cut inside and fired a shot that was parried by the Argentine goalkeeper Emiliano Martínez, keeping Argentina's lead intact.\nAt the 67th minute, Ángel Di María of Argentina, after a swift counter-attack, received the ball on the left side, sprinted towards the byline and whipped in a cross that Lautaro Martínez headed home powerfully, doubling Argentina's lead to 2 - 0.\nIn the 85th minute, Brazil threw everything forward in search of a goal, but the Argentine defense, marshalled by Nicolás Otamendi, stood firm, repelling wave after wave of attacks.\nArgentina managed to see out the game and advanced to the next round with a 2 - 0 victory, delighting their passionate fans in the stadium."
  }
]
heidi-humansignal commented 1 day ago

Hello,

I think you might be able to use Repeater tag (https://labelstud.io/templates/multi-page-document-annotation.html#Labeling-configuration). But this has some limitation.

Thank you, Abu

Comment by Abubakar Saad Workflow Run