Annotation de spans
Surlignez et étiquetez des spans de texte dans Potato pour la NER, l'extraction de relations et le sentiment. Configurez types de spans, couleurs, spans chevauchants et raccourcis clavier.
L'annotation de spans permet aux annotateurs de sélectionner et d'étiqueter des portions de texte. Elle sert couramment à la reconnaissance d'entités nommées (NER), à l'étiquetage morphosyntaxique et aux tâches de surlignage de texte.
Annotation de spans avec étiquettes d'entités colorées dans Potato
Configuration de base
annotation_schemes:
- annotation_type: span
name: entities
description: "Highlight named entities in the text"
labels:
- PERSON
- ORGANIZATION
- LOCATIONOptions de configuration
Étiquettes d'entités
Définissez les types de spans que les annotateurs peuvent créer :
labels:
- PERSON
- ORGANIZATION
- LOCATION
- DATE
- EVENTCouleurs
Personnalisez les couleurs pour une distinction visuelle :
colors:
PERSON: "#3b82f6"
ORGANIZATION: "#10b981"
LOCATION: "#f59e0b"
DATE: "#8b5cf6"
EVENT: "#ec4899"Les couleurs peuvent être en hexadécimal (#ff0000) ou en RGB (rgb(255, 0, 0)).
Raccourcis clavier
Accélérez l'annotation avec des raccourcis clavier :
keyboard_shortcuts:
PERSON: "1"
ORGANIZATION: "2"
LOCATION: "3"
DATE: "4"Infobulles
Fournissez des consignes pour chaque étiquette :
tooltips:
PERSON: "Names of people, characters, or personas"
ORGANIZATION: "Companies, agencies, institutions"
LOCATION: "Physical locations, addresses, geographic regions"Spans chevauchants
Autoriser le chevauchement
Activez les spans qui peuvent se chevaucher :
- annotation_type: span
name: entities
labels:
- PERSON
- ROLE
allow_discontinuous: trueC'est utile quand un même texte peut porter plusieurs étiquettes (par exemple, « Dr. Smith » est à la fois une PERSON et porte un ROLE).
Désactiver le chevauchement (par défaut)
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
allow_discontinuous: false # Default behaviorModes de sélection de span
Sélection au niveau du mot
Sélectionner uniquement des mots entiers :
- annotation_type: span
name: entities
labels:
- ENTITYSélection au niveau du caractère
Autoriser la sélection de portions de mots :
- annotation_type: span
name: entities
labels:
- ENTITYSpans pré-annotés
Chargez des annotations existantes pour révision ou correction :
{
"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"}
]
}Configurez le chargement des pré-annotations :
- annotation_type: span
name: entitiesConfigurations NER courantes
NER standard (4 types)
- annotation_type: span
name: ner
description: "Label named entities"
labels:
- PER # Person
- ORG # Organization
- LOC # Location
- MISC # Miscellaneous
sequential_key_binding:
PER: "1"
ORG: "2"
LOC: "3"
MISC: "4"NER étendue (style OntoNotes)
- 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
- CARDINALNER biomédicale
- annotation_type: span
name: bio_ner
labels:
- GENE
- PROTEIN
- DISEASE
- DRUG
- SPECIESNER pour réseaux sociaux
- annotation_type: span
name: social_ner
labels:
- PERSON
- ORGANIZATION
- LOCATION
- PRODUCT
- CREATIVE_WORK
- GROUPSpans avec attributs
Ajoutez des attributs aux spans pour une annotation plus riche :
annotation_schemes:
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
- annotation_type: radio
name: entity_type
description: "What type of entity is this?"
labels:
- Named
- Nominal
- PronominalPlusieurs schémas de spans
Annotez séparément différents aspects :
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
- NEGATIVEAnnotation de spans multi-champs
Nouveau en v2.1.0
L'annotation de spans peut cibler des champs de texte précis dans des données multi-champs via l'option target_field. C'est utile quand vos données contiennent plusieurs champs de texte et que vous voulez annoter les spans dans l'un d'eux en particulier.
Configuration
annotation_schemes:
- annotation_type: span
name: source_entities
description: "Label entities in the source text"
labels:
- PERSON
- ORGANIZATION
- annotation_type: span
name: summary_entities
description: "Label entities in the summary"
labels:
- PERSON
- ORGANIZATIONFormat des données multi-champs
Vos données doivent inclure les champs de texte séparés :
{
"id": "doc1",
"source_text": "John Smith works at Microsoft in Seattle.",
"summary": "Smith is employed by Microsoft."
}Format de sortie
Avec target_field, les annotations sont indexées par champ :
{
"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"}
]
}
}Pour un exemple complet et fonctionnel, voir project-hub/simple_examples/simple-multi-span/ dans le dépôt Potato.
Options d'affichage
Afficher l'étiquette dans le span
Affichez le texte de l'étiquette à l'intérieur des spans surlignés :
- annotation_type: span
name: entitiesStyle souligné
Utilisez des soulignements au lieu d'un surlignage de fond :
- annotation_type: span
name: entitiesFormat de sortie
Les annotations de spans sont enregistrées avec des décalages de caractères :
{
"id": "doc1",
"entities": [
{
"start": 0,
"end": 10,
"text": "John Smith",
"label": "PERSON"
},
{
"start": 20,
"end": 29,
"text": "Microsoft",
"label": "ORGANIZATION"
}
]
}Exemple complet : tâche de NER
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
sequential_key_binding:
PERSON: "1"
ORGANIZATION: "2"
LOCATION: "3"
DATE: "4"
MONEY: "5"
allow_discontinuous: false
- annotation_type: radio
name: difficulty
description: "How difficult was this document to annotate?"
labels:
- Easy
- Medium
- HardSpans discontinus
Nouveau en v2.2.0
Activez les spans de texte non contigus avec le paramètre allow_discontinuous. Les annotateurs peuvent alors sélectionner plusieurs segments de texte non adjacents comme une seule annotation de span, ce qui sert pour les entités discontinues ou les expressions scindées.
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
allow_discontinuous: trueUne fois activé, les annotateurs peuvent maintenir une touche de modification pendant qu'ils sélectionnent des segments de texte supplémentaires pour les ajouter au span courant. La sortie contient plusieurs paires début/fin, une par segment.
Intégration du liage d'entités
Nouveau en v2.2.0
Les annotations de spans peuvent être liées à des bases de connaissances externes (Wikidata, UMLS ou API REST personnalisées) en ajoutant un bloc de configuration entity_linking au schéma de span :
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
- LOCATION
entity_linking:
enabled: true
knowledge_bases:
- name: wikidata
type: wikidata
language: enQuand le liage d'entités est activé, une icône de lien apparaît dans la barre de contrôle de chaque span. Un clic ouvre une fenêtre de recherche pour trouver et lier les entités correspondantes de la base. Voir la documentation Liage d'entités pour tous les détails.
Bonnes pratiques
- Utilisez des couleurs distinctes pour une différenciation visuelle facile
- Fournissez des infobulles claires avec des exemples pour chaque type d'entité
- Activez les raccourcis clavier pour annoter plus vite
- Utilisez la sélection au niveau du mot sauf si une précision au caractère est nécessaire
- Envisagez la pré-annotation pour accélérer les flux de correction
- Testez les réglages de chevauchement selon vos consignes d'annotation
Pour aller plus loin
- Liage d'entités - Liez des spans à des bases de connaissances
- Chaînes de coréférence - Regroupez les mentions coréférentes
- Annotation d'événements - Structures d'événements n-aires avec arguments de span
- Liage de spans - Créez des relations entre spans
- Affichage des instances - Affichage de contenu multi-champs avec cibles de span
- Configuration de l'interface - Personnalisez les couleurs de spans
- Fonctionnalités de productivité - Raccourcis clavier
Pour les détails d'implémentation, voir la documentation source.