← 返回 Skills 市场
fisa712

Knowledge Graph - Text Entity Relation Extractor

作者 Muhammad Asif · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
39
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install text-entity-relation-extractor
功能描述
Extract entities and relationships from unstructured text and convert them into graph-ready structures such as triples, nodes, and edges.
使用说明 (SKILL.md)

Text Entity Relation Extractor

Extract structured knowledge from unstructured text.

This skill analyzes natural language text and identifies entities and relationships that can be converted into knowledge graph structures such as nodes, edges, or semantic triples. It is useful for transforming documents, articles, transcripts, or raw text into graph-ready data suitable for knowledge graphs, semantic systems, or graph databases.

Quick Start

Use When

  • Extracting entities from text
  • Identifying relationships between entities
  • Converting natural language text into knowledge graphs
  • Generating triples from unstructured text
  • Building graph datasets from documents
  • Performing information extraction from unstructured content
  • Mining knowledge from documents

Inputs

  • Unstructured text documents
  • Text corpus or collection
  • Natural language text strings
  • Entity type specifications
  • Relationship pattern definitions
  • Extraction rules and configurations
  • Training data (optional)

Outputs

  • Extracted entities with types
  • Detected relationships
  • RDF triples or semantic statements
  • Graph JSON (nodes and edges)
  • Entity-relationship tables
  • Confidence scores
  • Extracted knowledge base

Example

Input Text:

Elon Musk founded SpaceX in 2002. SpaceX is headquartered 
in Hawthorne, California and develops reusable spacecraft. 
The company employs over 9,000 people and has partnerships 
with NASA for space exploration missions.

Extracted Entities:

Elon Musk → PERSON
SpaceX → ORGANIZATION
2002 → DATE
Hawthorne → LOCATION
California → LOCATION
NASA → ORGANIZATION
9,000 → QUANTITY

Extracted Relationships:

Elon Musk -[FOUNDED]-> SpaceX
SpaceX -[HEADQUARTERED_IN]-> Hawthorne
SpaceX -[HEADQUARTERED_IN]-> California
SpaceX -[DEVELOPS]-> Spacecraft
SpaceX -[EMPLOYS]-> 9,000 people
SpaceX -[PARTNERS_WITH]-> NASA

Generated RDF Triples:

:Elon_Musk a foaf:Person ;
  foaf:founded :SpaceX .

:SpaceX a schema:Organization ;
  schema:foundationDate "2002"^^xsd:gYear ;
  schema:headquartersLocation :Hawthorne ;
  schema:numberOfEmployees 9000 ;
  schema:partnerOf :NASA .

:Hawthorne a schema:Place ;
  schema:location :California .

Text Extraction Architecture

1. Named Entity Recognition (NER)

Purpose: Identify and classify entities in text

Entity Types Supported:

  • PERSON - Individual people
  • ORGANIZATION - Companies, institutions
  • LOCATION - Places, geographic regions
  • DATE - Temporal expressions
  • QUANTITY - Numbers, measurements
  • PRODUCT - Items, goods, services
  • EVENT - Named events, conferences
  • LANGUAGE - Languages and dialects
  • GPE - Geopolitical entities
  • FACILITY - Buildings, infrastructure

Configuration:

ner:
  model: spacy|bert|custom
  entity_types:
    - PERSON
    - ORGANIZATION
    - LOCATION
  confidence_threshold: 0.7
  case_sensitive: true

2. Relationship Detection

Purpose: Identify and extract relationships between entities

Relationship Types:

  • Domain-Specific - Custom relationships
  • Syntactic - Based on grammar patterns
  • Semantic - Based on meaning
  • Knowledge-Based - Using knowledge bases

Detection Methods:

Dependency Parsing:
  - Extract based on syntactic dependencies
  - Example: SUBJECT -[verb]-> OBJECT

Pattern Matching:
  - Use predefined patterns
  - Example: [PERSON] works at [ORGANIZATION]

Machine Learning:
  - Train on annotated data
  - Classify relationship types

Knowledge Extraction:
  - Use external knowledge bases
  - Semantic role labeling

Configuration:

relation_extraction:
  method: dependency|pattern|ml|hybrid
  relationship_types:
    - WORKS_AT
    - LOCATED_IN
    - FOUNDED
    - OWNS
  confidence_threshold: 0.6

3. Entity Normalization

Purpose: Standardize and deduplicate entities

Operations:

  • Name Normalization - Standardize spelling and format
  • Alias Resolution - Map aliases to canonical form
  • Deduplication - Merge equivalent entities
  • URI Generation - Create unique identifiers

Configuration:

normalization:
  lowercase: true
  remove_punctuation: true
  alias_mapping:
    USA: United States
    NYC: New York City
  deduplication:
    similarity_threshold: 0.85

4. Triple Generation

Purpose: Convert extracted knowledge to RDF triples

Components:

  • Subject - Entity or reference
  • Predicate - Relationship type
  • Object - Target entity or literal

Example:

Elon_Musk -[FOUNDED]-> SpaceX
SpaceX -[HEADQUARTERS]-> Hawthorne
SpaceX -[EMPLOYEE_COUNT]-> 9000

5. Graph Construction

Purpose: Build knowledge graph from triples

Output:

  • Nodes representing entities
  • Edges representing relationships
  • Attributes on nodes and edges
  • Connected graph structure

Extraction Patterns

Named Entity Recognition Pattern

Pattern: Identify entity boundaries and types

Text: "Apple Inc. was founded in 1976 by Steve Jobs."

Extracted:
  Apple Inc. → ORGANIZATION
  1976 → DATE
  Steve Jobs → PERSON

Relationship Extraction Pattern

Pattern: Extract [Entity1] -[Relation]-> [Entity2]

Text: "Steve Jobs founded Apple Inc."

Extracted:
  Steve Jobs -[FOUNDED]-> Apple Inc.
  Type: FOUNDER_OF
  Confidence: 0.92

Dependency Parsing Pattern

Pattern: Use syntactic structure to extract relations

Dependency: nsubj(VERB, PERSON), dobj(VERB, ORG)

Example:
  Person → VERB → Organization
  John → founded → Apple

Pattern-Based Extraction

Pattern: Use handcrafted extraction rules

Rule: [PERSON] works at [ORGANIZATION]
Match: "Alice works at Acme"
Extract: Alice -[WORKS_AT]-> Acme

Rule: [ORG] is located in [LOCATION]
Match: "Google is located in Mountain View"
Extract: Google -[LOCATED_IN]-> Mountain View

Output Formats

RDF Triples

@prefix ex: \x3Chttp://example.org/> .
@prefix foaf: \x3Chttp://xmlns.com/foaf/0.1/> .
@prefix schema: \x3Chttp://schema.org/> .

ex:Elon_Musk a foaf:Person ;
  foaf:name "Elon Musk" ;
  ex:founded ex:SpaceX .

ex:SpaceX a schema:Organization ;
  foaf:name "SpaceX" ;
  schema:foundingDate "2002"^^xsd:gYear ;
  schema:headquartersLocation ex:Hawthorne .

Graph JSON

{
  "nodes": [
    {"id": "Elon Musk", "type": "PERSON", "properties": {"name": "Elon Musk"}},
    {"id": "SpaceX", "type": "ORGANIZATION", "properties": {"name": "SpaceX", "founded": 2002}},
    {"id": "Hawthorne", "type": "LOCATION", "properties": {"name": "Hawthorne"}}
  ],
  "edges": [
    {"source": "Elon Musk", "target": "SpaceX", "type": "FOUNDED", "confidence": 0.92},
    {"source": "SpaceX", "target": "Hawthorne", "type": "HEADQUARTERED_IN", "confidence": 0.88}
  ]
}

Tabular Format

Entity 1 Type 1 Relationship Entity 2 Type 2 Confidence
Elon Musk PERSON FOUNDED SpaceX ORG 0.92
SpaceX ORG HEADQUARTERED_IN Hawthorne LOCATION 0.88

Execution Steps

  1. Preprocess Text – Tokenize, normalize, split sentences
  2. Apply NER – Identify and classify entities
  3. Detect Relationships – Extract entity connections
  4. Normalize Entities – Standardize names, deduplicate
  5. Generate Triples – Create RDF statements
  6. Score Confidence – Calculate extraction confidence
  7. Build Graph – Construct knowledge graph
  8. Format Output – Generate requested output format

Confidence Scoring

Entity Confidence:

Score = Model_Confidence × Type_Confidence × Normalization_Score
Range: 0.0 - 1.0
Threshold: Usually 0.6-0.8 for filtering

Relationship Confidence:

Score = Detection_Score × Entity_Confidence × Pattern_Match_Score
Factors:
  - Model prediction confidence
  - Dependency strength
  - Pattern specificity

Recommended Libraries

  • NER/NLP: spaCy, NLTK, Transformers (BERT, RoBERTa)
  • Relation Extraction: AllenNLP, OpenIE, Stanford CoreNLP
  • Text Processing: NLTK, TextBlob, Gensim
  • Graph Building: networkx, rdflib, pyLD
  • Machine Learning: scikit-learn, TensorFlow, PyTorch
  • Utilities: pandas, numpy, regex

Best Practices

✓ Choose appropriate NER models for domain
✓ Validate extracted relationships
✓ Normalize entity names consistently
✓ Remove low-confidence extractions
✓ Handle entity disambiguation
✓ Document extraction patterns
✓ Test with domain-specific text
✓ Manage performance with long texts
✓ Validate against domain knowledge
✓ Monitor confidence scores

Integration with Downstream Skills

Extracted knowledge feeds into:

  • Mapping DSL Builder – Define mappings from extracted data
  • Graph Constraint Generator – Add constraints to extracted graph
  • Graph Schema Validation – Validate extracted triples
  • Knowledge Graph Construction – Build KGs from extractions
  • ETL Pipeline Generator – Process extractions in pipelines

References

See extraction-patterns.md for detailed NER and relationship extraction patterns and example-extractions.md for complete real-world examples.


Version: 1.0.0

安全使用建议
Install is reasonable for local NLP and knowledge-graph extraction. Avoid processing real medical, legal, or personal records unless you have authorization, and prefer de-identified inputs because the skill is designed to surface names, dates, diagnoses, organizations, and relationships from whatever text you provide.
能力评估
Purpose & Capability
The skill coherently describes extracting entities and relationships from user-provided text into triples, graph JSON, RDF, and tables; the Python utility implements local rule-based extraction aligned with that purpose.
Instruction Scope
The instructions are broad and include a medical report example with identifiable-looking patient and provider details, so users need privacy discipline when using it on sensitive text.
Install Mechanism
No install hooks, package dependencies, postinstall behavior, or hidden setup mechanism were found in the artifact.
Credentials
The script uses standard Python modules for regex-based local processing; review found no network calls, subprocess execution, credential access, telemetry, or filesystem mutation.
Persistence & Privilege
No persistence mechanism, background worker, privilege escalation, session/profile use, or long-running behavior was present.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install text-entity-relation-extractor
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /text-entity-relation-extractor 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release of the Text Entity Relation Extractor skill. - Extracts entities and relationships from unstructured text for knowledge graph construction. - Supports named entity recognition (PERSON, ORGANIZATION, LOCATION, DATE, etc.) and relationship extraction with configurable patterns and models. - Outputs include RDF triples, graph JSON (nodes and edges), entity-relationship tables, and confidence scores. - Provides entity normalization (deduplication, alias mapping) and flexible extraction architecture. - Suitable for converting natural language content into graph-ready datasets and semantic structures.
元数据
Slug text-entity-relation-extractor
版本 1.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Knowledge Graph - Text Entity Relation Extractor 是什么?

Extract entities and relationships from unstructured text and convert them into graph-ready structures such as triples, nodes, and edges. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 39 次。

如何安装 Knowledge Graph - Text Entity Relation Extractor?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install text-entity-relation-extractor」即可一键安装,无需额外配置。

Knowledge Graph - Text Entity Relation Extractor 是免费的吗?

是的,Knowledge Graph - Text Entity Relation Extractor 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Knowledge Graph - Text Entity Relation Extractor 支持哪些平台?

Knowledge Graph - Text Entity Relation Extractor 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Knowledge Graph - Text Entity Relation Extractor?

由 Muhammad Asif(@fisa712)开发并维护,当前版本 v1.0.0。

💬 留言讨论