Spannen-Annotation
Textspannen für Named-Entity-Recognition und mehr hervorheben und beschriften.
Spannen-Annotation
Die Spannen-Annotation ermöglicht es Annotatoren, Textabschnitte auszuwählen und zu beschriften. Sie wird häufig für Named-Entity-Recognition (NER), Part-of-Speech-Tagging und Texthervorhebungsaufgaben verwendet.
Grundkonfiguration
annotation_schemes:
- annotation_type: span
name: entities
description: "Highlight named entities in the text"
labels:
- PERSON
- ORGANIZATION
- LOCATIONKonfigurationsoptionen
Entitätsbeschriftungen
Typen der Spannen definieren, die Annotatoren erstellen können:
labels:
- PERSON
- ORGANIZATION
- LOCATION
- DATE
- EVENTBeschriftungsfarben
Farben zur visuellen Unterscheidung anpassen:
label_colors:
PERSON: "#3b82f6"
ORGANIZATION: "#10b981"
LOCATION: "#f59e0b"
DATE: "#8b5cf6"
EVENT: "#ec4899"Farben können als Hex (#ff0000) oder RGB (rgb(255, 0, 0)) angegeben werden.
Tastaturkürzel
Annotation mit Tastenbelegungen beschleunigen:
keyboard_shortcuts:
PERSON: "1"
ORGANIZATION: "2"
LOCATION: "3"
DATE: "4"Tooltips
Hinweise für jede Beschriftung bereitstellen:
tooltips:
PERSON: "Names of people, characters, or personas"
ORGANIZATION: "Companies, agencies, institutions"
LOCATION: "Physical locations, addresses, geographic regions"Überlappende Spannen
Überlappungen erlauben
Spannen aktivieren, die sich überlappen können:
- annotation_type: span
name: entities
labels:
- PERSON
- ROLE
allow_overlapping: trueDies ist nützlich, wenn derselbe Text mehrere Beschriftungen haben kann (z. B. ist „Dr. Schmidt" sowohl eine PERSON als auch eine ROLE).
Überlappungen deaktivieren (Standard)
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
allow_overlapping: false # Default behaviorSpannen-Auswahlmodi
Wortebene
Nur vollständige Wörter auswählen:
- annotation_type: span
name: entities
selection_mode: word
labels:
- ENTITYZeichenebene
Auswahl von Teilwörtern erlauben:
- annotation_type: span
name: entities
selection_mode: character
labels:
- ENTITYVorannotierte Spannen
Vorhandene Annotationen zur Überprüfung oder Korrektur laden:
{
"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"}
]
}Zum Laden von Vorannotationen konfigurieren:
- annotation_type: span
name: entities
load_pre_annotations: true
pre_annotation_field: spansHäufige NER-Konfigurationen
Standard-NER (4 Typen)
- annotation_type: span
name: ner
description: "Label named entities"
labels:
- PER # Person
- ORG # Organization
- LOC # Location
- MISC # Miscellaneous
label_colors:
PER: "#3b82f6"
ORG: "#10b981"
LOC: "#f59e0b"
MISC: "#6b7280"
keyboard_shortcuts:
PER: "1"
ORG: "2"
LOC: "3"
MISC: "4"Erweitertes NER (OntoNotes-Stil)
- 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
- CARDINALBiomedizinisches NER
- annotation_type: span
name: bio_ner
labels:
- GENE
- PROTEIN
- DISEASE
- DRUG
- SPECIES
label_colors:
GENE: "#22c55e"
PROTEIN: "#3b82f6"
DISEASE: "#ef4444"
DRUG: "#f59e0b"
SPECIES: "#8b5cf6"Social-Media-NER
- annotation_type: span
name: social_ner
labels:
- PERSON
- ORGANIZATION
- LOCATION
- PRODUCT
- CREATIVE_WORK
- GROUPSpannen mit Attributen
Attribute zu Spannen für reichhaltigere Annotation hinzufügen:
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
- PronominalMehrere Spannen-Schemata
Verschiedene Aspekte separat annotieren:
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
label_colors:
POSITIVE: "#22c55e"
NEGATIVE: "#ef4444"Mehrfeld-Spannen-Annotation
Neu in v2.1.0
Die Spannen-Annotation kann über die Option target_field auf bestimmte Textfelder in Mehrfeld-Daten abzielen. Dies ist nützlich, wenn die Daten mehrere Textfelder enthalten und Spannen in einem bestimmten Feld annotiert werden sollen.
Konfiguration
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
- ORGANIZATIONMehrfeld-Datenformat
Die Daten sollten die separaten Textfelder enthalten:
{
"id": "doc1",
"source_text": "John Smith works at Microsoft in Seattle.",
"summary": "Smith is employed by Microsoft."
}Ausgabeformat
Bei Verwendung von target_field werden Annotationen nach Feld aufgeschlüsselt:
{
"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"}
]
}
}Ein vollständiges funktionierendes Beispiel ist unter project-hub/simple_examples/simple-multi-span/ im Potato-Repository verfügbar.
Anzeigeoptionen
Beschriftung in der Spanne anzeigen
Den Beschriftungstext in hervorgehobenen Spannen anzeigen:
- annotation_type: span
name: entities
show_label_in_span: trueUnterstrich-Stil
Unterstreichungen statt Hintergrundhervorhebung verwenden:
- annotation_type: span
name: entities
display_style: underlineAusgabeformat
Spannen-Annotationen werden mit Zeichenoffsets gespeichert:
{
"id": "doc1",
"entities": [
{
"start": 0,
"end": 10,
"text": "John Smith",
"label": "PERSON"
},
{
"start": 20,
"end": 29,
"text": "Microsoft",
"label": "ORGANIZATION"
}
]
}Vollständiges Beispiel: NER-Aufgabe
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
label_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
- HardDiskontinuierliche Spannen
Neu in v2.2.0
Nicht-zusammenhängende Textspannen mit dem Parameter allow_discontinuous aktivieren. Dies ermöglicht Annotatoren, mehrere nicht benachbarte Textsegmente als einzelne Spannen-Annotation auszuwählen – nützlich für diskontinuierliche Entitäten oder geteilte Ausdrücke.
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
allow_discontinuous: trueWenn aktiviert, können Annotatoren eine Modifikatortaste gedrückt halten, während sie weitere Textsegmente auswählen, um sie zur aktuellen Spanne hinzuzufügen. Die Ausgabe enthält mehrere Start-/End-Paare für jedes Segment.
Entitätsverknüpfungs-Integration
Neu in v2.2.0
Spannen-Annotationen können durch Hinzufügen eines entity_linking-Konfigurationsblocks zum Spannen-Schema mit externen Wissensdatenbanken (Wikidata, UMLS oder benutzerdefinierte REST-APIs) verknüpft werden:
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
- LOCATION
entity_linking:
enabled: true
knowledge_bases:
- name: wikidata
type: wikidata
language: enWenn die Entitätsverknüpfung aktiviert ist, erscheint ein Verknüpfungssymbol in der Steuerleiste jeder Spanne. Durch Klicken öffnet sich ein Such-Modal, um passende KB-Entitäten zu finden und zu verknüpfen. Vollständige Details sind in der Entitätsverknüpfungs-Dokumentation zu finden.
Bewährte Vorgehensweisen
- Eindeutige Farben verwenden für einfache visuelle Unterscheidung
- Klare Tooltips bereitstellen mit Beispielen für jeden Entitätstyp
- Tastaturkürzel aktivieren für schnellere Annotation
- Wort-Auswahl verwenden, außer wenn Zeichenpräzision benötigt wird
- Vorannotation erwägen für schnellere Korrektur-Workflows
- Überlappungseinstellungen testen basierend auf den Annotationsrichtlinien
Weiterführende Lektüre
- Entitätsverknüpfung - Spannen mit Wissensdatenbanken verknüpfen
- Koreferenzketten - Koreferente Erwähnungen gruppieren
- Ereignis-Annotation - N-äre Ereignisstrukturen mit Spannen-Argumenten
- Spannenverknüpfung - Beziehungen zwischen Spannen erstellen
- Instanzanzeige - Mehrfeld-Inhaltsanzeige mit Spannen-Zielen
- UI-Konfiguration - Spannenfarben anpassen
- Produktivitätsfunktionen - Tastaturkürzel
Implementierungsdetails sind in der Quelldokumentation zu finden.