Skip to content

스팬 주석

NER, 관계 추출, 감성 분석을 위해 Potato에서 텍스트 스팬을 강조 표시하고 레이블을 지정합니다. 스팬 유형, 색상, 겹치는 스팬, 키보드 단축키를 구성합니다.

스팬 주석을 사용하면 주석자가 텍스트의 일부를 선택하고 레이블을 지정할 수 있으며, 개체명 인식(NER), 품사 태깅, 텍스트 강조 표시 작업에 널리 사용됩니다.

개체 강조 표시가 있는 스팬 주석 인터페이스Potato에서 색상으로 구분된 개체 레이블이 있는 스팬 주석

기본 구성

yaml
annotation_schemes:
  - annotation_type: span
    name: entities
    description: "Highlight named entities in the text"
    labels:
      - PERSON
      - ORGANIZATION
      - LOCATION

구성 옵션

개체 레이블

주석자가 생성할 수 있는 스팬 유형을 정의합니다.

yaml
labels:
  - PERSON
  - ORGANIZATION
  - LOCATION
  - DATE
  - EVENT

색상

시각적 구분을 위해 색상을 사용자 지정합니다.

yaml
colors:
  PERSON: "#3b82f6"
  ORGANIZATION: "#10b981"
  LOCATION: "#f59e0b"
  DATE: "#8b5cf6"
  EVENT: "#ec4899"

색상은 16진수(#ff0000) 또는 RGB(rgb(255, 0, 0))로 지정할 수 있습니다.

키보드 단축키

키보드 바인딩으로 주석 작업 속도를 높입니다.

yaml
keyboard_shortcuts:
  PERSON: "1"
  ORGANIZATION: "2"
  LOCATION: "3"
  DATE: "4"

툴팁

각 레이블에 대한 안내를 제공합니다.

yaml
tooltips:
  PERSON: "Names of people, characters, or personas"
  ORGANIZATION: "Companies, agencies, institutions"
  LOCATION: "Physical locations, addresses, geographic regions"

겹치는 스팬

겹침 허용

겹칠 수 있는 스팬을 활성화합니다.

yaml
- annotation_type: span
  name: entities
  labels:
    - PERSON
    - ROLE
  allow_overlapping: true

이는 동일한 텍스트에 여러 레이블이 지정될 수 있을 때 유용합니다(예: "Dr. Smith"는 PERSON이면서 ROLE을 가짐).

겹침 비활성화(기본값)

yaml
- annotation_type: span
  name: entities
  labels:
    - PERSON
    - ORGANIZATION
  allow_overlapping: false  # Default behavior

스팬 선택 모드

단어 단위 선택

완전한 단어만 선택합니다.

yaml
- annotation_type: span
  name: entities
  selection_mode: word
  labels:
    - ENTITY

문자 단위 선택

부분 단어 선택을 허용합니다.

yaml
- annotation_type: span
  name: entities
  selection_mode: character
  labels:
    - ENTITY

사전 주석된 스팬

검토 또는 수정을 위해 기존 주석을 불러옵니다.

json
{
  "id": "doc1",
  "text": "John Smith works at Microsoft in Seattle.",
  "spans": [
    {"start": 0, "end": 10, "label": "PERSON"},
    {"start": 20, "end": 29, "label": "ORGANIZATION"},
    {"start": 33, "end": 40, "label": "LOCATION"}
  ]
}

사전 주석을 불러오도록 구성합니다.

yaml
- annotation_type: span
  name: entities
  load_pre_annotations: true
  pre_annotation_field: spans

일반적인 NER 구성

표준 NER(4가지 유형)

yaml
- annotation_type: span
  name: ner
  description: "Label named entities"
  labels:
    - PER    # Person
    - ORG    # Organization
    - LOC    # Location
    - MISC   # Miscellaneous
  colors:
    PER: "#3b82f6"
    ORG: "#10b981"
    LOC: "#f59e0b"
    MISC: "#6b7280"
  keyboard_shortcuts:
    PER: "1"
    ORG: "2"
    LOC: "3"
    MISC: "4"

확장 NER(OntoNotes 스타일)

yaml
- annotation_type: span
  name: ner_extended
  labels:
    - PERSON
    - NORP        # Nationalities, religious/political groups
    - FAC         # Facilities
    - ORG
    - GPE         # Geopolitical entities
    - LOC
    - PRODUCT
    - EVENT
    - WORK_OF_ART
    - LAW
    - LANGUAGE
    - DATE
    - TIME
    - PERCENT
    - MONEY
    - QUANTITY
    - ORDINAL
    - CARDINAL

생물의학 NER

yaml
- annotation_type: span
  name: bio_ner
  labels:
    - GENE
    - PROTEIN
    - DISEASE
    - DRUG
    - SPECIES
  colors:
    GENE: "#22c55e"
    PROTEIN: "#3b82f6"
    DISEASE: "#ef4444"
    DRUG: "#f59e0b"
    SPECIES: "#8b5cf6"

소셜 미디어 NER

yaml
- annotation_type: span
  name: social_ner
  labels:
    - PERSON
    - ORGANIZATION
    - LOCATION
    - PRODUCT
    - CREATIVE_WORK
    - GROUP

속성이 있는 스팬

더 풍부한 주석을 위해 스팬에 속성을 추가합니다.

yaml
annotation_schemes:
  - annotation_type: span
    name: entities
    labels:
      - PERSON
      - ORGANIZATION
 
  - annotation_type: radio
    name: entity_type
    description: "What type of entity is this?"
    show_for_span: entities
    labels:
      - Named
      - Nominal
      - Pronominal

여러 스팬 스키마

서로 다른 측면을 별도로 주석 처리합니다.

yaml
annotation_schemes:
  # Named entities
  - annotation_type: span
    name: entities
    description: "Label named entities"
    labels:
      - PERSON
      - ORGANIZATION
      - LOCATION
 
  # Sentiment expressions
  - annotation_type: span
    name: sentiment_spans
    description: "Highlight sentiment expressions"
    labels:
      - POSITIVE
      - NEGATIVE
    colors:
      POSITIVE: "#22c55e"
      NEGATIVE: "#ef4444"

다중 필드 스팬 주석

v2.1.0에서 추가됨

스팬 주석은 target_field 옵션을 사용하여 다중 필드 데이터에서 특정 텍스트 필드를 대상으로 지정할 수 있습니다. 이는 데이터에 여러 텍스트 필드가 포함되어 있고 특정 필드에서 스팬을 주석 처리하려는 경우에 유용합니다.

구성

yaml
annotation_schemes:
  - annotation_type: span
    name: source_entities
    description: "Label entities in the source text"
    target_field: "source_text"
    labels:
      - PERSON
      - ORGANIZATION
 
  - annotation_type: span
    name: summary_entities
    description: "Label entities in the summary"
    target_field: "summary"
    labels:
      - PERSON
      - ORGANIZATION

다중 필드 데이터 형식

데이터에는 별도의 텍스트 필드가 포함되어야 합니다.

json
{
  "id": "doc1",
  "source_text": "John Smith works at Microsoft in Seattle.",
  "summary": "Smith is employed by Microsoft."
}

출력 형식

target_field를 사용하면 주석이 필드별로 키가 지정됩니다.

json
{
  "id": "doc1",
  "source_entities": {
    "source_text": [
      {"start": 0, "end": 10, "text": "John Smith", "label": "PERSON"},
      {"start": 20, "end": 29, "text": "Microsoft", "label": "ORGANIZATION"}
    ]
  },
  "summary_entities": {
    "summary": [
      {"start": 0, "end": 5, "text": "Smith", "label": "PERSON"},
      {"start": 22, "end": 31, "text": "Microsoft", "label": "ORGANIZATION"}
    ]
  }
}

완전히 동작하는 예제는 Potato 저장소의 project-hub/simple_examples/simple-multi-span/을 참조하십시오.

표시 옵션

스팬에 레이블 표시

강조 표시된 스팬 내에 레이블 텍스트를 표시합니다.

yaml
- annotation_type: span
  name: entities
  show_label_in_span: true

밑줄 스타일

배경 강조 표시 대신 밑줄을 사용합니다.

yaml
- annotation_type: span
  name: entities
  display_style: underline

출력 형식

스팬 주석은 문자 오프셋과 함께 저장됩니다.

json
{
  "id": "doc1",
  "entities": [
    {
      "start": 0,
      "end": 10,
      "text": "John Smith",
      "label": "PERSON"
    },
    {
      "start": 20,
      "end": 29,
      "text": "Microsoft",
      "label": "ORGANIZATION"
    }
  ]
}

전체 예제: NER 작업

yaml
annotation_task_name: "Named Entity Recognition"
 
data_files:
  - path: data/documents.json
    text_field: text
 
annotation_schemes:
  - annotation_type: span
    name: entities
    description: "Highlight and label all named entities"
    labels:
      - PERSON
      - ORGANIZATION
      - LOCATION
      - DATE
      - MONEY
    colors:
      PERSON: "#3b82f6"
      ORGANIZATION: "#10b981"
      LOCATION: "#f59e0b"
      DATE: "#8b5cf6"
      MONEY: "#ec4899"
    keyboard_shortcuts:
      PERSON: "1"
      ORGANIZATION: "2"
      LOCATION: "3"
      DATE: "4"
      MONEY: "5"
    tooltips:
      PERSON: "Names of people"
      ORGANIZATION: "Companies, agencies, institutions"
      LOCATION: "Cities, countries, addresses"
      DATE: "Dates and time expressions"
      MONEY: "Monetary values"
    allow_overlapping: false
    selection_mode: word
 
  - annotation_type: radio
    name: difficulty
    description: "How difficult was this document to annotate?"
    labels:
      - Easy
      - Medium
      - Hard

불연속 스팬

v2.2.0에서 추가됨

allow_discontinuous 매개변수로 비연속적인 텍스트 스팬을 활성화합니다. 이를 통해 주석자는 인접하지 않은 여러 텍스트 세그먼트를 단일 스팬 주석으로 선택할 수 있으며, 불연속 개체나 분할된 표현에 유용합니다.

yaml
- annotation_type: span
  name: entities
  labels:
    - PERSON
    - ORGANIZATION
  allow_discontinuous: true

활성화되면 주석자는 수정 키를 누른 상태에서 추가 텍스트 세그먼트를 선택하여 현재 스팬에 추가할 수 있습니다. 출력에는 각 세그먼트에 대한 여러 개의 시작/끝 쌍이 포함됩니다.

개체 연결 통합

v2.2.0에서 추가됨

스팬 주석은 스팬 스키마에 entity_linking 구성 블록을 추가하여 외부 지식 베이스(Wikidata, UMLS 또는 사용자 지정 REST API)에 연결할 수 있습니다.

yaml
- annotation_type: span
  name: entities
  labels:
    - PERSON
    - ORGANIZATION
    - LOCATION
  entity_linking:
    enabled: true
    knowledge_bases:
      - name: wikidata
        type: wikidata
        language: en

개체 연결이 활성화되면 각 스팬의 컨트롤 바에 링크 아이콘이 나타납니다. 이를 클릭하면 일치하는 지식 베이스 개체를 찾아 연결할 수 있는 검색 모달이 열립니다. 자세한 내용은 개체 연결 문서를 참조하십시오.

모범 사례

  1. 명확한 색상을 사용하여 시각적으로 쉽게 구별합니다
  2. 각 개체 유형에 대해 예시와 함께 명확한 툴팁을 제공합니다
  3. 더 빠른 주석을 위해 키보드 단축키를 활성화합니다
  4. 문자 정밀도가 필요하지 않은 한 단어 단위 선택을 사용합니다
  5. 더 빠른 수정 워크플로를 위해 사전 주석을 고려합니다
  6. 주석 지침에 따라 겹침 설정을 테스트합니다

더 읽어보기

구현 세부 사항은 원본 문서를 참조하십시오.