Datasaur
Search…
Inserting Span and Arrow Label into Document
In Token Based Labeling, we have 2 different kinds of label:
  • Span Label: Label applied to a span of tokens
  • Arrow Label: Label which points from a Span Label to another Span Label

cURL

Use the following cURL command to get label sets added to a project. You can copy and paste the following template and replace the access_token and the content of the label set items according to your needs.
1
curl --location --request POST 'https://datasaur.ai/graphql' \
2
--header 'Authorization: Bearer access_token' \
3
--header 'Content-Type: application/json' \
4
--data-raw '{"operationName":"UpdateLabels","variables":{"input":{"documentId":"c541e403-776a-40b7-af4b-955c7be86c0d","signature":"fab4a116af4da9d2381e61e8bf2337170d8d044704c4d679f439a79a04d7bddb","labels":[{"id":"PhvHFKDx0m1lA4bl46NhH:0:0:15:0:0:15:6:0","l":"PhvHFKDx0m1lA4bl46NhH","s":15,"e":15,"charS":0,"charE":6,"layer":0,"deleted":false,"sidS":0,"sidE":0}],"action":"LABEL"}}, "query":"mutation UpdateLabels($input: UpdateTokenLabelsInput!) { updateLabelsResult: updateLabels(input: $input) { updatedSentences { id } } }"}'
Copied!
Below is a more readable version of the above curl command's request body.
1
{
2
"operationName": "UpdateLabels",
3
"variables": {
4
"input": {
5
"documentId": "document-id",
6
"signature": "signature",
7
"labels": [
8
{
9
"layer": 0,
10
"sidS": 0,
11
"s": 0,
12
"charS": 0,
13
"sidE": 0,
14
"e": 2,
15
"charE": 5,
16
"l": "vGOy0ZKA-2rqK7netKz9I",
17
"id": "vGOy0ZKA-2rqK7netKz9I:0:0:0:0:0:2:5:0",
18
"deleted": false
19
},
20
{
21
"layer": 0,
22
"sidS": 0,
23
"s": 14,
24
"charS": 0,
25
"sidE": 0,
26
"e": 18,
27
"charE": 6,
28
"l": "9I-5oYKvnzJRWHgsZrDe_",
29
"id": "9I-5oYKvnzJRWHgsZrDe_:0:0:14:0:0:18:6:0",
30
"deleted": false
31
},
32
{
33
"layer": 1,
34
"sidS": 0,
35
"s": 0,
36
"charS": 0,
37
"sidE": 0,
38
"e": 18,
39
"charE": 6,
40
"l": "A-92mMT_WppaawOOBJbjt",
41
"id": "A-92mMT_WppaawOOBJbjt:1:9I-5oYKvnzJRWHgsZrDe_:0:0:14:0:0:18:6:0:vGOy0ZKA-2rqK7netKz9I:0:0:0:0:0:2:5:0:0",
42
"deleted": false
43
}
44
],
45
"action": "LABEL"
46
}
47
},
48
"query": "mutation UpdateLabels($input: UpdateTokenLabelsInput!) { updateLabelsResult: updateLabels(input: $input) { updatedSentences { id } } }"
49
}
Copied!
The request above will produce span and arrow labels like the following:
  • operationName: you can fill any alphanumeric string in as the operationName. Refer this page for best practices on choosing an operationName .
  • variables:
    • input:
      • documentId: string, ID of the targeted document where the label will be inserted.
      • signature: hash of the document to ensure the structure of the sentence / tokens of the document has not changed when inserting label. You can obtain the signature value by following the instruction in this page.
      • labels:
        • id: the unique identifier of a label.
          1. 1.
            If the ID has 9 segments, this indicates a span label. For example, INNM0ViFwo8LluMTaTIK9:0:0:14:0:0:18:6:0 and here's the explanation <label set item id>:<layer>:<sidS>:<s>:<charS>:<sidE>:<e>:<charE>:<index>.
          2. 2.
            If the ID has 21 segments, this indicates an arrow label. For example, tfc1FkbbEk9fOLx6haR1s:0:INNM0ViFwo8LluMTaTIK9:0:0:14:0:0:18:6:0:Oq_VuB0s_N7D8ZY0rgYsg:0:0:0:0:0:2:5:0:0 and here's the explanation <label set item id>:<arrow layer>:<….. origin id>:<….destination id>:<arrow index>.
        • layer: indicates the index of the label set.
        • l: the label set item ID of the label set. You can obtain the label set information of a project including the label set item ID in this page.
        • sidS: starting line of the label
        • s: starting token of the label
        • charS: starting character index of the label
        • sidE: ending line of the label
        • e: ending token of the label
        • charE: ending character index of the label
        • deleted: boolean, set true if you want to delete the existing label
  • query: Copy this from the example above.
💡a tag has the same meaning as label. In the near future, we will update the GraphQL Schema to refer to all instances as labels.

Response

Here is the response you can expect after issuing the cURL command. Use the id to create the project.
1
{
2
"data": {
3
"updateLabelsResult": {
4
"updatedSentences": [
5
{
6
"id": 0
7
}
8
]
9
}
10
},
11
"extensions": {}
12
}
Copied!
Last modified 2mo ago
Copy link
Contents
cURL
Response