Skip to content
このページはまだお使いの言語に翻訳されていません。英語版を表示しています。

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 स्कीमा की आवश्यकता है:

  1. Entity एनोटेट करने के लिए span स्कीमा
  2. संबंध एनोटेट करने के लिए span_link स्कीमा
yaml
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_typesLink प्रकार परिभाषाओं की array
फ़ील्डप्रकारविवरण
namestringआवश्यक। Link प्रकार के लिए नाम/लेबल
directedbooleanक्या लिंक दिशात्मक है। डिफ़ॉल्ट: false
colorstringलिंक के लिए Hex रंग कोड
allowed_source_labelsarraySpan लेबल जो source हो सकते हैं
allowed_target_labelsarraySpan लेबल जो target हो सकते हैं
max_spansintegerइस link प्रकार में अधिकतम span (n-ary लिंक के लिए)

दृश्य प्रदर्शन विकल्प

yaml
visual_display:
  enabled: true        # Show arc visualization
  arc_position: "above"  # Position of arcs
  show_labels: true    # Show link type labels on arcs

उपयोग

Span बनाना

  1. पहले, span लेबल चुनकर और टेक्स्ट हाइलाइट करके टेक्स्ट एनोटेट करें
  2. प्रत्येक हाइलाइट किया गया span लिंक करने के लिए उपलब्ध हो जाता है

लिंक बनाना

  1. उपलब्ध विकल्पों में से एक link प्रकार चुनें
  2. वर्तमान लिंक में जोड़ने के लिए span पर क्लिक करें (चयनित span हाइलाइट होते हैं)
  3. लिंक को अंतिम रूप देने के लिए "Create Link" पर क्लिक करें
  4. निर्देशित लिंक के लिए, पहला चयनित span source है और अंतिम target है

लिंक देखना

  • बनाए गए लिंक "Existing Links" अनुभाग में दिखाई देते हैं
  • यदि दृश्य प्रदर्शन सक्षम है, तो लिंक किए गए span को जोड़ने वाले arc टेक्स्ट के ऊपर खींचे जाते हैं
  • Arc को link प्रकार के अनुसार रंग-कोड किया गया है

लिंक हटाना

  • "Existing Links" अनुभाग में किसी भी लिंक के पास delete बटन (x) पर क्लिक करें

डेटा फॉर्मेट

इनपुट डेटा

ID और टेक्स्ट फ़ील्ड के साथ मानक टेक्स्ट डेटा:

json
[
  {
    "id": "item_1",
    "text": "John Smith works at Google as a senior engineer."
  }
]

आउटपुट फॉर्मेट

एनोटेशन में span एनोटेशन और link एनोटेशन दोनों शामिल हैं:

json
{
  "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 लेबल भाग ले सकते हैं इसे सीमित करें:

yaml
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 वाले संबंधों के लिए:

yaml
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

चलाने के लिए:

bash
cd project-hub/simple_examples
python ../../potato/flask_server.py start simple-span-linking/config.yaml -p 9001

सुझाव

  1. पहले span एनोटेट करें: लिंक करने से पहले span एनोटेशन बनाना सुनिश्चित करें
  2. रंगों का प्रभावी उपयोग करें: विभिन्न link प्रकारों के लिए विशिष्ट रंग चुनें
  3. दिशा पर विचार करें: निर्देशित लिंक का उपयोग करें जब संबंध की स्पष्ट दिशा हो
  4. कीबोर्ड शॉर्टकट: Span लेबल तेज़ एनोटेशन के लिए कीबोर्ड शॉर्टकट (1, 2, 3...) का समर्थन करते हैं

अधिक पढ़ें

  • Span Annotation - बुनियादी span एनोटेशन
  • UI Configuration - रंग और प्रदर्शन कस्टमाइज़ करें

कार्यान्वयन विवरण के लिए, स्रोत दस्तावेज़ीकरण देखें।