Skip to content
advancedtext

Relation Extraction

Identify and classify relationships between entities in text (e.g., works-for, located-in, married-to).

Try it live — no install

Boot the real Potato server in your browser (WebAssembly) and annotate with this exact config. Nothing leaves your machine.

Run live in your browser

Get This Design

View on GitHub(opens in a new tab)

Clone or download from the repository

Quick start:

bash
git clone https://github.com/davidjurgens/potato-showcase.git
cd potato-showcase/templates/text/relation-extraction
potato start config.yaml

Configuration File

yaml
# Relation Extraction Configuration
# Identify relationships between entities in text

task_dir: "."
annotation_task_name: "Relation Extraction"

data_files:
  - "data/sentences.json"

item_properties:
  id_key: "id"
  text_key: "display"
  text_display_key: "display"

user_config:
  allow_all_users: true

annotation_schemes:
  - annotation_type: "radio"
    name: "relation_type"
    description: "What is the relationship between the highlighted entities?"
    labels:
      - name: "works_for"
        tooltip: "Subject works for/is employed by object"
        key_value: "w"
      - name: "located_in"
        tooltip: "Subject is located in object (place)"
        key_value: "l"
      - name: "founded_by"
        tooltip: "Subject was founded by object"
        key_value: "f"
      - name: "ceo_of"
        tooltip: "Subject is CEO/leader of object"
        key_value: "c"
      - name: "born_in"
        tooltip: "Subject was born in object (place)"
        key_value: "b"
      - name: "married_to"
        tooltip: "Subject is married to object"
        key_value: "m"
      - name: "subsidiary_of"
        tooltip: "Subject is a subsidiary of object"
        key_value: "s"
      - name: "part_of"
        tooltip: "Subject is part of object"
        key_value: "p"
      - name: "no_relation"
        tooltip: "No clear relationship between entities"
        key_value: "n"
      - name: "other"
        tooltip: "Relationship exists but not in list"
        key_value: "o"

  - annotation_type: "text"
    name: "other_relation"
    description: "If 'other', describe the relationship"
    show_if:
      field: "relation_type"
      value: "other"

  - annotation_type: "radio"
    name: "direction"
    description: "What is the direction of the relation?"
    labels:
      - name: "Subject → Object"
        tooltip: "Relation goes from Subject to Object"
      - name: "Object → Subject"
        tooltip: "Relation goes from Object to Subject"
      - name: "Bidirectional"
        tooltip: "Relation works both ways"

  - annotation_type: "likert"
    name: "confidence"
    description: "How confident are you in this relation?"
    size: 5
    min_label: "Not confident"
    max_label: "Very confident"

output: "annotation_output/"

output_annotation_dir: "annotation_output/"
output_annotation_format: "json"

Sample Data

json
[
  {
    "id": "rel_001",
    "text": "Tim Cook has been the CEO of Apple since 2011.",
    "subject": "Tim Cook",
    "object": "Apple",
    "subject_type": "PERSON",
    "object_type": "ORGANIZATION",
    "display": "**Text:** Tim Cook has been the CEO of Apple since 2011.\n\n**Subject:** [Tim Cook] (PERSON)\n**Object:** [Apple] (ORGANIZATION)"
  },
  {
    "id": "rel_002",
    "text": "The Eiffel Tower is located in Paris, France.",
    "subject": "Eiffel Tower",
    "object": "Paris",
    "subject_type": "LOCATION",
    "object_type": "LOCATION",
    "display": "**Text:** The Eiffel Tower is located in Paris, France.\n\n**Subject:** [Eiffel Tower] (LOCATION)\n**Object:** [Paris] (LOCATION)"
  }
]

// ... and 2 more items

Details

Annotation Types

likertradiotext

Domain

nlpinformation-extraction

Use Cases

knowledge-graphrelation-classification

Tags

relationentitiesknowledge-graphextractionnlp

Found an issue or want to improve this design?

Open an Issue(opens in a new tab)