Toloka documentation

Sentiment analysis & Content moderation

For this type of project, you can use the Sentiment analysis & Content moderation preset.

This preset helps you classify text content by specified categories.

Take a look at the example: the labeling interface includes a text and radio buttons. When the Yes, there are option is selected, an additional question with checkboxes appears. Note that validation, keyboard shortcuts, and task layout are already configured in this Template Builder sample code.

Components used in the example
  • view.list: Displays data in a list.

  • view.text: Adds the text that you want to check.

    Show code
    {
      "type": "view.text",
      "content": {
        "type": "data.input",
        "path": "comment"
      }
    }
    
  • view.alert: Highlights important information to enhance Toloker's experience. In this example, the text content is highlighted with a blue border.

    Show code
    {
      "type": "view.alert",
      "theme": "info",
      "content": {
        "type": "view.text",
        "content": {
          "type": "data.input",
          "path": "comment"
        }
      }
    }
    
  • view.markdown: Displays a text in Markdown.

    Show code
    {
      "type": "view.markdown",
      "content": "**Are there any infringements of publication guidelines in the text?**"
    }
    

    Note that the view.markdown component is resource-intensive and might overload weak Toloker devices. Do not use this component to display plain text. If you need to display text without formatting, use the view.text component.

  • field.radio-group: Adds radio buttons for selecting an answer option.

    Show code
    {
      "type": "field.radio-group",
      "options": [
        {
          "label": "No, there are not",
          "value": "no"
        },
        {
          "label": "Yes, there are",
          "value": "yes"
        }
      ],
      "data": {
        "type": "data.output",
        "path": "is_infringements"
      },
      "validation": {
        "type": "condition.required",
        "hint": "Choose one of the options"
      }
    }
    
  • field.checkbox-group: Adds checkboxes for selecting one or more answer option from the given list of choices.

    Show code
    {
      "type": "field.checkbox-group",
      "label": "Which ones?",
      "options": [
        {
          "label": "Advertising or spam",
          "value": "advertising"
        },
        {
          "label": "Nonsense",
          "value": "nonsense"
        },
        {
          "label": "Insult",
          "value": "insult"
        },
        {
          "label": "Violation of the law",
          "value": "law_violation"
        },
        {
          "label": "Profanity",
          "value": "profanity"
        }
      ],
      "data": {
        "type": "data.output",
        "path": ""
      },
      "validation": {
        "type": "condition.required",
        "hint": "Select one or more infringements"
      }
    }
    
  • condition.required: Checks if at least one option is selected.

    Show code
    {
      "type": "condition.required",
      "hint": "Choose one of the options"
    }
    
  • helper.if: Displays an interface element after a specific response is selected.

    Show code
    {
      "type": "helper.if",
      "condition": {
        "type": "condition.equals",
        "data": {
          "type": "data.output",
          "path": "is_infringements"
        },
        "to": "yes"
      },
      "then": {
        "type": "field.checkbox-group",
        "label": "Which ones?",
        "options": [
          {
            "label": "Advertising or spam",
            "value": "advertising"
          },
          {
            "label": "Nonsense",
            "value": "nonsense"
          },
          {
            "label": "Insult",
            "value": "insult"
          },
          {
            "label": "Violation of the law",
            "value": "law_violation"
          },
          {
            "label": "Profanity",
            "value": "profanity"
          }
        ],
        "data": {
          "type": "data.output",
          "path": ""
        },
        "validation": {
          "type": "condition.required",
          "hint": "Select one or more infringements"
        }
      }
    }
    
  • plugin.toloka: Customizes the task layout.

    Show code
    {
      "type": "plugin.toloka",
      "layout": {
        "kind": "scroll",
        "taskWidth": 500
      }
    }
    
  • plugin.hotkeys: Adds keyboard shortcuts.

    Show code
    {
      "1": {
        "type": "action.set",
        "data": {
          "type": "data.output",
          "path": "is_infringements"
        },
        "payload": "no"
      },
      "2": {
        "type": "action.set",
        "data": {
          "type": "data.output",
          "path": "is_infringements"
        },
        "payload": "yes"
      },
      "w": {
        "type": "action.toggle",
        "data": {
          "type": "data.output",
          "path": "advertising"
        }
      },
      "a": {
        "type": "action.toggle",
        "data": {
          "type": "data.output",
          "path": "nonsense"
        }
      },
      "s": {
        "type": "action.toggle",
        "data": {
          "type": "data.output",
          "path": "insult"
        }
      },
      "d": {
        "type": "action.toggle",
        "data": {
          "type": "data.output",
          "path": "law_violation"
        }
      },
      "f": {
        "type": "action.toggle",
        "data": {
          "type": "data.output",
          "path": "profanity"
        }
      },
      "type": "plugin.hotkeys"
    }
    

If this template doesn't meet your needs, see other examples in the Text section.

Add a description

To add a detailed description to the task, use the view.text component.

Show code
{
  "type": "view.text",
  "content": "Decide whether comments follow the publication guidelines."
}

Add a response field

If you want that Tolokers give an extended response, add a text field using the field.textarea component.

Show code
{
  "type": "field.textarea",
  "label": "Comments",
  "placeholder": "Enter text",
  "data": {
    "type": "data.output",
    "path": "comment"
  }
}

See also