スパンアノテーション
固有表現認識などのためのテキストスパンのハイライトとラベル付け。
スパンアノテーション
スパンアノテーションにより、アノテーターはテキストの一部を選択してラベルを付けることができます。固有表現認識(NER)、品詞タグ付け、テキストハイライトタスクなどに一般的に使用されます。
基本設定
annotation_schemes:
- annotation_type: span
name: entities
description: "Highlight named entities in the text"
labels:
- PERSON
- ORGANIZATION
- LOCATION設定オプション
エンティティラベル
アノテーターが作成できるスパンの種類を定義:
labels:
- PERSON
- ORGANIZATION
- LOCATION
- DATE
- EVENTラベルカラー
視覚的な区別のためにカラーをカスタマイズ:
label_colors:
PERSON: "#3b82f6"
ORGANIZATION: "#10b981"
LOCATION: "#f59e0b"
DATE: "#8b5cf6"
EVENT: "#ec4899"カラーは16進数(#ff0000)またはRGB(rgb(255, 0, 0))で指定できます。
キーボードショートカット
キーボードバインディングでアノテーションを高速化:
keyboard_shortcuts:
PERSON: "1"
ORGANIZATION: "2"
LOCATION: "3"
DATE: "4"ツールチップ
各ラベルのガイダンスを提供:
tooltips:
PERSON: "Names of people, characters, or personas"
ORGANIZATION: "Companies, agencies, institutions"
LOCATION: "Physical locations, addresses, geographic regions"重複スパン
重複を許可
重複可能なスパンを有効化:
- annotation_type: span
name: entities
labels:
- PERSON
- ROLE
allow_overlapping: trueこれは同じテキストに複数のラベルを付ける場合に便利です(例:「Dr. Smith」はPERSONでありROLEでもある)。
重複を無効化(デフォルト)
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
allow_overlapping: false # Default behaviorスパン選択モード
単語レベル選択
完全な単語のみを選択:
- annotation_type: span
name: entities
selection_mode: word
labels:
- ENTITY文字レベル選択
部分的な単語の選択を許可:
- annotation_type: span
name: entities
selection_mode: character
labels:
- ENTITY事前アノテーションされたスパン
レビューまたは修正のために既存のアノテーションを読み込み:
{
"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"}
]
}事前アノテーションの読み込みを設定:
- annotation_type: span
name: entities
load_pre_annotations: true
pre_annotation_field: spans一般的なNER設定
標準NER(4タイプ)
- 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"拡張NER(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
- CARDINAL生物医学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"ソーシャルメディアNER
- annotation_type: span
name: social_ner
labels:
- PERSON
- ORGANIZATION
- LOCATION
- PRODUCT
- CREATIVE_WORK
- GROUP属性付きスパン
より豊かなアノテーションのためにスパンに属性を追加:
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複数のスパンスキーム
異なる側面を別々にアノテーション:
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"マルチフィールドスパンアノテーション
v2.1.0の新機能
スパンアノテーションはtarget_fieldオプションを使用して、マルチフィールドデータの特定のテキストフィールドをターゲットにできます。データに複数のテキストフィールドがあり、特定のフィールドのスパンをアノテーションしたい場合に便利です。
設定
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マルチフィールドデータ形式
データに個別のテキストフィールドを含める必要があります:
{
"id": "doc1",
"source_text": "John Smith works at Microsoft in Seattle.",
"summary": "Smith is employed by Microsoft."
}出力形式
target_fieldを使用する場合、アノテーションはフィールドごとにキー付けされます:
{
"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/を参照してください。
表示オプション
スパン内にラベルを表示
ハイライトされたスパン内にラベルテキストを表示:
- annotation_type: span
name: entities
show_label_in_span: trueアンダーラインスタイル
背景ハイライトの代わりにアンダーラインを使用:
- annotation_type: span
name: entities
display_style: underline出力形式
スパンアノテーションは文字オフセットで保存されます:
{
"id": "doc1",
"entities": [
{
"start": 0,
"end": 10,
"text": "John Smith",
"label": "PERSON"
},
{
"start": 20,
"end": 29,
"text": "Microsoft",
"label": "ORGANIZATION"
}
]
}完全な例:NERタスク
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
- Hard不連続スパン
v2.2.0の新機能
allow_discontinuousパラメータで非連続テキストスパンを有効にします。これにより、アノテーターは複数の非隣接テキストセグメントを単一のスパンアノテーションとして選択できます。不連続エンティティや分割表現に便利です。
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
allow_discontinuous: true有効にすると、アノテーターは修飾キーを押しながら追加のテキストセグメントを選択して現在のスパンに追加できます。出力には各セグメントの複数のstart/endペアが含まれます。
エンティティリンキング統合
v2.2.0の新機能
スパンアノテーションにスパンスキーマにentity_linking設定ブロックを追加することで、外部知識ベース(Wikidata、UMLS、またはカスタムREST API)にリンクできます:
- annotation_type: span
name: entities
labels:
- PERSON
- ORGANIZATION
- LOCATION
entity_linking:
enabled: true
knowledge_bases:
- name: wikidata
type: wikidata
language: enエンティティリンキングが有効な場合、各スパンのコントロールバーにリンクアイコンが表示されます。クリックすると一致するKBエンティティを検索するモーダルが開きます。詳細はエンティティリンキングのドキュメントを参照してください。
ベストプラクティス
- 区別しやすいカラーを使用 - 視覚的な区別を容易にする
- 各エンティティタイプに例付きの明確なツールチップを提供
- キーボードショートカットを有効化 - より高速なアノテーションのため
- 文字精度が不要な場合は単語レベル選択を使用
- 事前アノテーションを検討 - 修正ワークフローの高速化
- アノテーションガイドラインに基づいて重複設定をテスト
関連資料
- エンティティリンキング - スパンの知識ベースへのリンク
- 共参照チェーン - 共参照メンションのグループ化
- イベントアノテーション - スパン引数を持つN項イベント構造
- スパンリンキング - スパン間の関係の作成
- インスタンス表示 - スパンターゲット付きマルチフィールドコンテンツ表示
- UI設定 - スパンカラーのカスタマイズ
- 生産性機能 - キーボードショートカット
実装の詳細については、ソースドキュメントを参照してください。