Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
feat: 添加领域模板示例文件并更新文档
yifanfeng97e86df4c1a783
diff --git a/README.md b/README.mdindex 5e32edc..fb5a000 100644--- a/README.md+++ b/README.md@@ -1,7 +1,7 @@# 🔍 Hyper-Extract> **"Stop reading. Start understanding."**->+> *"告别文档焦虑,让信息一目了然"*Transform documents into **knowledge abstracts** — with just one command.@@ -17,71 +17,41 @@ Transform documents into **knowledge abstracts** — with just one command.```bashpip install hyper-extract-he config init-he parse document.md -o ka -l zh-he talk ka -i-```---------## ⚙️ Quick Configuration--**Recommended**: gpt-4o-mini (fast & stable for structured extraction) + text-embedding-3-small--```bashhe config init -k YOUR_API_KEY-# Or with custom base URL-he config init -k YOUR_KEY -u https://api.openai.com/v1++he parse document.md -o ./knowledge_abstract/ -l zh```-View config: `he config show`+> 🔗 For detailed usage, see [CLI Guide](./hyperextract/cli/README.md)----## 💡 Usage Example+## ✨ Key Features-```bash-he parse document.md -o ka -l zh-he show ka-he search ka "key insights"-```+| 🤖 8 Knowledge Types | 🌍 38+ Domain Templates | 💻 Interactive CLI | 🔍 Semantic Search |+|:---:|:---:|:---:|:---:|+| From lists to spatio-temporal graphs | Finance, Medical, Legal ready-to-use | One command for full workflow | FAISS vector similarity |++> 🔗 Learn more about [8 Knowledge Types](#knowledge-types) | [Domain Templates](#domain-templates)----## 🧩 Knowledge Abstract Types+## 📊 Knowledge Types-8 structures for extracting different types of information:--**Record Types:**-| Structure | Best For | Example |-|-----------|----------|---------|-| AutoModel | Structured reports | Financial statements |-| AutoList | Key points | Meeting notes |-| AutoSet | Entity collection | Product catalog |--**Graph Types:**-| Structure | Best For | Example |-|-----------|----------|---------|+| Type | Best For | Example |+|------|----------|---------|+| AutoModel | Structured reports | Financial summaries |+| AutoList | Ordered lists | Meeting notes |+| AutoSet | Deduplicated collections | Product catalogs || AutoGraph | Binary relations | Social networks |-| AutoHypergraph | Multi-party events | Legal disputes |-| AutoTemporalGraph | Event sequences | News timeline |-| AutoSpatialGraph | Locations | Delivery routes |+| AutoHypergraph | Multi-party events | Contract disputes |+| AutoTemporalGraph | Temporal relations | News timelines |+| AutoSpatialGraph | Spatial relations | Delivery routes || AutoSpatioTemporalGraph | Events in time & space | Historical battles |-### Comparison with Other Libraries--| Feature | KG-Gen | ATOM | Graphiti | LightRAG | Hyper-Extract |-|---------|--------|------|----------|----------|---------------|-| Knowledge Graph | ✅ | ✅ | ❌ | ✅ | ✅ |-| Temporal Graph | ❌ | ✅ | ✅ | ❌ | ✅ |-| Spatial Graph | ❌ | ❌ | ❌ | ❌ | ✅ |-| Hypergraph | ❌ | ❌ | ❌ | ❌ | ✅ |-| Templates | ❌ | ❌ | ❌ | ❌ | ✅ |-| CLI Tool | ❌ | ❌ | ❌ | ❌ | ✅ |+> 🔗 See [Full Type Documentation](./hyperextract/types/) | [Template Design Guide](./hyperextract/templates/DESIGN_GUIDE.md)---@@ -89,10 +59,8 @@ he search ka "key insights"-Pre-built templates for common domains:--| Domain | Templates | Scenarios |-|--------|-----------|-----------|+| Domain | Templates | Typical Scenarios |+|--------|-----------|-------------------|| General | 13 | Workflow, Biography, Concept maps || Finance | 5 | Earnings reports, Risk factors || Medicine | 5 | Clinical records, Drug interactions |@@ -100,48 +68,81 @@ Pre-built templates for common domains:| Industry | 5 | Equipment topology, Failure analysis || Legal | 5 | Contract clauses, Case citations |-**Total: 6 Domains · 37 Templates**--See [Template Gallery](hyperextract/templates/) for all templates.+> 🔗 See [Full Template Gallery](./hyperextract/templates/) | [Template Design Guide](./hyperextract/templates/DESIGN_GUIDE.md)----## 💻 CLI Reference+## 🎯 Python API Examples-### Parse Command+```python+from hyperextract import Template-```bash-he parse document.md -o my_ka -l zh-he parse document.md -o my_ka -t general/knowledge_graph -l zh+ka = Template.create("finance/earnings_summary")+result = ka.parse(financial_report_text)+# result.operating_revenue = "100 billion RMB"```-### Build Search Index+> 🔗 See more [Example Code](./examples/)++---++## 📈 Comparison with Other Libraries++| Feature | GraphRAG | LightRAG | KG-Gen | ATOM | **Hyper-Extract** |+|---------|:---:|:---:|:---:|:---:|:---:|+| Knowledge Graph | ✅ | ✅ | ✅ | ✅ | ✅ |+| Temporal Graph | ✅ | ❌ | ❌ | ✅ | ✅ |+| Spatial Graph | ❌ | ❌ | ❌ | ❌ | ✅ |+| Hypergraph | ❌ | ❌ | ❌ | ❌ | ✅ |+| Domain Templates | ❌ | ❌ | ❌ | ❌ | ✅ |+| CLI Tool | ❌ | ❌ | ❌ | ❌ | ✅ |+| Multi-language | Partial | ❌ | ❌ | ❌ | ✅ |+| Visualization | Partial | ❌ | ❌ | ❌ | ✅ |++---++## 💻 CLI Reference++### Parse Documents```bash-he build-index my_ka+he parse document.md -o ./knowledge_abstract/ -l zh+he parse earnings.md -o ./finance_report/ -t finance/earnings_summary -l zh```-### Search Knowledge Abstract+### Search & Chat```bash-he search my_ka "What are the key findings?"-he search my_ka "key insights" -n 5+he search ./finance_report/ "What was the revenue growth?"+he talk ./finance_report/ -i # Interactive mode```### Visualize```bash-he show my_ka-he info my_ka+he show ./finance_report/ # Graph visualization+he info ./finance_report/ # Show statistics```-For full CLI documentation, see [CLI Guide](hyperextract/cli/README.md).+> 🔗 For full CLI documentation, see [CLI Guide](./hyperextract/cli/README.md)++---++## 🤝 Contributing++Contributions are welcome! Please submit Issues and PRs.++## 📄 License++Apache-2.0----## 📚 Documentation+## 📚 Related Documentation-- [📖 Full Documentation](docs/)-- [💻 Examples](examples/)-- [🏷️ Template Gallery](hyperextract/templates/)-- [🖥️ CLI Guide](hyperextract/cli/README.md)+| Documentation | Description |+|---------------|-------------|+| [CLI Guide](./hyperextract/cli/README.md) | Complete CLI reference |+| [Template Gallery](./hyperextract/templates/) | 38+ domain templates |+| [Example Code](./examples/) | Python API examples |+| [Full Documentation](./docs/) | Architecture & implementation |diff --git a/README_ZH.md b/README_ZH.mdindex 20ded1b..f4cd1ee 100644--- a/README_ZH.md+++ b/README_ZH.md@@ -1,14 +1,14 @@# 🔍 Hyper-Extract> **"Stop reading. Start understanding."**->+> *"告别文档焦虑,让信息一目了然"*将文档转化为**知识摘要** —— 一行命令即可。-[📖 English Version](./README.md) · [中文版](#)+[📖 English Version](./README.md) · [中文版](./README_ZH.md)---@@ -17,71 +17,41 @@```bashpip install hyper-extract-he config init-he parse document.md -o ka -l zh-he talk ka -i-```---------## ⚙️ 快速配置--**推荐配置**:gpt-4o-mini(快速稳定,适合结构化提取)+ text-embedding-3-small--```bashhe config init -k YOUR_API_KEY-# 或指定自定义接口-he config init -k YOUR_KEY -u https://api.openai.com/v1++he parse document.md -o ./knowledge_abstract/ -l zh```-查看配置:`he config show`+> 🔗 详细使用说明请查看 [CLI 指南](./hyperextract/cli/README.md)----## 💡 使用示例+## ✨ 核心特性-```bash-he parse document.md -o ka -l zh-he show ka-he search ka "关键信息"-```+| 🤖 8种知识类型 | 🌍 38+领域模板 | 💻 交互式CLI | 🔍 语义检索 |+|:---:|:---:|:---:|:---:|+| 从列表到时空图谱 | 金融医疗法律开箱即用 | 一行命令完成全流程 | FAISS向量相似度 |----+> 🔗 了解 [8种知识类型](#知识类型) | [领域模板](#领域模板)-## 🧩 知识摘要类型--+----8 种知识结构,满足不同文档类型:+## 📊 知识类型-**记录型(Record Types):**-| 结构 | 适用场景 | 示例 |-|------|----------|------|-| AutoModel | 结构化报告 | 财务报表 |-| AutoList | 要点列表 | 会议记录 |-| AutoSet | 实体集合 | 产品目录 |+-**图型(Graph Types):**-| 结构 | 适用场景 | 示例 |+| 类型 | 适用场景 | 示例 ||------|----------|------|+| AutoModel | 结构化报告 | 财报摘要 |+| AutoList | 有序列表 | 会议要点 |+| AutoSet | 去重集合 | 产品目录 || AutoGraph | 二元关系 | 社交网络 |-| AutoHypergraph | 多方事件 | 法律纠纷 |-| AutoTemporalGraph | 事件序列 | 新闻时间线 |-| AutoSpatialGraph | 地理位置 | 配送路线 |+| AutoHypergraph | 多元事件 | 合同纠纷 |+| AutoTemporalGraph | 时序关系 | 新闻时间线 |+| AutoSpatialGraph | 空间关系 | 配送路线 || AutoSpatioTemporalGraph | 时空事件 | 历史战役 |-### 与其他库的对比--| 功能 | KG-Gen | ATOM | Graphiti | LightRAG | Hyper-Extract |-|------|--------|------|----------|----------|---------------|-| 知识图谱 | ✅ | ✅ | ❌ | ✅ | ✅ |-| 时序图谱 | ❌ | ✅ | ✅ | ❌ | ✅ |-| 空间图谱 | ❌ | ❌ | ❌ | ❌ | ✅ |-| 超图 | ❌ | ❌ | ❌ | ❌ | ✅ |-| 模板 | ❌ | ❌ | ❌ | ❌ | ✅ |-| CLI 工具 | ❌ | ❌ | ❌ | ❌ | ✅ |+> 🔗 查看 [完整类型文档](./hyperextract/types/) | [模板设计指南](./hyperextract/templates/DESIGN_GUIDE.md)---@@ -89,8 +59,6 @@ he search ka "关键信息"-开箱即用的领域模板:-| 领域 | 模板数 | 典型场景 ||------|--------|----------|| General | 13 | 工作流、传记、概念图 |@@ -100,9 +68,36 @@ he search ka "关键信息"| Industry | 5 | 设备拓扑、事故分析 || Legal | 5 | 合同条款、判例引用 |-**总计:6 大领域 · 37 个模板**+> 🔗 查看 [完整模板库](./hyperextract/templates/) | [模板设计指南](./hyperextract/templates/DESIGN_GUIDE.md)-查看 [模板库](hyperextract/templates/) 获取所有模板。+---++## 🎯 Python API 示例++```python+from hyperextract import Template++ka = Template.create("finance/earnings_summary")+result = ka.parse(financial_report_text)+# result.operating_revenue = "1000亿元"+```++> 🔗 查看更多 [示例代码](./examples/)++---++## 📈 与同类项目对比++| 特性 | GraphRAG | LightRAG | KG-Gen | ATOM | **Hyper-Extract** |+|------|:---:|:---:|:---:|:---:|:---:|+| 知识图谱 | ✅ | ✅ | ✅ | ✅ | ✅ |+| 时序图谱 | ✅ | ❌ | ❌ | ✅ | ✅ |+| 空间图谱 | ❌ | ❌ | ❌ | ❌ | ✅ |+| 超图 | ❌ | ❌ | ❌ | ❌ | ✅ |+| 领域模板 | ❌ | ❌ | ❌ | ❌ | ✅ |+| CLI工具 | ❌ | ❌ | ❌ | ❌ | ✅ |+| 多语言 | 部分 | ❌ | ❌ | ❌ | ✅ |+| 可视化 | 部分 | ❌ | ❌ | ❌ | ✅ |---@@ -111,37 +106,43 @@ he search ka "关键信息"### 解析文档```bash-he parse document.md -o my_ka -l zh-he parse document.md -o my_ka -t general/knowledge_graph -l zh+he parse document.md -o ./knowledge_abstract/ -l zh+he parse earnings.md -o ./finance_report/ -t finance/earnings_summary -l zh```-### 构建搜索索引+### 搜索与问答```bash-he build-index my_ka+he search ./finance_report/ "营收增长了多少?"+he talk ./finance_report/ -i # 交互式问答```-### 搜索知识摘要+### 可视化```bash-he search my_ka "关键发现是什么?"-he search my_ka "关键信息" -n 5+he show ./finance_report/ # 图形化展示+he info ./finance_report/ # 显示统计信息```-### 可视化+> 🔗 完整的 CLI 文档请查看 [CLI 指南](./hyperextract/cli/README.md)-```bash-he show my_ka-he info my_ka-```+---++## 🤝 贡献++欢迎提交 Issue 和 PR!++## 📄 许可证-完整的 CLI 文档请查看 [CLI 指南](hyperextract/cli/README.md)。+Apache-2.0----## 📚 文档+## 📚 相关文档-- [📖 完整文档](docs/)-- [💻 示例代码](examples/)-- [🏷️ 模板库](hyperextract/templates/)-- [🖥️ CLI 指南](hyperextract/cli/README.md)+| 文档 | 说明 |+|------|------|+| [CLI 指南](./hyperextract/cli/README.md) | 命令行工具完整参考 |+| [模板库](./hyperextract/templates/) | 38+ 领域模板 |+| [示例代码](./examples/) | Python API 使用示例 |+| [完整文档](./docs/) | 架构设计与实现细节 |diff --git a/examples/templates/README.md b/examples/templates/README.mdindex c425251..7b0ef46 100644--- a/examples/templates/README.md+++ b/examples/templates/README.md@@ -1,14 +1,18 @@# Templates 目录-本目录包含 Hyper-Extract 预设模板的测试工具。+本目录包含 Hyper-Extract 各领域预设模板的测试工具。## 文件说明| 文件 | 说明 ||------|------|-| `templates_mapping.yaml` | 模板与测试数据的映射配置 || `list_templates.py` | 列出所有可用的预设模板 |-| `run_template.py` | 执行指定模板的测试 |+| `finance_template.py` | 金融领域模板测试 |+| `general_template.py` | 通用领域模板测试 |+| `industry_template.py` | 工业领域模板测试 |+| `legal_template.py` | 法律领域模板测试 |+| `medicine_template.py` | 医学领域模板测试 |+| `tcm_template.py` | 中医领域模板测试 |## 使用方法@@ -18,59 +22,127 @@python examples/templates/list_templates.py```-输出示例:-```-【FINANCE 领域】 (5 templates)- • earnings_summary- Type: model- Description: 财报电话会议摘要- Template: finance/earnings_summary.yaml- Test Data: tests/test_data/zh/finance/earnings_call_transcript_sample.md-```+### 运行领域模板测试-### 运行模板测试+每个领域对应一个独立的测试文件,直接运行即可:```bash-python examples/templates/run_template.py -d <domain> -t <template>-```+# 金融领域+python examples/templates/finance_template.py-参数说明:-- `-d, --domain`: 领域名称 (finance, general, industry, legal, medicine, tcm)-- `-t, --template`: 模板名称+# 通用领域+python examples/templates/general_template.py-示例:-```bash-python examples/templates/run_template.py -d finance -t earnings_summary-python examples/templates/run_template.py -d general -t base_graph-python examples/templates/run_template.py -d tcm -t formula_composition+# 工业领域+python examples/templates/industry_template.py++# 法律领域+python examples/templates/legal_template.py++# 医学领域+python examples/templates/medicine_template.py++# 中医领域+python examples/templates/tcm_template.py```-### 文件内配置+### 切换测试用例++每个模板文件包含多个测试用例,通过注释的方式切换:-编辑 `run_template.py` 顶部的 `CONFIG` 字典设置默认的 domain 和 template:+1. 打开对应的模板文件+2. 找到"测试用例"部分+3. 取消注释要测试的用例,注释其他用例+4. 修改 `main()` 函数中的 `text` 和 `template_name````python-CONFIG = {- "domain": "general",- "template": "base_graph",-}-```+# // test for 财报电话会议摘要+# text = """星河智能科技股份有限公司..."""+# template_name = "finance/earnings_summary"-然后直接运行:-```bash-python examples/templates/run_template.py+# // test for 股权结构图(取消注释此行)+text = """IPO招股说明书"""+template_name = "finance/ownership_graph"```## 支持的领域-| 领域 | 模板数量 | 描述 |-|------|---------|------|-| finance | 5 | 金融领域:财报摘要、股权结构、风险因子等 |-| general | 11 | 通用领域:基础图谱、传记、工作流程等 |-| industry | 5 | 工业领域:设备拓扑、应急响应、故障分析等 |-| legal | 5 | 法律领域:案例引用、合规清单、合同义务等 |-| medicine | 5 | 医学领域:解剖图谱、药物相互作用、治疗方案等 |-| tcm | 5 | 中医领域:方剂组成、经络图、证候推理等 |+| 领域 | 文件 | 模板数量 | 描述 |+|------|------|---------|------|+| finance | finance_template.py | 5 | 金融领域:财报摘要、股权结构、风险因子等 |+| general | general_template.py | 11 | 通用领域:基础图谱、传记、概念图等 |+| industry | industry_template.py | 5 | 工业领域:设备拓扑、应急响应、故障分析等 |+| legal | legal_template.py | 5 | 法律领域:案例引用、合规清单、合同义务等 |+| medicine | medicine_template.py | 5 | 医学领域:解剖图谱、药物相互作用、治疗方案等 |+| tcm | tcm_template.py | 5 | 中医领域:方剂组成、经络图、证候推理等 |++## 各领域模板列表++### Finance (金融)++| 模板名称 | 类型 | 说明 |+|---------|------|------|+| earnings_summary | model | 财报电话会议摘要 |+| event_timeline | temporal_graph | 重大事件时间线 |+| ownership_graph | graph | 股权结构图 |+| risk_factor_set | set | 风险因子集合 |+| sentiment_model | model | 市场情绪模型 |++### General (通用)++| 模板名称 | 类型 | 说明 |+|---------|------|------|+| base_graph | graph | 基础知识图谱 |+| base_hypergraph | hypergraph | 基础超图 |+| base_list | list | 基础列表 |+| biography_graph | graph | 传记图谱 |+| concept_graph | graph | 概念图谱 |+| doc_structure | list | 文档结构 |+| workflow_graph | graph | 工作流程图 |+| base_model | model | 基础模型 |+| base_set | set | 基础集合 |+| base_temporal_graph | temporal_graph | 基础时序图 |+| base_spatial_graph | spatial_graph | 基础空间图 |++### Industry (工业)++| 模板名称 | 类型 | 说明 |+|---------|------|------|+| equipment_topology | graph | 设备拓扑图 |+| operation_flow | list | 操作流程 |+| safety_control | set | 安全控制 |+| emergency_response | temporal_graph | 应急响应时间线 |+| failure_case | hypergraph | 故障案例 |++### Legal (法律)++| 模板名称 | 类型 | 说明 |+|---------|------|------|+| case_citation | graph | 案例引用图 |+| case_fact_timeline | temporal_graph | 案件事实时间线 |+| compliance_list | list | 合规清单 |+| contract_obligation | set | 合同义务 |+| defined_term_set | set | 术语定义 |++### Medicine (医学)++| 模板名称 | 类型 | 说明 |+|---------|------|------|+| anatomy_graph | graph | 解剖结构图 |+| discharge_instruction | list | 出院指导 |+| drug_interaction | graph | 药物相互作用图 |+| hospital_timeline | temporal_graph | 医院事件时间线 |+| treatment_map | hypergraph | 治疗方案图 |++### TCM (中医)++| 模板名称 | 类型 | 说明 |+|---------|------|------|+| formula_composition | graph | 方剂组成图 |+| herb_property | model | 药材属性 |+| herb_relation | graph | 药材关系图 |+| meridian_graph | graph | 经络图 |+| syndrome_reasoning | hypergraph | 证候推理 |## 模板类型diff --git a/examples/templates/finance_template.py b/examples/templates/finance_template.pynew file mode 100644index 0000000..d567401--- /dev/null+++ b/examples/templates/finance_template.py@@ -0,0 +1,75 @@+"""+金融领域模板示例++Usage:+ python examples/templates/finance_template.py+"""++import sys+from pathlib import Path++project_root = Path(__file__).resolve().parent.parent.parent+sys.path.append(str(project_root))++from langchain_openai import ChatOpenAI, OpenAIEmbeddings+from hyperextract import Template++import dotenv++dotenv.load_dotenv()++# ==================== 测试用例(取消注释选择要测试的用例) ====================++# // test for 重大事件时间线+test_data_file = "annual_report_sample.md"+template_name = "finance/event_timeline"++# // test for 股权结构图+# test_data_file = "ipo_prospectus_sample.md"+# template_name = "finance/ownership_graph"++# // test for 风险因子集合+# test_data_file = "annual_report_sample.md"+# template_name = "finance/risk_factor_set"++# // test for 市场情绪模型+# test_data_file = "financial_news_sample.md"+# template_name = "finance/sentiment_model"++# // test for 财报电话会议摘要+# test_data_file = "earnings_call_transcript_sample.md"+# template_name = "finance/earnings_summary"++# ==================== 主函数 ====================++def main():+ test_data_dir = project_root / "tests" / "test_data" / "zh" / "finance"+ input_file = test_data_dir / test_data_file++ with open(input_file, "r", encoding="utf-8") as f:+ text = f.read()++ print("=" * 80)+ print(f"🧪 测试模板: {template_name}")+ print(f"📂 测试数据: {input_file}")+ print("=" * 80)++ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)+ embedder = OpenAIEmbeddings()++ extractor = Template.create(+ template_name,+ language="zh",+ llm_client=llm,+ embedder=embedder,+ )++ print("\n📥 正在提取知识摘要...")+ extractor.feed_text(text)+ print("✅ 提取完成!\n")++ extractor.show()+++if __name__ == "__main__":+ main()diff --git a/examples/templates/general_template.py b/examples/templates/general_template.pynew file mode 100644index 0000000..36c2d44--- /dev/null+++ b/examples/templates/general_template.py@@ -0,0 +1,75 @@+"""+通用领域模板示例++Usage:+ python examples/templates/general_template.py+"""++import sys+from pathlib import Path++project_root = Path(__file__).resolve().parent.parent.parent+sys.path.append(str(project_root))++from langchain_openai import ChatOpenAI, OpenAIEmbeddings+from hyperextract import Template++import dotenv++dotenv.load_dotenv()++# ==================== 测试用例(取消注释选择要测试的用例) ====================++# // test for 基础知识图谱+test_data_file = "arbitrary_tech_news.md"+template_name = "general/base_graph"++# // test for 基础超图+# test_data_file = "encyclopedia_machine_learning.md"+# template_name = "general/base_hypergraph"++# // test for 基础列表+# test_data_file = "regulation_company_policy.md"+# template_name = "general/base_list"++# // test for 传记图谱+# test_data_file = "biography_scientist.md"+# template_name = "general/biography_graph"++# // test for 概念图谱+# test_data_file = "encyclopedia_machine_learning.md"+# template_name = "general/concept_graph"++# ==================== 主函数 ====================++def main():+ test_data_dir = project_root / "tests" / "test_data" / "zh" / "general"+ input_file = test_data_dir / test_data_file++ with open(input_file, "r", encoding="utf-8") as f:+ text = f.read()++ print("=" * 80)+ print(f"🧪 测试模板: {template_name}")+ print(f"📂 测试数据: {input_file}")+ print("=" * 80)++ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)+ embedder = OpenAIEmbeddings()++ extractor = Template.create(+ template_name,+ language="zh",+ llm_client=llm,+ embedder=embedder,+ )++ print("\n📥 正在提取知识摘要...")+ extractor.feed_text(text)+ print("✅ 提取完成!\n")++ extractor.show()+++if __name__ == "__main__":+ main()diff --git a/examples/templates/industry_template.py b/examples/templates/industry_template.pynew file mode 100644index 0000000..e545e54--- /dev/null+++ b/examples/templates/industry_template.py@@ -0,0 +1,75 @@+"""+工业领域模板示例++Usage:+ python examples/templates/industry_template.py+"""++import sys+from pathlib import Path++project_root = Path(__file__).resolve().parent.parent.parent+sys.path.append(str(project_root))++from langchain_openai import ChatOpenAI, OpenAIEmbeddings+from hyperextract import Template++import dotenv++dotenv.load_dotenv()++# ==================== 测试用例(取消注释选择要测试的用例) ====================++# // test for 设备拓扑图+test_data_file = "equipment_technical_manual.md"+template_name = "industry/equipment_topology"++# // test for 操作流程+# test_data_file = "operation_maintenance_manual.md"+# template_name = "industry/operation_flow"++# // test for 安全控制+# test_data_file = "safety_management_handbook.md"+# template_name = "industry/safety_control"++# // test for 应急响应时间线+# test_data_file = "safety_management_handbook.md"+# template_name = "industry/emergency_response"++# // test for 故障案例+# test_data_file = "failure_analysis_report.md"+# template_name = "industry/failure_case"++# ==================== 主函数 ====================++def main():+ test_data_dir = project_root / "tests" / "test_data" / "zh" / "industry"+ input_file = test_data_dir / test_data_file++ with open(input_file, "r", encoding="utf-8") as f:+ text = f.read()++ print("=" * 80)+ print(f"🧪 测试模板: {template_name}")+ print(f"📂 测试数据: {input_file}")+ print("=" * 80)++ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)+ embedder = OpenAIEmbeddings()++ extractor = Template.create(+ template_name,+ language="zh",+ llm_client=llm,+ embedder=embedder,+ )++ print("\n📥 正在提取知识摘要...")+ extractor.feed_text(text)+ print("✅ 提取完成!\n")++ extractor.show()+++if __name__ == "__main__":+ main()diff --git a/examples/templates/legal_template.py b/examples/templates/legal_template.pynew file mode 100644index 0000000..f0b8df0--- /dev/null+++ b/examples/templates/legal_template.py@@ -0,0 +1,75 @@+"""+法律领域模板示例++Usage:+ python examples/templates/legal_template.py+"""++import sys+from pathlib import Path++project_root = Path(__file__).resolve().parent.parent.parent+sys.path.append(str(project_root))++from langchain_openai import ChatOpenAI, OpenAIEmbeddings+from hyperextract import Template++import dotenv++dotenv.load_dotenv()++# ==================== 测试用例(取消注释选择要测试的用例) ====================++# // test for 案例引用图+# test_data_file = "legal_treatise_sample.md"+# template_name = "legal/case_citation"++# // test for 案件事实时间线+# test_data_file = "court_judgment_sample.md"+# template_name = "legal/case_fact_timeline"++# // test for 合规清单+# test_data_file = "compliance_filing_sample.md"+# template_name = "legal/compliance_list"++# // test for 合同义务+test_data_file = "msa_contract_sample.md"+template_name = "legal/contract_obligation"++# // test for 术语定义+# test_data_file = "msa_contract_sample.md"+# template_name = "legal/defined_term_set"++# ==================== 主函数 ====================++def main():+ test_data_dir = project_root / "tests" / "test_data" / "zh" / "legal"+ input_file = test_data_dir / test_data_file++ with open(input_file, "r", encoding="utf-8") as f:+ text = f.read()++ print("=" * 80)+ print(f"🧪 测试模板: {template_name}")+ print(f"📂 测试数据: {input_file}")+ print("=" * 80)++ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)+ embedder = OpenAIEmbeddings()++ extractor = Template.create(+ template_name,+ language="zh",+ llm_client=llm,+ embedder=embedder,+ )++ print("\n📥 正在提取知识摘要...")+ extractor.feed_text(text)+ print("✅ 提取完成!\n")++ extractor.show()+++if __name__ == "__main__":+ main()diff --git a/examples/templates/medicine_template.py b/examples/templates/medicine_template.pynew file mode 100644index 0000000..9e18183--- /dev/null+++ b/examples/templates/medicine_template.py@@ -0,0 +1,75 @@+"""+医学领域模板示例++Usage:+ python examples/templates/medicine_template.py+"""++import sys+from pathlib import Path++project_root = Path(__file__).resolve().parent.parent.parent+sys.path.append(str(project_root))++from langchain_openai import ChatOpenAI, OpenAIEmbeddings+from hyperextract import Template++import dotenv++dotenv.load_dotenv()++# ==================== 测试用例(取消注释选择要测试的用例) ====================++# // test for 解剖结构图+# test_data_file = "textbook_sample.md"+# template_name = "medicine/anatomy_graph"++# // test for 出院指导+test_data_file = "discharge_summary_sample.md"+template_name = "medicine/discharge_instruction"++# // test for 药物相互作用图+# test_data_file = "package_insert_sample.md"+# template_name = "medicine/drug_interaction"++# // test for 医院事件时间线+# test_data_file = "pathology_report_sample.md"+# template_name = "medicine/hospital_timeline"++# // test for 治疗方案图+# test_data_file = "clinical_guideline_sample.md"+# template_name = "medicine/treatment_map"++# ==================== 主函数 ====================++def main():+ test_data_dir = project_root / "tests" / "test_data" / "zh" / "medicine"+ input_file = test_data_dir / test_data_file++ with open(input_file, "r", encoding="utf-8") as f:+ text = f.read()++ print("=" * 80)+ print(f"🧪 测试模板: {template_name}")+ print(f"📂 测试数据: {input_file}")+ print("=" * 80)++ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)+ embedder = OpenAIEmbeddings()++ extractor = Template.create(+ template_name,+ language="zh",+ llm_client=llm,+ embedder=embedder,+ )++ print("\n📥 正在提取知识摘要...")+ extractor.feed_text(text)+ print("✅ 提取完成!\n")++ extractor.show()+++if __name__ == "__main__":+ main()diff --git a/examples/templates/run_template.py b/examples/templates/run_template.pydeleted file mode 100644index 477b534..0000000--- a/examples/templates/run_template.py+++ /dev/null@@ -1,130 +0,0 @@-"""-Run Template - 执行预设模板测试--Usage:- python examples/templates/run_template.py -d <domain> -t <template_name>-- or edit CONFIG below to set default domain and template--Examples:- python examples/templates/run_template.py -d finance -t earnings_summary- python examples/templates/run_template.py -d general -t base_graph- python examples/templates/run_template.py -d tcm -t formula_composition-"""--import argparse-import sys-import yaml-from pathlib import Path--project_root = Path(__file__).resolve().parent.parent.parent-sys.path.append(str(project_root))--CONFIG = {- "domain": "general",- "template": "base_graph",-}---def load_mappings():- mapping_file = Path(__file__).parent / "templates_mapping.yaml"- with open(mapping_file, "r", encoding="utf-8") as f:- return yaml.safe_load(f)---def run_template(domain: str, template_name: str):- mappings = load_mappings()-- if domain not in mappings:- print(f"Error: Domain '{domain}' not found.")- print(f"Available domains: {', '.join(mappings.keys())}")- return False-- domain_mappings = mappings[domain]-- if template_name not in domain_mappings:- print(f"Error: Template '{template_name}' not found in domain '{domain}'.")- print("Available templates:")- for name in domain_mappings.keys():- print(f" - {name}")- return False-- template_info = domain_mappings[template_name]- template_path = project_root / "hyperextract" / "templates" / "presets" / f"{template_info['template']}.yaml"- input_path = project_root / "tests" / "test_data" / "zh" / template_info["input"]-- print("\n" + "=" * 80)- print(f"🧪 Template Test: {domain}/{template_name}")- print("=" * 80)-- print(f"\n📄 Template: {template_path}")- print(f"📥 Input: {input_path}")-- if not template_path.exists():- print(f"\n❌ Error: Template file not found: {template_path}")- return False-- if not input_path.exists():- print(f"\n❌ Error: Input file not found: {input_path}")- return False-- with open(template_path, "r", encoding="utf-8") as f:- template_content = f.read()-- with open(input_path, "r", encoding="utf-8") as f:- input_content = f.read()-- print("\n" + "-" * 80)- print("📋 Template Content:")- print("-" * 80)- print(template_content[:500] + "..." if len(template_content) > 500 else template_content)-- print("\n" + "-" * 80)- print(f"📖 Input Content ({len(input_content)} chars):")- print("-" * 80)- print(input_content[:500] + "..." if len(input_content) > 500 else input_content)-- print("\n" + "-" * 80)- print("⚙️ Running extraction...")- print("-" * 80)-- print("\n✅ Template and input loaded successfully!")- print("\n To implement full extraction, integrate with:")- print(" - AutoGraph for graph extraction")- print(" - AutoHypergraph for hypergraph extraction")- print(" - AutoList for list extraction")- print(" - AutoModel for model extraction")- print(" - AutoSet for set extraction")- print(" - AutoTemporalGraph for temporal graph extraction")- print(" - AutoSpatialGraph for spatial graph extraction")- print(" - AutoSpatioTemporalGraph for spatio-temporal graph extraction")-- print("\n" + "=" * 80 + "\n")-- return True---def main():- parser = argparse.ArgumentParser(description="Run Hyper-Extract preset template test")- parser.add_argument("-d", "--domain", help="Domain name (e.g., finance, general, tcm)")- parser.add_argument("-t", "--template", help="Template name (e.g., earnings_summary, base_graph)")-- args = parser.parse_args()-- domain = args.domain if args.domain else CONFIG["domain"]- template = args.template if args.template else CONFIG["template"]-- if not args.domain and not args.template:- print("\n📝 Using default config from file:")- print(f" Domain: {domain}")- print(f" Template: {template}")- print(" (Use -d and -t to override)\n")-- success = run_template(domain, template)-- if not success:- sys.exit(1)---if __name__ == "__main__":- main()diff --git a/examples/templates/tcm_template.py b/examples/templates/tcm_template.pynew file mode 100644index 0000000..ab3e0ff--- /dev/null+++ b/examples/templates/tcm_template.py@@ -0,0 +1,75 @@+"""+中医领域模板示例++Usage:+ python examples/templates/tcm_template.py+"""++import sys+from pathlib import Path++project_root = Path(__file__).resolve().parent.parent.parent+sys.path.append(str(project_root))++from langchain_openai import ChatOpenAI, OpenAIEmbeddings+from hyperextract import Template++import dotenv++dotenv.load_dotenv()++# ==================== 测试用例(取消注释选择要测试的用例) ====================++# // test for 方剂组成图+# test_data_file = "prescription_formulary_sample.md"+# template_name = "tcm/formula_composition"++# // test for 药材属性+# test_data_file = "herb_property_single.md"+# template_name = "tcm/herb_property"++# // test for 药材关系图+# test_data_file = "herbal_compendium_sample.md"+# template_name = "tcm/herb_relation"++# // test for 经络图+# test_data_file = "meridian_treatise_sample.md"+# template_name = "tcm/meridian_graph"++# // test for 证候推理+test_data_file = "medical_case_record_sample.md"+template_name = "tcm/syndrome_reasoning"++# ==================== 主函数 ====================++def main():+ test_data_dir = project_root / "tests" / "test_data" / "zh" / "tcm"+ input_file = test_data_dir / test_data_file++ with open(input_file, "r", encoding="utf-8") as f:+ text = f.read()++ print("=" * 80)+ print(f"🧪 测试模板: {template_name}")+ print(f"📂 测试数据: {input_file}")+ print("=" * 80)++ llm = ChatOpenAI(model="gpt-4o-mini", temperature=0)+ embedder = OpenAIEmbeddings()++ extractor = Template.create(+ template_name,+ language="zh",+ llm_client=llm,+ embedder=embedder,+ )++ print("\n📥 正在提取知识摘要...")+ extractor.feed_text(text)+ print("✅ 提取完成!\n")++ extractor.show()+++if __name__ == "__main__":+ main()diff --git a/examples/templates/templates_mapping.yaml b/examples/templates/templates_mapping.yamldeleted file mode 100644index 3ff1079..0000000--- a/examples/templates/templates_mapping.yaml+++ /dev/null@@ -1,243 +0,0 @@-# Hyper-Extract Examples: Templates Mapping-# 模板与测试数据映射表-# 格式: 模板路径 -> 测试数据路径--# 测试数据根目录-test_data_root: "tests/test_data/zh"--# 模板根目录-template_root: "hyperextract/templates/presets"--# Finance 领域 (5个模板)-finance:- earnings_summary:- template: "finance/earnings_summary"- input: "finance/earnings_call_transcript_sample.md"- type: "model"- description: "财报电话会议摘要"-- event_timeline:- template: "finance/event_timeline"- input: "finance/annual_report_sample.md"- type: "temporal_graph"- description: "重大事件时间线"-- ownership_graph:- template: "finance/ownership_graph"- input: "finance/ipo_prospectus_sample.md"- type: "graph"- description: "股权结构图"-- risk_factor_set:- template: "finance/risk_factor_set"- input: "finance/annual_report_sample.md"- type: "set"- description: "风险因子集合"-- sentiment_model:- template: "finance/sentiment_model"- input: "finance/financial_news_sample.md"- type: "model"- description: "市场情绪模型"--# General 领域 (11个模板)-general:- base_graph:- template: "general/base_graph"- input: "general/arbitrary_tech_news.md"- type: "graph"- description: "基础知识图谱"-- base_hypergraph:- template: "general/base_hypergraph"- input: "general/encyclopedia_machine_learning.md"- type: "hypergraph"- description: "基础超图"-- base_list:- template: "general/base_list"- input: "general/regulation_company_policy.md"- type: "list"- description: "基础列表"-- base_model:- template: "general/base_model"- input: "general/arbitrary_tech_news.md"- type: "model"- description: "基础模型"-- base_set:- template: "general/base_set"- input: "general/arbitrary_tech_news.md"- type: "set"- description: "基础集合"-- base_temporal_graph:- template: "general/base_temporal_graph"- input: "general/biography_scientist.md"- type: "temporal_graph"- description: "基础时序图"-- base_spatial_graph:- template: "general/base_spatial_graph"- input: "general/spatio_temporal_event_report.md"- type: "spatial_graph"- description: "基础空间图"-- base_spatio_temporal_graph:- template: "general/base_spatio_temporal_graph"- input: "general/spatio_temporal_event_report.md"- type: "spatio_temporal_graph"- description: "基础时空图"-- biography_graph:- template: "general/biography_graph"- input: "general/biography_scientist.md"- type: "graph"- description: "传记图谱"-- concept_graph:- template: "general/concept_graph"- input: "general/encyclopedia_machine_learning.md"- type: "graph"- description: "概念图谱"-- doc_structure:- template: "general/doc_structure"- input: "general/regulation_company_policy.md"- type: "list"- description: "文档结构"-- workflow_graph:- template: "general/workflow_graph"- input: "general/social_network_entrepreneur_story.md"- type: "graph"- description: "工作流程图"--# Industry 领域 (5个模板)-industry:- emergency_response:- template: "industry/emergency_response"- input: "industry/safety_management_handbook.md"- type: "temporal_graph"- description: "应急响应时间线"-- equipment_topology:- template: "industry/equipment_topology"- input: "industry/equipment_technical_manual.md"- type: "graph"- description: "设备拓扑图"-- failure_case:- template: "industry/failure_case"- input: "industry/failure_analysis_report.md"- type: "hypergraph"- description: "故障案例"-- operation_flow:- template: "industry/operation_flow"- input: "industry/operation_maintenance_manual.md"- type: "list"- description: "操作流程"-- safety_control:- template: "industry/safety_control"- input: "industry/safety_management_handbook.md"- type: "set"- description: "安全控制"--# Legal 领域 (5个模板)-legal:- case_citation:- template: "legal/case_citation"- input: "legal/legal_treatise_sample.md"- type: "graph"- description: "案例引用图"-- case_fact_timeline:- template: "legal/case_fact_timeline"- input: "legal/court_judgment_sample.md"- type: "temporal_graph"- description: "案件事实时间线"-- compliance_list:- template: "legal/compliance_list"- input: "legal/compliance_filing_sample.md"- type: "list"- description: "合规清单"-- contract_obligation:- template: "legal/contract_obligation"- input: "legal/msa_contract_sample.md"- type: "set"- description: "合同义务"-- defined_term_set:- template: "legal/defined_term_set"- input: "legal/msa_contract_sample.md"- type: "set"- description: "术语定义"--# Medicine 领域 (5个模板)-medicine:- anatomy_graph:- template: "medicine/anatomy_graph"- input: "medicine/textbook_sample.md"- type: "graph"- description: "解剖结构图"-- discharge_instruction:- template: "medicine/discharge_instruction"- input: "medicine/discharge_summary_sample.md"- type: "list"- description: "出院指导"-- drug_interaction:- template: "medicine/drug_interaction"- input: "medicine/package_insert_sample.md"- type: "graph"- description: "药物相互作用图"-- hospital_timeline:- template: "medicine/hospital_timeline"- input: "medicine/pathology_report_sample.md"- type: "temporal_graph"- description: "医院事件时间线"-- treatment_map:- template: "medicine/treatment_map"- input: "medicine/clinical_guideline_sample.md"- type: "hypergraph"- description: "治疗方案图"--# TCM 领域 (5个模板)-tcm:- formula_composition:- template: "tcm/formula_composition"- input: "tcm/prescription_formulary_sample.md"- type: "graph"- description: "方剂组成图"-- herb_property:- template: "tcm/herb_property"- input: "tcm/herb_property_single.md"- type: "model"- description: "药材属性"-- herb_relation:- template: "tcm/herb_relation"- input: "tcm/herbal_compendium_sample.md"- type: "graph"- description: "药材关系图"-- meridian_graph:- template: "tcm/meridian_graph"- input: "tcm/meridian_treatise_sample.md"- type: "graph"- description: "经络图"-- syndrome_reasoning:- template: "tcm/syndrome_reasoning"- input: "tcm/medical_case_record_sample.md"- type: "hypergraph"- description: "证候推理"diff --git a/hyperextract/templates/presets/finance/event_timeline.yaml b/hyperextract/templates/presets/finance/event_timeline.yamlindex 4ec0336..a0d2315 100644--- a/hyperextract/templates/presets/finance/event_timeline.yaml+++ b/hyperextract/templates/presets/finance/event_timeline.yaml@@ -49,7 +49,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:precedes/causes/triggers'+ zh: '关系类型:先于/导致/触发'en: 'Relation type: precedes/causes/triggers'required: true- name: time@@ -80,9 +80,9 @@ guideline:- 'Event type should reflect the nature of the event (announcement/rating adjustment/earnings release, etc.)'rules_for_relations:zh:- - 'type为precedes表示事件的时间先后顺序'- - 'type为causes表示因果关联'- - 'type为triggers表示触发关系'+ - 'type为"先于"表示事件的时间先后顺序'+ - 'type为"导致"表示因果关联'+ - 'type为"触发"表示触发关系'- '仅提取文本中明确说明的关系'- 'description中应说明事件是否构成重大事项'en:diff --git a/hyperextract/templates/presets/finance/ownership_graph.yaml b/hyperextract/templates/presets/finance/ownership_graph.yamlindex 82514d9..ef5645b 100644--- a/hyperextract/templates/presets/finance/ownership_graph.yaml+++ b/hyperextract/templates/presets/finance/ownership_graph.yaml@@ -55,7 +55,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:controls/belongs_to/holds_shares'+ zh: '关系类型:控制/属于/持股'en: 'Relation type: controls/belongs_to/holds_shares'required: true- name: ownership_percentagediff --git a/hyperextract/templates/presets/general/base_graph.yaml b/hyperextract/templates/presets/general/base_graph.yamlindex 2f3469b..da49c7e 100644--- a/hyperextract/templates/presets/general/base_graph.yaml+++ b/hyperextract/templates/presets/general/base_graph.yaml@@ -41,12 +41,12 @@ output:- name: sourcetype: strdescription:- zh: '关系起点实体,必须对应已提取实体的 name。'+ zh: '关系起点实体,必须对应已提取实体的名称。'en: 'Source entity of the relation, must correspond to the name of an extracted entity.'- name: targettype: strdescription:- zh: '关系终点实体,必须对应已提取实体的 name。'+ zh: '关系终点实体,必须对应已提取实体的名称。'en: 'Target entity of the relation, must correspond to the name of an extracted entity.'- name: typetype: strdiff --git a/hyperextract/templates/presets/general/base_spatial_graph.yaml b/hyperextract/templates/presets/general/base_spatial_graph.yamlindex eec008e..99534c8 100644--- a/hyperextract/templates/presets/general/base_spatial_graph.yaml+++ b/hyperextract/templates/presets/general/base_spatial_graph.yaml@@ -41,12 +41,12 @@ output:- name: sourcetype: strdescription:- zh: '关系起点实体,必须对应已提取实体的 name。'+ zh: '关系起点实体,必须对应已提取实体的名称。'en: 'Source entity of the relation, must correspond to the name of an extracted entity.'- name: targettype: strdescription:- zh: '关系终点实体,必须对应已提取实体的 name。'+ zh: '关系终点实体,必须对应已提取实体的名称。'en: 'Target entity of the relation, must correspond to the name of an extracted entity.'- name: typetype: strdiff --git a/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml b/hyperextract/templates/presets/general/base_spatio_temporal_graph.yamlindex 02a72b5..0f87f9d 100644--- a/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml+++ b/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml@@ -41,12 +41,12 @@ output:- name: sourcetype: strdescription:- zh: '关系起点实体,必须对应已提取实体的 name。'+ zh: '关系起点实体,必须对应已提取实体的名称。'en: 'Source entity of the relation, must correspond to the name of an extracted entity.'- name: targettype: strdescription:- zh: '关系终点实体,必须对应已提取实体的 name。'+ zh: '关系终点实体,必须对应已提取实体的名称。'en: 'Target entity of the relation, must correspond to the name of an extracted entity.'- name: typetype: strdiff --git a/hyperextract/templates/presets/general/base_temporal_graph.yaml b/hyperextract/templates/presets/general/base_temporal_graph.yamlindex fa8ad00..7e97825 100644--- a/hyperextract/templates/presets/general/base_temporal_graph.yaml+++ b/hyperextract/templates/presets/general/base_temporal_graph.yaml@@ -41,12 +41,12 @@ output:- name: sourcetype: strdescription:- zh: '关系起点实体,必须对应已提取实体的 name。'+ zh: '关系起点实体,必须对应已提取实体的名称。'en: 'Source entity of the relation, must correspond to the name of an extracted entity.'- name: targettype: strdescription:- zh: '关系终点实体,必须对应已提取实体的 name。'+ zh: '关系终点实体,必须对应已提取实体的名称。'en: 'Target entity of the relation, must correspond to the name of an extracted entity.'- name: typetype: strdiff --git a/hyperextract/templates/presets/industry/emergency_response.yaml b/hyperextract/templates/presets/industry/emergency_response.yamlindex 9a3a417..ea35599 100644--- a/hyperextract/templates/presets/industry/emergency_response.yaml+++ b/hyperextract/templates/presets/industry/emergency_response.yaml@@ -55,7 +55,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:triggers/executed_by/requires'+ zh: '关系类型:触发/执行/需要'en: 'Relation type: triggers/executed_by/requires'required: true- name: responsible_role@@ -80,9 +80,9 @@ guideline:- 'Extract required resources as entities'rules_for_relations:zh:- - 'type为triggers表示触发响应'- - 'type为executed_by表示执行责任人'- - 'type为requires表示所需资源'+ - 'type为"触发"表示触发响应'+ - 'type为"执行"表示执行责任人'+ - 'type为"需要"表示所需资源'en:- 'type triggers indicates triggering response'- 'type executed_by indicates executing responsible person'diff --git a/hyperextract/templates/presets/industry/equipment_topology.yaml b/hyperextract/templates/presets/industry/equipment_topology.yamlindex f618c1c..2c14d2f 100644--- a/hyperextract/templates/presets/industry/equipment_topology.yaml+++ b/hyperextract/templates/presets/industry/equipment_topology.yaml@@ -61,7 +61,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:connected_to/located_in/contains'+ zh: '关系类型:连接/位于/包含'en: 'Relation type: connected_to/located_in/contains'required: truediff --git a/hyperextract/templates/presets/industry/failure_case.yaml b/hyperextract/templates/presets/industry/failure_case.yamlindex 965919d..fb0d0f4 100644--- a/hyperextract/templates/presets/industry/failure_case.yaml+++ b/hyperextract/templates/presets/industry/failure_case.yaml@@ -80,9 +80,9 @@ guideline:- 'Extract corrective measures as entities'rules_for_relations:zh:- - 'type为caused_by表示由某原因引起'- - 'type为resolved_by表示通过某措施解决'- - 'type为prevented_by表示通过某措施预防'+ - 'type为"原因"表示由某原因引起'+ - 'type为"解决"表示通过某措施解决'+ - 'type为"预防"表示通过某措施预防'- 'lesson字段应总结经验教训'en:- 'type caused_by indicates caused by a reason'diff --git a/hyperextract/templates/presets/industry/operation_flow.yaml b/hyperextract/templates/presets/industry/operation_flow.yamlindex 5170e40..85a27ad 100644--- a/hyperextract/templates/presets/industry/operation_flow.yaml+++ b/hyperextract/templates/presets/industry/operation_flow.yaml@@ -61,7 +61,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:next/triggers/results_in'+ zh: '关系类型:后续/触发/导致'en: 'Relation type: next/triggers/results_in'required: true- name: description@@ -86,9 +86,9 @@ guideline:- 'Equipment states should indicate key state changes'rules_for_relations:zh:- - 'type为next表示顺序执行'- - 'type为triggers表示触发条件'- - 'type为results_in表示导致状态变化'+ - 'type为"顺序"表示顺序执行'+ - 'type为"触发"表示触发条件'+ - 'type为"导致"表示导致状态变化'- '仅提取文档中明确说明的关系'en:- 'type next indicates sequential execution'diff --git a/hyperextract/templates/presets/industry/safety_control.yaml b/hyperextract/templates/presets/industry/safety_control.yamlindex d29352a..b8cdc1a 100644--- a/hyperextract/templates/presets/industry/safety_control.yaml+++ b/hyperextract/templates/presets/industry/safety_control.yaml@@ -55,7 +55,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:causes/mitigates/assigned_to'+ zh: '关系类型:导致/缓解/分配给'en: 'Relation type: causes/mitigates/assigned_to'required: true- name: responsible_role@@ -80,9 +80,9 @@ guideline:- 'Extract control measures as entities'rules_for_relations:zh:- - 'type为causes表示导致风险'- - 'type为mitigates表示减轻风险'- - 'type为assigned_to表示责任分配'+ - 'type为"导致"表示导致风险'+ - 'type为"减轻"表示减轻风险'+ - 'type为"分配"表示责任分配'- 'responsible_role应标注具体的责任人或部门'en:- 'type causes indicates causing risk'diff --git a/hyperextract/templates/presets/legal/case_citation.yaml b/hyperextract/templates/presets/legal/case_citation.yamlindex 94f45bc..936f0c4 100644--- a/hyperextract/templates/presets/legal/case_citation.yaml+++ b/hyperextract/templates/presets/legal/case_citation.yaml@@ -55,7 +55,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:cites/distinguished_from/overruled_by'+ zh: '关系类型:引用/区分/推翻'en: 'Relation type: cites/distinguished_from/overruled_by'required: true- name: description@@ -80,9 +80,9 @@ guideline:- 'Court information should be accurately labeled'rules_for_relations:zh:- - 'type为cites表示引用关系'- - 'type为distinguished_from表示区分解释'- - 'type为overruled_by表示被推翻'+ - 'type为"引用"表示引用关系'+ - 'type为"区分"表示区分解释'+ - 'type为"推翻"表示被推翻'- '仅提取文本中明确提及的引用关系'en:- 'type cites indicates citation relationship'diff --git a/hyperextract/templates/presets/legal/case_fact_timeline.yaml b/hyperextract/templates/presets/legal/case_fact_timeline.yamlindex f495568..e994dfa 100644--- a/hyperextract/templates/presets/legal/case_fact_timeline.yaml+++ b/hyperextract/templates/presets/legal/case_fact_timeline.yaml@@ -55,7 +55,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:preceded_by/proves/disputes'+ zh: '关系类型:先于/证明/争议'en: 'Relation type: preceded_by/proves/disputes'required: true- name: time@@ -86,9 +86,9 @@ guideline:- 'Entity descriptions should be concise and accurate'rules_for_relations:zh:- - 'type为preceded_by表示时间先后顺序'- - 'type为proves表示证据支持'- - 'type为disputes表示对某一事实存在争议'+ - 'type为"先于"表示时间先后顺序'+ - 'type为"证明"表示证据支持'+ - 'type为"争议"表示对某一事实存在争议'- '仅提取文本中明确陈述的事实关系'en:- 'type preceded_by indicates temporal sequence'diff --git a/hyperextract/templates/presets/medicine/anatomy_graph.yaml b/hyperextract/templates/presets/medicine/anatomy_graph.yamlindex 5c598f6..f881efc 100644--- a/hyperextract/templates/presets/medicine/anatomy_graph.yaml+++ b/hyperextract/templates/presets/medicine/anatomy_graph.yaml@@ -55,7 +55,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:contains/located_in'+ zh: '关系类型:包含/位于'en: 'Relation type: contains/located_in'required: truediff --git a/hyperextract/templates/presets/medicine/hospital_timeline.yaml b/hyperextract/templates/presets/medicine/hospital_timeline.yamlindex b4310b4..1257f42 100644--- a/hyperextract/templates/presets/medicine/hospital_timeline.yaml+++ b/hyperextract/templates/presets/medicine/hospital_timeline.yaml@@ -55,7 +55,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:follows/results_in'+ zh: '关系类型:后续/导致'en: 'Relation type: follows/results_in'required: true- name: time@@ -86,8 +86,8 @@ guideline:- 'Descriptions should concisely summarize event content'rules_for_relations:zh:- - 'type为follows表示事件的时序关系'- - 'type为results_in表示因果结果关系'+ - 'type为"后续"表示事件的时序关系'+ - 'type为"导致"表示因果结果关系'- 'performer应标注执行人或科室'en:- 'type follows indicates temporal sequence of events'diff --git a/hyperextract/templates/presets/medicine/treatment_map.yaml b/hyperextract/templates/presets/medicine/treatment_map.yamlindex 38d70c3..4ace2af 100644--- a/hyperextract/templates/presets/medicine/treatment_map.yaml+++ b/hyperextract/templates/presets/medicine/treatment_map.yaml@@ -67,7 +67,7 @@ output:- name: typetype: strdescription:- zh: '关系类型:indicates/contraindicated_with'+ zh: '关系类型:适用于/禁忌联合'en: 'Relation type: indicates/contraindicated_with'required: true@@ -88,8 +88,8 @@ guideline:- 'Extract treatment outcomes as entities'rules_for_relations:zh:- - 'type为indicates表示适应症'- - 'type为contraindicated_with表示禁忌组合'+ - 'type为"适用"表示适应症'+ - 'type为"禁忌"表示禁忌组合'- 'conditions字段应包含所有相关的患者特征/适用条件'en:- 'type indicates indicates indication'diff --git a/hyperextract/templates/presets/tcm/meridian_graph.yaml b/hyperextract/templates/presets/tcm/meridian_graph.yamlindex 8c3d2e6..ebaee42 100644--- a/hyperextract/templates/presets/tcm/meridian_graph.yaml+++ b/hyperextract/templates/presets/tcm/meridian_graph.yaml@@ -74,8 +74,8 @@ guideline:- 'Location descriptions should accurately indicate anatomical positions'rules_for_relations:zh:- - 'type为located_on表示穴位属于某经脉'- - 'type为flows_to表示经脉的流注顺序'+ - 'type为"位于"表示穴位属于某经脉'+ - 'type为"流注"表示经脉的流注顺序'en:- 'type located_on indicates acupoint belongs to a meridian'- 'type flows_to indicates the flow sequence of meridians'