Span Linking
एनोटेट किए गए text span के बीच typed संबंध बनाएँ।
Span Linking Annotation
v2.1.0 में नया
Span linking एनोटेटर्स को पहले से एनोटेट किए गए span (टेक्स्ट सेगमेंट) के बीच typed संबंध बनाने की अनुमति देता है। यह relation extraction कार्यों के लिए उपयोगी है जहाँ आपको यह पहचानना होता है कि entity एक-दूसरे से कैसे संबंधित हैं, जैसे "PERSON works_for ORGANIZATION" या "PERSON collaborates_with PERSON"।
अवलोकन
Span linking सुविधा प्रदान करती है:
- Typed संबंध: विभिन्न रंगों और बाधाओं के साथ एकाधिक link प्रकार परिभाषित करें
- निर्देशित और अनिर्देशित लिंक: दिशात्मक और सममित संबंधों दोनों का समर्थन
- N-ary लिंक: कई span के बीच लिंक बनाएँ (केवल जोड़े नहीं)
- दृश्य arc प्रदर्शन: टेक्स्ट के ऊपर रंगीन arc के रूप में रेंडर किए गए संबंध देखें
- लेबल बाधाएँ: source या target कौन से span लेबल हो सकते हैं इसे सीमित करें
कॉन्फ़िगरेशन
Span linking का उपयोग करने के लिए, आपको दो annotation स्कीमा की आवश्यकता है:
- Entity एनोटेट करने के लिए
spanस्कीमा - संबंध एनोटेट करने के लिए
span_linkस्कीमा
annotation_schemes:
# First, define the span schema for named entities
- annotation_type: span
name: entities
description: "Highlight named entities"
labels:
- name: "PERSON"
color: "#3b82f6"
- name: "ORGANIZATION"
color: "#22c55e"
- name: "LOCATION"
color: "#f59e0b"
sequential_key_binding: true
# Then, define the span_link schema for relationships
- annotation_type: span_link
name: relations
description: "Annotate relationships between entities"
span_schema: entities # References the span schema above
link_types:
- name: "WORKS_FOR"
directed: true
allowed_source_labels: ["PERSON"]
allowed_target_labels: ["ORGANIZATION"]
color: "#dc2626"
- name: "COLLABORATES_WITH"
directed: false
allowed_source_labels: ["PERSON"]
allowed_target_labels: ["PERSON"]
color: "#06b6d4"कॉन्फ़िगरेशन विकल्प
आवश्यक फ़ील्ड
| फ़ील्ड | विवरण |
|---|---|
annotation_type | "span_link" होना चाहिए |
name | स्कीमा के लिए अद्वितीय पहचानकर्ता |
description | एनोटेटर्स को दिखाया गया विवरण |
span_schema | लिंक करने के लिए span annotation स्कीमा का नाम |
link_types | Link प्रकार परिभाषाओं की array |
Link प्रकार विकल्प
| फ़ील्ड | प्रकार | विवरण |
|---|---|---|
name | string | आवश्यक। Link प्रकार के लिए नाम/लेबल |
directed | boolean | क्या लिंक दिशात्मक है। डिफ़ॉल्ट: false |
color | string | लिंक के लिए Hex रंग कोड |
allowed_source_labels | array | Span लेबल जो source हो सकते हैं |
allowed_target_labels | array | Span लेबल जो target हो सकते हैं |
max_spans | integer | इस link प्रकार में अधिकतम span (n-ary लिंक के लिए) |
दृश्य प्रदर्शन विकल्प
visual_display:
enabled: true # Show arc visualization
arc_position: "above" # Position of arcs
show_labels: true # Show link type labels on arcsउपयोग
Span बनाना
- पहले, span लेबल चुनकर और टेक्स्ट हाइलाइट करके टेक्स्ट एनोटेट करें
- प्रत्येक हाइलाइट किया गया span लिंक करने के लिए उपलब्ध हो जाता है
लिंक बनाना
- उपलब्ध विकल्पों में से एक link प्रकार चुनें
- वर्तमान लिंक में जोड़ने के लिए span पर क्लिक करें (चयनित span हाइलाइट होते हैं)
- लिंक को अंतिम रूप देने के लिए "Create Link" पर क्लिक करें
- निर्देशित लिंक के लिए, पहला चयनित span source है और अंतिम target है
लिंक देखना
- बनाए गए लिंक "Existing Links" अनुभाग में दिखाई देते हैं
- यदि दृश्य प्रदर्शन सक्षम है, तो लिंक किए गए span को जोड़ने वाले arc टेक्स्ट के ऊपर खींचे जाते हैं
- Arc को link प्रकार के अनुसार रंग-कोड किया गया है
लिंक हटाना
- "Existing Links" अनुभाग में किसी भी लिंक के पास delete बटन (x) पर क्लिक करें
डेटा फॉर्मेट
इनपुट डेटा
ID और टेक्स्ट फ़ील्ड के साथ मानक टेक्स्ट डेटा:
[
{
"id": "item_1",
"text": "John Smith works at Google as a senior engineer."
}
]आउटपुट फॉर्मेट
एनोटेशन में span एनोटेशन और link एनोटेशन दोनों शामिल हैं:
{
"id": "item_1",
"text": "John Smith works at Google as a senior engineer.",
"entities": [
{"start": 0, "end": 10, "label": "PERSON", "text": "John Smith"},
{"start": 20, "end": 26, "label": "ORGANIZATION", "text": "Google"}
],
"relations": [
{
"link_type": "WORKS_FOR",
"span_ids": ["span_abc123", "span_def456"],
"direction": "directed"
}
]
}लेबल बाधाएँ
प्रत्येक link प्रकार में कौन से span लेबल भाग ले सकते हैं इसे सीमित करें:
link_types:
- name: "WORKS_FOR"
directed: true
allowed_source_labels: ["PERSON"] # Only PERSON can be source
allowed_target_labels: ["ORGANIZATION"] # Only ORGANIZATION can be targetजब बाधाओं का उल्लंघन होता है, तो UI एक error message दिखाता है और link निर्माण को रोकता है।
N-ary लिंक
डिफ़ॉल्ट रूप से, लिंक बिल्कुल 2 span को जोड़ते हैं। अधिक entity वाले संबंधों के लिए:
link_types:
- name: "MEETING"
directed: false
max_spans: 5 # Allow up to 5 participants
allowed_source_labels: ["PERSON"]
allowed_target_labels: ["PERSON"]उदाहरण
यहाँ पूर्ण कार्यशील उदाहरण देखें:
- Config:
project-hub/simple_examples/simple-span-linking/config.yaml - Data:
project-hub/simple_examples/simple-span-linking/data.json
चलाने के लिए:
cd project-hub/simple_examples
python ../../potato/flask_server.py start simple-span-linking/config.yaml -p 9001सुझाव
- पहले span एनोटेट करें: लिंक करने से पहले span एनोटेशन बनाना सुनिश्चित करें
- रंगों का प्रभावी उपयोग करें: विभिन्न link प्रकारों के लिए विशिष्ट रंग चुनें
- दिशा पर विचार करें: निर्देशित लिंक का उपयोग करें जब संबंध की स्पष्ट दिशा हो
- कीबोर्ड शॉर्टकट: Span लेबल तेज़ एनोटेशन के लिए कीबोर्ड शॉर्टकट (1, 2, 3...) का समर्थन करते हैं
अधिक पढ़ें
- Span Annotation - बुनियादी span एनोटेशन
- UI Configuration - रंग और प्रदर्शन कस्टमाइज़ करें
कार्यान्वयन विवरण के लिए, स्रोत दस्तावेज़ीकरण देखें।