Document-Based Projects

Create New Document Based Project

In this example, we will create a new Document Based Labeling project. We are going to label some book cover images and determine the title of the book. Additionally, we will use a Hierarchical Dropdown for our question.

Book Cover Project

cURL

curl --location --request POST 'https://datasaur.ai/graphql' \
--header 'Authorization: Bearer access_token' \
--form 'operations={
"operationName": "LaunchTextProjectMutation",
"variables": {
"input": {
"teamId": "1",
"name": "Book Cover",
"documentSettings": {
"kind": "DOCUMENT_BASED"
},
"projectSettings": {
"consensus": 1,
"enableEditLabelSet": true,
"enableEditSentence": true
},
"assignees": [
{
"email": "[email protected]"
}
],
"documents": [
{
"name": "cover-1.jpg",
"file": null,
"fileName": "cover-1.jpg",
"settings": {
"guidelineID": "1",
"questions": [
{
"type": "HIERARCHICAL_DROPDOWN",
"config": {
"multiple": false,
"options": [
{
"label": "Novel",
"id": 1
},
{
"label": "Sherlock Holmes",
"id": 2,
"parentId": 1
},
{
"label": "A Study in Scarlet",
"id": 3,
"parentId": 2
},
{
"label": "A Scandal in Bohemia",
"id": 4,
"parentId": 2
},
{
"label": "Harry Potter",
"id": 5,
"parentId": 1
},
{
"label": "Philosopher'\''s Stone",
"id": 6,
"parentId": 5
},
{
"label": "Chamber of Secrets",
"id": 7,
"parentId": 5
},
{
"label": "Drama",
"id": 8
},
{
"label": "William Shakespeare",
"id": 9,
"parentId": 8
},
{
"label": "Hamlet",
"id": 10,
"parentId": 9
},
{
"label": "Macbeth",
"id": 11,
"parentId": 9
},
{
"label": "Molière",
"id": 12,
"parentId": 8
},
{
"label": "Tartuffe",
"id": 13,
"parentId": 12
},
{
"label": "The Misanthrope",
"id": 14,
"parentId": 12
}
]
},
"name": "Book Title",
"label": "What is the book title?",
"required": true
}
]
}
},
{
"name": "cover-2.jpg",
"file": null,
"fileName": "cover-2.jpg",
"settings": {"guidelineID": "1"}
},
{
"name": "cover-3.jpg",
"file": null,
"fileName": "cover-3.jpg",
"settings": {"guidelineID": "1"}
},
{
"name": "cover-4.jpg",
"file": null,
"fileName": "cover-4.jpg",
"settings": {"guidelineID": "1"}
},
{
"name": "cover-5.jpg",
"file": null,
"fileName": "cover-5.jpg",
"settings": {"guidelineID": "1"}
}
]
}
},
"query": "mutation LaunchTextProjectMutation($input: LaunchTextProjectInput!) { launchTextProject(input: $input) { id rootDocumentId settings { consensus enableEditLabelSet enableEditSentence __typename } __typename }}"
}' \
--form 'map={"1":["variables.input.documents.0.file"], "2":["variables.input.documents.1.file"], "3":["variables.input.documents.2.file"], "4":["variables.input.documents.3.file"], "5":["variables.input.documents.4.file"]}' \
  • operationName: you can fill any alphanumeric string in as the operationName. Refer this page for best practices on choosing an operationName .

  • variables

    • teamId: id of the team where we want to create the project.

    • name: Name for the project.

    • documentSettings

      • kind: Use DOCUMENT_BASED as the value here since we want to create document-based labeling project.

        • TOKEN_BASED

        • ROW_BASED

        • DOCUMENT_BASED

    • projectSettings

      • consensus: peer review / labeler consensus. This determines how many labelers must agree in order for the system to automatically accept the label.

      • enableEditLabelSet: labelers will be restricted from adding or removing labels from the label set while labeling.

      • enableEditSentence: labelers will be able to edit the original text while labeling.

    • assignees

      • email: this refers to the user's email. Datasaur will throw an error if the email is not found on the team.

      • documentNames: Optional. List of document names. It refers to the field documents.fileName below. If not specified, all documents will be assigned to the team member above.

      • role: Optional. This determines the assignment role.

        • LABELER

        • REVIEWER

    • documents: list of documents or files to be attached to this project. Every document must have the fields: name and fileName. There are optional fields, such as settings and fileUrl. Please see GraphQL schema for more information.

      • name: Document name.

      • fileName: File name. This can be used in the documentNames field above.

      • file: Use null.

      • settings

        • guidelineID: Put guideline ID here.

        • questions: Add the list of questions here. Refer to this page for more information about questions.

  • query: Copy this from the cURL example.

Sample Files

Extract cover.zip to get sample files. You could use these images to execute cURL command above.

💡 You can check this page to see how to upload file in GraphQL.

Response

Here is the response you can expect after issuing the cURL command.

{
"data": {
"launchTextProject": {
"id": "580",
"rootDocumentId": "caa436bd-848c-4151-b5d4-ca57530c47b5",
"settings": {
"consensus": 0,
"enableEditLabelSet": false,
"enableEditSentence": false,
"__typename": "ProjectSettings"
},
"__typename": "Project"
}
},
"extensions": {}
}

💡 You can check this page to see what parameters available.