extract

GitHub

执行Semantica完整语义提取流水线,支持NER、关系、事件及三元组抽取。自动解析文件/文本源,清理缓存后运行模型并验证质量,最终返回Markdown表格形式的结构化结果及警告信息。

plugins/skills/extract/SKILL.md semantica-agi/semantica

触发场景

需要提取文本中的实体和关系时 对文件或代码进行语义分析时

安装

npx skills add semantica-agi/semantica --skill extract -g -y
更多选项

非标准路径

npx skills add https://github.com/semantica-agi/semantica/tree/main/plugins/skills/extract -g -y

不安装直接使用

npx skills use semantica-agi/semantica@extract

指定 Agent (Claude Code)

npx skills add semantica-agi/semantica --skill extract -a claude-code -g -y

安装 repo 全部 skill

npx skills add semantica-agi/semantica --all -g -y

预览 repo 内 skill

npx skills add semantica-agi/semantica --list

SKILL.md

Frontmatter
{
    "name": "extract",
    "description": "Run the full Semantica semantic extraction pipeline on a file or selected text — NER, relations, events, coreference resolution, triplets, and validation. Clears result cache before each run. Returns Markdown tables with entity\/relation\/event\/triplet results and inline validator warnings."
}

/semantica:extract

Run the full extraction pipeline. Usage: /semantica:extract [file_path | "inline text"]

$ARGUMENTS = file path, inline text in quotes, or blank (uses active editor file).


Steps

1. Resolve the source.

  • If $ARGUMENTS is a readable file path → text = open(path).read()
  • If it's quoted inline text → use directly
  • If blank → use the active editor file

2. Clear the result cache to prevent cross-invocation pollution:

from semantica.semantic_extract.cache import extraction_cache
extraction_cache.clear()

3. Run the full pipeline:

from semantica.semantic_extract import (
    NamedEntityRecognizer,
    RelationExtractor,
    EventDetector,
    CoreferenceResolver,
    TripletExtractor,
    ExtractionValidator,
)

# Named Entity Recognition
ner = NamedEntityRecognizer()
entities = ner.extract(text)

# Relation Extraction
rel = RelationExtractor()
relations = rel.extract(text)

# Event Detection
evt = EventDetector()
events = evt.extract(text)

# Coreference Resolution — resolve pronouns/aliases before extraction
coref = CoreferenceResolver()
resolved_text = coref.resolve(text)

# Triplet Extraction (subject–predicate–object)
triplet = TripletExtractor()
triplets = triplet.extract(resolved_text)

# Validate quality
validator = ExtractionValidator()
issues = validator.validate(entities, relations)

4. Report validator warnings above results:

⚠ ExtractionValidator: <warning message>

5. Return results as Markdown tables:

Entities (N total)

Label Type Confidence Span

Relations (M total)

Source Relation Type Target Confidence

Events (K total)

Label Type Participants Confidence

Triplets (J total)

Subject Predicate Object Confidence

6. Summary line:

Extracted: N entities, M relations, K events, J triplets — from <source>

For large files (>50KB), process in chunks and show a progress indicator. Highlight any entities appearing in the context graph already (ContextGraph.has_node(label)) with [in graph] tag.

版本历史

  • fdf3fd8 当前 2026-09-22 03:20

    修复了缓存模块导入路径错误的问题,将私有变量名更正为公开的extraction_cache实例。

  • 9094f1e 2026-07-05 09:26

同 Skill 集合

.claude/skills/semantica/SKILL.md
plugins/skills/causal/SKILL.md
plugins/skills/change/SKILL.md
plugins/skills/decision/SKILL.md
plugins/skills/deduplicate/SKILL.md
plugins/skills/explain/SKILL.md
plugins/skills/export/SKILL.md
plugins/skills/ingest/SKILL.md
plugins/skills/ontology/SKILL.md
plugins/skills/policy/SKILL.md
plugins/skills/provenance/SKILL.md
plugins/skills/query/SKILL.md

元信息

文件数
0
版本
47d3cc7
Hash
de4554e1
收录时间
2026-07-05 09:26

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-11-02 23:25
浙ICP备14020137号-1