Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
refactor(templates): migrate Python templates to YAML config and mark legacy
yifanfeng97da1b47b5d593
diff --git a/README.md b/README.mdindex 6cde68a..e49e732 100644--- a/README.md+++ b/README.md@@ -76,15 +76,37 @@ Transform LLM output from scattered text into **searchable, queryable, and reaso## 🚀 Quick Start+### Option 1: Using YAML Config (Recommended)++```python+from hyperextract.utils.template_engine import Gallery, TemplateFactory+from langchain_openai import ChatOpenAI, OpenAIEmbeddings++llm = ChatOpenAI(model="gpt-4o-mini")+embedder = OpenAIEmbeddings()++# Get template (auto-loaded presets and customs)+config = Gallery.get("ResearchNoteSummary")++# Create template+template = TemplateFactory.create(config, llm, embedder)+result = template.parse("Apple Q3 revenue reached $94.9 billion...")++answer = template.chat("What drove the revenue growth?")+print(answer.content)+```++### Option 2: Using Python Class (Deprecated)+```python-from hyperextract.templates.en.finance import ResearchNoteSummary+from hyperextract.templates.legacy.en.finance import ResearchNoteSummaryfrom langchain_openai import ChatOpenAI, OpenAIEmbeddingsllm = ChatOpenAI(model="gpt-4o-mini")embedder = OpenAIEmbeddings()template = ResearchNoteSummary(llm_client=llm, embedder=embedder)-result = template.extract("Apple Q3 revenue reached $94.9 billion...")+result = template.parse("Apple Q3 revenue reached $94.9 billion...")answer = template.chat("What drove the revenue growth?")print(answer.content)diff --git a/README_ZH.md b/README_ZH.mdindex 24389b1..df635ec 100644--- a/README_ZH.md+++ b/README_ZH.md@@ -76,15 +76,37 @@## 🚀 快速开始+### 方式一:使用 YAML 配置(推荐)++```python+from hyperextract.utils.template_engine import Gallery, TemplateFactory+from langchain_openai import ChatOpenAI, OpenAIEmbeddings++llm = ChatOpenAI(model="gpt-4o-mini")+embedder = OpenAIEmbeddings()++# 直接获取模板(自动加载 presets 和 customs)+config = Gallery.get("ResearchNoteSummary")++# 创建模板+template = TemplateFactory.create(config, llm, embedder)+result = template.parse("苹果Q3营收达到949亿美元...")++answer = template.chat("营收增长的原因是什么?")+print(answer.content)+```++### 方式二:使用 Python 类(已废弃)+```python-from hyperextract.templates.zh.finance import ResearchNoteSummary+from hyperextract.templates.legacy.zh.finance import ResearchNoteSummaryfrom langchain_openai import ChatOpenAI, OpenAIEmbeddingsllm = ChatOpenAI(model="gpt-4o-mini")embedder = OpenAIEmbeddings()template = ResearchNoteSummary(llm_client=llm, embedder=embedder)-result = template.extract("苹果Q3营收达到949亿美元...")+result = template.parse("苹果Q3营收达到949亿美元...")answer = template.chat("营收增长的原因是什么?")print(answer.content)diff --git a/examples/config_template_demo.py b/examples/config_template_demo.pynew file mode 100644index 0000000..ac004f4--- /dev/null+++ b/examples/config_template_demo.py@@ -0,0 +1,96 @@+"""+YAML配置模板测试演示++这个文件用于测试通过YAML配置文件生成的模板。+测试LifeEventTimeline (temporal_graph) 模板。++使用方法:+1. 运行文件:python examples/config_template_demo.py+"""++import os+import sys++sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))++from pathlib import Path+from dotenv import load_dotenv++from hyperextract.utils.template_engine import Gallery, TemplateFactory+from langchain_openai import ChatOpenAI, OpenAIEmbeddings+++TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "general"+INPUT_FILE = TEST_SAMPLES_ROOT / "biography_scientist.md"+++def main():+ print("=" * 60)+ print("YAML配置模板测试 - LifeEventTimeline")+ print("=" * 60)++ load_dotenv()++ if not INPUT_FILE.exists():+ print(f"错误:找不到文件 {INPUT_FILE}")+ return++ print(f"\n输入文件: {INPUT_FILE.name}")++ print("\n初始化LLM客户端...")+ try:+ llm = ChatOpenAI(+ model="gpt-4o-mini",+ temperature=0,+ )+ embedder = OpenAIEmbeddings(model="text-embedding-3-small")+ print("LLM客户端初始化成功")+ except Exception as e:+ print(f"LLM客户端初始化失败: {e}")+ return++ print("\n读取文件内容...")+ with open(INPUT_FILE, "r", encoding="utf-8") as f:+ content = f.read()+ print(f"读取成功,共 {len(content)} 字符")++ print("\n加载YAML配置...")+ config = Gallery.get("LifeEventTimeline")+ if not config:+ print("错误:找不到LifeEventTimeline配置")+ return+ print(f"配置加载成功: {config.name}, autotype: {config.autotype}")++ print("\n从配置创建模板...")+ try:+ template = TemplateFactory.create(+ config,+ llm,+ embedder,+ )+ print("模板创建成功")+ except Exception as e:+ print(f"模板创建失败: {e}")+ import traceback+ traceback.print_exc()+ return++ print("\n开始知识提取...")+ try:+ template.feed_text(content)+ print("知识提取完成")++ template.build_index()+ print("\n" + "=" * 60)+ print("提取结果展示")+ print("=" * 60)+ template.show()++ except Exception as e:+ print(f"知识提取失败: {e}")+ import traceback+ traceback.print_exc()+++if __name__ == "__main__":+ main()diff --git a/examples/template_agriculture_demo.py b/examples/template_agriculture_demo.pyindex f7ce9c3..77081bd 100644--- a/examples/template_agriculture_demo.py+++ b/examples/template_agriculture_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有农业知识模板-from hyperextract.templates.zh.agriculture import (+from hyperextract.templates.legacy.zh.agriculture import (# 农业技术手册CropGrowthCycle,PestControlHypergraph,diff --git a/examples/template_biology_demo.py b/examples/template_biology_demo.pyindex 0ab0213..76754fe 100644--- a/examples/template_biology_demo.py+++ b/examples/template_biology_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有生物科学知识模板-from hyperextract.templates.zh.biology import (+from hyperextract.templates.legacy.zh.biology import (# 生物学专著SpeciesInteractionWeb,TaxonomicTree,diff --git a/examples/template_finance_demo.py b/examples/template_finance_demo.pyindex e08b82e..7f0ef83 100644--- a/examples/template_finance_demo.py+++ b/examples/template_finance_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有金融知识模板-from hyperextract.templates.zh.finance import (+from hyperextract.templates.legacy.zh.finance import (# SEC 文件 (10-K / 10-Q / 8-K)FilingFinancialSnapshot,MDANarrativeGraph,diff --git a/examples/template_food_demo.py b/examples/template_food_demo.pyindex bbaaa77..10a12ca 100644--- a/examples/template_food_demo.py+++ b/examples/template_food_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有美食餐饮知识模板-from hyperextract.templates.zh.food import (+from hyperextract.templates.legacy.zh.food import (# 标准化食谱RecipeCollection,StandardRecipeCard,diff --git a/examples/template_general_demo.py b/examples/template_general_demo.pyindex b9c575b..4fa01b5 100644--- a/examples/template_general_demo.py+++ b/examples/template_general_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有 general 知识模板-from hyperextract.templates.zh.general import (+from hyperextract.templates.legacy.zh.general import (# 第一波:基础知识提取KnowledgeGraph,EntityRegistry,diff --git a/examples/template_history_demo.py b/examples/template_history_demo.pyindex 08ebddd..525815d 100644--- a/examples/template_history_demo.py+++ b/examples/template_history_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有历史知识模板-from hyperextract.templates.zh.history import (+from hyperextract.templates.legacy.zh.history import (# 历史专著HistoricalKnowledgeGraph,MultiParticipantEventMap,diff --git a/examples/template_industry_demo.py b/examples/template_industry_demo.pyindex 8306d95..9caa3b3 100644--- a/examples/template_industry_demo.py+++ b/examples/template_industry_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有工业知识模板-from hyperextract.templates.zh.industry import (+from hyperextract.templates.legacy.zh.industry import (# 1. 管理规范 (Management Specifications)SafetyControlGraph,EmergencyResponseGraph,diff --git a/examples/template_legal_demo.py b/examples/template_legal_demo.pyindex 5f9f7b9..9d34e38 100644--- a/examples/template_legal_demo.py+++ b/examples/template_legal_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有法律知识模板-from hyperextract.templates.zh.legal import (+from hyperextract.templates.legacy.zh.legal import (# 法学专著与评注LegalConceptOntology,CaseLawCitationNet,diff --git a/examples/template_literature_demo.py b/examples/template_literature_demo.pyindex 9587982..8e3e348 100644--- a/examples/template_literature_demo.py+++ b/examples/template_literature_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有文学与影视知识模板-from hyperextract.templates.zh.literature import (+from hyperextract.templates.legacy.zh.literature import (# 影视剧本模板SceneEventHypergraph,NarrativeTimeline,diff --git a/examples/template_medicine_demo.py b/examples/template_medicine_demo.pyindex e8e7228..2e84c45 100644--- a/examples/template_medicine_demo.py+++ b/examples/template_medicine_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有医学知识模板-from hyperextract.templates.zh.medicine import (+from hyperextract.templates.legacy.zh.medicine import (# 医学教科书与专著PathologyHypergraph,MedicalConceptNet,diff --git a/examples/template_news_demo.py b/examples/template_news_demo.pyindex 881837d..bee275f 100644--- a/examples/template_news_demo.py+++ b/examples/template_news_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有新闻传媒知识模板-from hyperextract.templates.zh.news import (+from hyperextract.templates.legacy.zh.news import (# 深度调查报道InvestigativeContextGraph,ComplexRelationNet,diff --git a/examples/template_tcm_demo.py b/examples/template_tcm_demo.pyindex d87d2f6..3ec5ca5 100644--- a/examples/template_tcm_demo.py+++ b/examples/template_tcm_demo.py@@ -19,7 +19,7 @@ from pathlib import Pathfrom dotenv import load_dotenv# 导入所有中医知识模板-from hyperextract.templates.zh.tcm import (+from hyperextract.templates.legacy.zh.tcm import (# 本草典籍HerbPropertyModel,ProcessingMethod,diff --git a/hyperextract/cli/cli.py b/hyperextract/cli/cli.pyindex 35e45af..14dfdc8 100644--- a/hyperextract/cli/cli.py+++ b/hyperextract/cli/cli.py@@ -62,7 +62,7 @@ def main(table.add_row("he parse", "<input> -o <output>", "Extract knowledge from text")table.add_row("he list", "template", "List available templates")table.add_row("he show", "<kb_path>", "Visualize knowledge base")- table.add_row("he search", "<query> -k <kb>", "Semantic search")+ table.add_row("he search", "<query> -k <kb>", "Semantic search in knowledge base")table.add_row("he talk", "-k <kb>", "Chat with knowledge base")panel = Panel(diff --git a/hyperextract/cli/commands/build_index.py b/hyperextract/cli/commands/build_index.pyindex 1053847..82f9abb 100644--- a/hyperextract/cli/commands/build_index.py+++ b/hyperextract/cli/commands/build_index.py@@ -67,14 +67,10 @@ def main(try:from ..templates import resolve_template- from .feed import create_llm_client, create_embedder- template_class = resolve_template(template, lang)- llm = create_llm_client(config)- embedder = create_embedder(config)+ kb = resolve_template(template, lang)progress.update(task, description="Loading knowledge base...")- kb = template_class(llm_client=llm, embedder=embedder)kb.load(path)progress.update(task, description="Building index...")diff --git a/hyperextract/cli/commands/feed.py b/hyperextract/cli/commands/feed.pyindex 9f88c68..791cb28 100644--- a/hyperextract/cli/commands/feed.py+++ b/hyperextract/cli/commands/feed.py@@ -16,35 +16,6 @@ app = typer.Typer()-def create_llm_client(config):- """Create LLM client from config."""- llm_config = config.get_llm_config()- if llm_config.provider == "openai":- from langchain_openai import ChatOpenAI- return ChatOpenAI(- model=llm_config.model,- api_key=llm_config.api_key,- base_url=llm_config.base_url or None,- temperature=0,- )- else:- raise ValueError(f"Unsupported LLM provider: {llm_config.provider}")---def create_embedder(config):- """Create embedder from config."""- emb_config = config.get_embedder_config()- if emb_config.provider == "openai":- from langchain_openai import OpenAIEmbeddings- return OpenAIEmbeddings(- model=emb_config.model,- api_key=emb_config.api_key,- base_url=emb_config.base_url or None,- )- else:- raise ValueError(f"Unsupported Embedder provider: {emb_config.provider}")--def read_input(input_path: str) -> str:"""Read input from file or stdin."""import sys@@ -65,7 +36,7 @@ def main(lang: Optional[str] = typer.Option(None, "--lang", "-l", help="Language"),):"""Append knowledge to an existing directory."""- from ..config import ConfigManager, load_kb_metadata+ from ..config import ConfigManager, load_kb_metadata, save_kb_metadatafrom ..templates import resolve_templateconfig = ConfigManager()@@ -97,25 +68,21 @@ def main(console.print()try:- template_class = resolve_template(template, lang)- console.print(f"[green]Template resolved:[/green] {template_class.__name__}")+ kb = resolve_template(template, lang)+ console.print(f"[green]Template loaded:[/green] {template}")except ValueError as e:console.print(f"[red]Error:[/red] {e}")raise typer.Exit(1)with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}"), console=console) as progress:- task = progress.add_task("Initializing LLM client...", total=None)- llm = create_llm_client(config)- embedder = create_embedder(config)+ task = progress.add_task("Loading existing knowledge...", total=None)++ kb.load(output_path)progress.update(task, description="Reading input...")text = read_input(input)console.print(f"[dim]Input text: {len(text)} characters[/dim]")- progress.update(task, description="Loading existing knowledge...")- kb = template_class(llm_client=llm, embedder=embedder, verbose=True)- kb.load(output_path)-progress.update(task, description="Appending knowledge...")kb.feed_text(text)@@ -123,7 +90,6 @@ def main(kb.dump(output_path)metadata["updated_at"] = datetime.now().isoformat()- from ..config import save_kb_metadatasave_kb_metadata(output_path, metadata)console.print()diff --git a/hyperextract/cli/commands/list.py b/hyperextract/cli/commands/list.pyindex 6fff06f..5e36aea 100644--- a/hyperextract/cli/commands/list.py+++ b/hyperextract/cli/commands/list.py@@ -25,18 +25,18 @@ AUTOTYPES = []DOMAINS = [- ("finance", "Financial documents (25+ templates)"),- ("medicine", "Medical documents (20+ templates)"),- ("legal", "Legal documents (15+ templates)"),- ("history", "Historical documents (12+ templates)"),- ("literature", "Literature works (10+ templates)"),- ("tcm", "Traditional Chinese Medicine (15+ templates)"),- ("news", "News articles (12+ templates)"),- ("biology", "Biological documents (10+ templates)"),- ("industry", "Industrial documents (18+ templates)"),- ("agriculture", "Agricultural documents (8+ templates)"),- ("food", "Food and culinary (8+ templates)"),- ("general", "General purpose (20+ templates)"),+ ("finance", "Financial documents"),+ ("medicine", "Medical documents"),+ ("legal", "Legal documents"),+ ("history", "Historical documents"),+ ("literature", "Literature works"),+ ("tcm", "Traditional Chinese Medicine"),+ ("news", "News articles"),+ ("biology", "Biological documents"),+ ("industry", "Industrial documents"),+ ("agriculture", "Agricultural documents"),+ ("food", "Food and culinary"),+ ("general", "General purpose"),]METHODS = [@@ -50,69 +50,72 @@ METHODS = []-def _get_all_templates() -> list:- """Get all available templates from hyperextract."""- templates = []+def _get_domains_from_configs() -> list:+ """Get domains from configs directory."""try:- from hyperextract.templates import zh, en- for name in dir(zh):- if not name.startswith("_"):- templates.append((f"zh/{name}", name, "Chinese"))- for name in dir(en):- if not name.startswith("_"):- templates.append((f"en/{name}", name, "English"))- return templates- except ImportError:+ from ..templates import get_domains+ return get_domains()+ except Exception:return []-def _filter_items(items: list, search: Optional[str]) -> list:- """Filter items by search keyword."""- if not search:- return items- search_lower = search.lower()- return [- item for item in items- if any(search_lower in str(field).lower() for field in item)- ]--@app.command(name="autotype")def autotype(search: Optional[str] = typer.Option(None, "--search", "-s", help="Search autotypes"),):"""List all available AutoTypes."""- items = _filter_items(AUTOTYPES, search)+ from hyperextract.utils.template_engine import Gallery++ autotypes = Gallery.list_autotypes()++ if search:+ search_lower = search.lower()+ autotypes = [a for a in autotypes if search_lower in a.lower()]table = Table(title="Available AutoTypes", show_header=True, header_style="bold magenta")table.add_column("AutoType", style="cyan", width=25)table.add_column("Description", style="green")- for name, desc in items:+ autotype_descriptions = dict(AUTOTYPES)+ for name in autotypes:+ desc = autotype_descriptions.get(name, "")table.add_row(name, desc)console.print(table)- console.print(f"\n[dim]Total: {len(items)} AutoTypes[/dim]")+ console.print(f"\n[dim]Total: {len(autotypes)} AutoTypes[/dim]")@app.command(name="template")def template(- search: Optional[str] = typer.Option(None, "--search", "-s", help="Search templates"),+ search: Optional[str] = typer.Option(None, "--search", "-s", help="Search templates by name"),+ autotype: Optional[str] = typer.Option(None, "--autotype", "-a", help="Filter by autotype"),+ language: Optional[str] = typer.Option(None, "--lang", "-l", help="Filter by language"),):"""List all available templates."""- templates = _get_all_templates()- items = _filter_items(templates, search)+ from hyperextract.utils.template_engine import Gallery++ results = Gallery.search(query=search, autotype=autotype, language=language)++ templates = []+ for cfg in results:+ full_name = cfg.name+ languages = cfg.language if cfg.language else ["zh"]+ if isinstance(languages, str):+ languages = [languages]++ for lang in languages:+ templates.append((full_name, full_name, lang))table = Table(title="Available Templates", show_header=True, header_style="bold magenta")table.add_column("Template ID", style="cyan", width=30)table.add_column("Name", style="green", width=30)table.add_column("Language", style="yellow", width=10)- for tid, name, lang in items:+ for tid, name, lang in templates:table.add_row(tid, name, lang)console.print(table)- console.print(f"\n[dim]Total: {len(items)} templates[/dim]")+ console.print(f"\n[dim]Total: {len(templates)} templates[/dim]")console.print("\n[dim]Tip: Use -t/--template to specify a template.[/dim]")@@ -121,7 +124,21 @@ def domain(search: Optional[str] = typer.Option(None, "--search", "-s", help="Search domains"),):"""List all available domains."""- items = _filter_items(DOMAINS, search)+ domains = _get_domains_from_configs()++ domain_descriptions = dict(DOMAINS)++ items = []+ for name, count in domains:+ desc = domain_descriptions.get(name, f"{name} documents")+ items.append((name, f"{desc} ({count} templates)"))++ if search:+ search_lower = search.lower()+ items = [+ item for item in items+ if search_lower in item[0].lower() or search_lower in item[1].lower()+ ]table = Table(title="Available Domains", show_header=True, header_style="bold magenta")table.add_column("Domain", style="cyan", width=20)@@ -139,7 +156,14 @@ def method(search: Optional[str] = typer.Option(None, "--search", "-s", help="Search methods"),):"""List all available extraction methods."""- items = _filter_items(METHODS, search)+ items = METHODS++ if search:+ search_lower = search.lower()+ items = [+ item for item in items+ if search_lower in item[0].lower() or search_lower in item[1].lower()+ ]table = Table(title="Available Methods", show_header=True, header_style="bold magenta")table.add_column("Method", style="cyan", width=20)diff --git a/hyperextract/cli/commands/parse.py b/hyperextract/cli/commands/parse.pyindex 38dc1ec..e3edb69 100644--- a/hyperextract/cli/commands/parse.py+++ b/hyperextract/cli/commands/parse.py@@ -9,9 +9,6 @@ import typerfrom rich.console import Consolefrom rich.progress import Progress, SpinnerColumn, TextColumn-from ..config import ConfigManager, save_kb_metadata-from ..templates import resolve_template, get_auto_type_from_template-console = Console()app = typer.Typer(@@ -20,35 +17,6 @@ app = typer.Typer()-def create_llm_client(config: ConfigManager):- """Create LLM client from config."""- llm_config = config.get_llm_config()- if llm_config.provider == "openai":- from langchain_openai import ChatOpenAI- return ChatOpenAI(- model=llm_config.model,- api_key=llm_config.api_key,- base_url=llm_config.base_url or None,- temperature=0,- )- else:- raise ValueError(f"Unsupported LLM provider: {llm_config.provider}")---def create_embedder(config: ConfigManager):- """Create embedder from config."""- emb_config = config.get_embedder_config()- if emb_config.provider == "openai":- from langchain_openai import OpenAIEmbeddings- return OpenAIEmbeddings(- model=emb_config.model,- api_key=emb_config.api_key,- base_url=emb_config.base_url or None,- )- else:- raise ValueError(f"Unsupported Embedder provider: {emb_config.provider}")--def read_input(input_path: str) -> str:"""Read input from file or stdin."""if input_path == "-":@@ -70,7 +38,7 @@ def main():"""Extract knowledge from text to a new directory."""from ..config import ConfigManager, save_kb_metadata- from ..templates import resolve_template, get_auto_type_from_template+ from ..templates import resolve_template, resolve_template_config, get_auto_type_from_templateconfig = ConfigManager()valid, msg = config.validate()@@ -94,35 +62,33 @@ def main(console.print()try:- template_class = resolve_template(template, lang)- console.print(f"[green]Template resolved:[/green] {template_class.__name__}")+ template_config = resolve_template_config(template, lang)+ if template_config is None:+ raise ValueError(f"Template '{template}' not found")+ console.print(f"[green]Template resolved:[/green] {template_config.name}")except ValueError as e:console.print(f"[red]Error:[/red] {e}")raise typer.Exit(1)with Progress(SpinnerColumn(), TextColumn("[progress.description]{task.description}"), console=console) as progress:- task = progress.add_task("Initializing LLM client...", total=None)- llm = create_llm_client(config)- embedder = create_embedder(config)-+ task = progress.add_task("Creating template instance...", total=None)++ kb = resolve_template(template, lang)+progress.update(task, description="Reading input...")text = read_input(input)console.print(f"[dim]Input text: {len(text)} characters[/dim]")- progress.update(task, description="Initializing template...")- kb = template_class(llm_client=llm, embedder=embedder, verbose=True)-progress.update(task, description="Extracting knowledge...")kb.feed_text(text)progress.update(task, description="Saving data...")kb.dump(output_path)- #TODO 后续可以考虑怎么融合进 dump 方法metadata = {"template": template,"lang": lang,- "auto_type": get_auto_type_from_template(template_class),+ "auto_type": get_auto_type_from_template(template_config),"created_at": datetime.now().isoformat(),"updated_at": datetime.now().isoformat(),}diff --git a/hyperextract/cli/commands/search.py b/hyperextract/cli/commands/search.pyindex dd40151..19810ab 100644--- a/hyperextract/cli/commands/search.py+++ b/hyperextract/cli/commands/search.py@@ -22,6 +22,7 @@ def main():"""Semantic search in knowledge base."""from ..config import ConfigManager, load_kb_metadata+ from ..templates import resolve_templatepath = Path(kb_path)@@ -62,15 +63,9 @@ def main(task = progress.add_task("Searching...", total=None)try:- from ..templates import resolve_template- from .feed import create_llm_client, create_embedder-- template_class = resolve_template(template, lang)- llm = create_llm_client(config)- embedder = create_embedder(config)+ kb = resolve_template(template, lang)progress.update(task, description="Loading knowledge base...")- kb = template_class(llm_client=llm, embedder=embedder)kb.load(path)progress.update(task, description="Searching...")diff --git a/hyperextract/cli/commands/show.py b/hyperextract/cli/commands/show.pyindex 5d181fd..ad675dd 100644--- a/hyperextract/cli/commands/show.py+++ b/hyperextract/cli/commands/show.py@@ -21,6 +21,7 @@ def main():"""Show knowledge base visualization."""from ..config import ConfigManager, load_kb_metadata+ from ..templates import resolve_template, resolve_template_configpath = Path(kb_path)@@ -58,22 +59,7 @@ def main(with console.status("[bold blue]Loading knowledge base..."):try:- from ..templates import resolve_template-- template_class = resolve_template(template, lang)- llm = None- embedder = None-- if build_index:- valid, msg = config.validate()- if not valid:- console.print(f"[yellow]Warning:[/yellow] Skipping index build: {msg}")- else:- from .feed import create_llm_client, create_embedder- llm = create_llm_client(config)- embedder = create_embedder(config)-- kb = template_class(llm_client=llm, embedder=embedder)+ kb = resolve_template(template, lang)kb.load(path)if build_index:diff --git a/hyperextract/cli/commands/talk.py b/hyperextract/cli/commands/talk.pyindex d6cc4d4..fb2e545 100644--- a/hyperextract/cli/commands/talk.py+++ b/hyperextract/cli/commands/talk.py@@ -46,6 +46,7 @@ def main():"""Chat with knowledge base."""from ..config import ConfigManager, load_kb_metadata+ from ..templates import resolve_templatepath = Path(kb_path)@@ -95,15 +96,9 @@ def main(task = progress.add_task("Loading...", total=None)try:- from ..templates import resolve_template- from .feed import create_llm_client, create_embedder-- template_class = resolve_template(template, lang)- llm = create_llm_client(config)- embedder = create_embedder(config)+ kb = resolve_template(template, lang)progress.update(task, description="Loading knowledge base...")- kb = template_class(llm_client=llm, embedder=embedder)kb.load(path)except Exception as e:diff --git a/hyperextract/cli/templates.py b/hyperextract/cli/templates.pyindex c5b6327..0f89bac 100644--- a/hyperextract/cli/templates.py+++ b/hyperextract/cli/templates.py@@ -1,73 +1,136 @@"""Template loading utilities for Hyper-Extract CLI."""-from typing import Type, Optional, Any-import importlib+from typing import Optional, Any, Type--TEMPLATE_ALIASES = {- "kg": "knowledge_graph",- "graph": "knowledge_graph",- "list": "keyword_list",- "entity": "entity_registry",- "timeline": "chronological_event_chain",- "risk": "risk_assessment",- "summary": "encyclopedia_item",-}+from hyperextract.utils.template_engine import Gallery, TemplateFactory, TemplateConfigdef resolve_template(template_str: str, lang: str = "zh") -> Type:"""- Resolve a template string to a template class.+ Resolve a template string to a template instance.Args:- template_str: Template name or alias (e.g., "knowledge_graph", "kg", "zh/finance/risk_assessment")+ template_str: Template name (e.g., "KnowledgeGraph", "zh/finance/risk_assessment")lang: Language (zh/en)Returns:- Template class+ TemplateWrapper instanceRaises:ValueError: If template not found"""- template_str = template_str.lower()+ original_str = template_str- if template_str in TEMPLATE_ALIASES:- template_str = TEMPLATE_ALIASES[template_str]+ config = Gallery.get(template_str)+ if config is not None:+ return _create_template_from_config(config)parts = template_str.split("/")-if len(parts) == 1:template_name = parts[0]- module_path = f"hyperextract.templates.{lang}.{template_name}"+ search_name = f"{lang}/{template_name}"+ config = Gallery.get(search_name)+ if config is not None:+ return _create_template_from_config(config)else:template_lang = parts[0]if template_lang not in ["zh", "en"]:template_lang = lang- domain = parts[1]- template_name = parts[2] if len(parts) > 2 else parts[1]- module_path = f"hyperextract.templates.{template_lang}.{domain}.{template_name}"+ template_name = parts[-1]++ full_name = f"{template_lang}/{template_name}"+ config = Gallery.get(full_name)+ if config is not None:+ return _create_template_from_config(config)- try:- module = importlib.import_module(module_path)- template_class = getattr(module, template_name)- return template_class- except (ImportError, AttributeError) as e:- raise ValueError(f"Template '{template_str}' not found: {e}")+ available = Gallery.list_all()+ raise ValueError(f"Template '{original_str}' not found. Available templates: {available[:10]}...")-def get_template_info(template_class: Type) -> dict:- """Get template information."""- return {- "name": template_class.__name__,- "module": template_class.__module__,- }+def resolve_template_config(template_str: str, lang: str = "zh") -> Optional[TemplateConfig]:+ """+ Resolve a template string to a TemplateConfig.++ Args:+ template_str: Template name+ lang: Language (zh/en)+ Returns:+ TemplateConfig if found, None otherwise+ """+ original_str = template_str-def get_auto_type_from_template(template_class: Type) -> str:- """Infer AutoType from template class."""- module = template_class.__module__+ config = Gallery.get(template_str)+ if config is not None:+ return config- if ".templates.zh." in module or ".templates.en." in module:- return "AutoGraph"+ parts = template_str.split("/")+ if len(parts) == 1:+ template_name = parts[0]+ search_name = f"{lang}/{template_name}"+ config = Gallery.get(search_name)+ if config is not None:+ return config+ else:+ template_lang = parts[0]+ if template_lang not in ["zh", "en"]:+ template_lang = lang+ template_name = parts[-1]+ full_name = f"{template_lang}/{template_name}"+ return Gallery.get(full_name)+++def _create_template_from_config(config: TemplateConfig):+ """Create a template instance from config using TemplateFactory."""+ from .config import ConfigManager++ config_manager = ConfigManager()+ llm_config = config_manager.get_llm_config()+ embedder_config = config_manager.get_embedder_config()++ if llm_config.provider == "openai":+ from langchain_openai import ChatOpenAI+ llm_client = ChatOpenAI(+ model=llm_config.model,+ api_key=llm_config.api_key,+ base_url=llm_config.base_url or None,+ temperature=0,+ )+ else:+ raise ValueError(f"Unsupported LLM provider: {llm_config.provider}")++ if embedder_config.provider == "openai":+ from langchain_openai import OpenAIEmbeddings+ embedder = OpenAIEmbeddings(+ model=embedder_config.model,+ api_key=embedder_config.api_key,+ base_url=embedder_config.base_url or None,+ )+ else:+ raise ValueError(f"Unsupported Embedder provider: {embedder_config.provider}")++ return TemplateFactory.create(config, llm_client, embedder)+++def get_auto_type_from_template(template_or_config: Any) -> str:+ """Infer AutoType from template class or config."""+ if isinstance(template_or_config, TemplateConfig):+ autotype = template_or_config.autotype+ autotype_map = {+ "model": "AutoModel",+ "list": "AutoList",+ "set": "AutoSet",+ "graph": "AutoGraph",+ "hypergraph": "AutoHypergraph",+ "temporal_graph": "AutoTemporalGraph",+ "spatial_graph": "AutoSpatialGraph",+ "spatio_temporal_graph": "AutoSpatioTemporalGraph",+ }+ return autotype_map.get(autotype, "AutoGraph")return "AutoGraph"+++def get_domains() -> list:+ """Get available domains from configs directory."""+ return Gallery.list_domains()diff --git "a/hyperextract/templates/PYTHON\350\275\254YAML\351\205\215\347\275\256\346\214\207\345\215\227.md" "b/hyperextract/templates/PYTHON\350\275\254YAML\351\205\215\347\275\256\346\214\207\345\215\227.md"new file mode 100644index 0000000..0df2355--- /dev/null+++ "b/hyperextract/templates/PYTHON\350\275\254YAML\351\205\215\347\275\256\346\214\207\345\215\227.md"@@ -0,0 +1,361 @@+# Python模板转YAML配置指南++本文档说明如何将现有的Python模板文件转换为YAML配置文件格式。++---++## 目录结构++```+hyperextract/templates/presets/+├── finance/ # 财经领域+├── medicine/ # 医疗领域+├── tcm/ # 中医领域+├── law/ # 法律领域+├── general/ # 通用领域+└── ... # 其他领域+```++每个YAML文件代表一个模板。++---++## YAML配置结构++以下是完整的配置字段说明:++```yaml+# 必需字段+name: 模板名称 # 模板类名,如 EarningsCallSummary+autotype: model # 类型:model | list | set | graph | hypergraph | temporal_graph | spatial_graph | spatio_temporal_graph+tag: [finance] # 标签数组,用于索引和检索,如 [finance], [medicine], [general] 等++# 语言配置(目前只用中文)+language: zh # 语言代码,目前统一使用 zh++# 描述(多语言格式)+description:+ zh: 中文描述文字 # 注意:要用 zh: 格式,即使只有一个语言++# Schema定义(根据autotype不同)+# autotype: model 时使用 schema+schema:+ fields:+ - name: 字段名+ type: string # 类型:string | int | float | bool | array+ description:+ zh: 字段描述 # 注意:这里也要用 zh: 格式+ required: false # 是否必填,默认 false+ default: "" # 默认值++# autotype: list 或 set 时使用 item_schema+item_schema:+ fields:+ - name: 字段名+ type: string+ description:+ zh: 字段描述+ required: false+ default: ""++# autotype: graph 类时使用 node_schema 和 edge_schema+node_schema:+ fields:+ - name: 字段名+ type: string+ description:+ zh: 字段描述++edge_schema:+ fields:+ - name: 字段名+ type: string+ description:+ zh: 字段描述++# 提取指南(多语言格式)+extraction_guide:+ target:+ zh: |+ 你是一位xxx专家...+ 这里写角色定义和提取任务说明++ rules:+ zh: |+ 1. 规则1+ 2. 规则2++ rules_for_nodes:+ zh: |+ 1. 节点规则1+ 2. 节点规则2++ rules_for_edges:+ zh: |+ 1. 边规则1+ 2. 边规则2++ rules_for_time: # temporal_graph / spatio_temporal_graph 使用+ zh: |+ 1. 时间规则1++ rules_for_location: # spatial_graph / spatio_temporal_graph 使用+ zh: |+ 1. 位置规则1++# 标识配置+identifiers:+ item_id: 字段名 # set 类型使用+ node_id: 字段名 # graph 类型使用+ edge_id: "{source}|{relation}" # graph 类型使用,支持模板格式+ edge_members: # graph 类型使用+ source: source+ target: target+ time_field: 字段名 # temporal_graph / spatio_temporal_graph 使用+ location_field: 字段名 # spatial_graph / spatio_temporal_graph 使用++# 运行时参数(可选,不填则使用默认值)+parameters:+ extraction_mode: two_stage # graph 类型使用:one_stage | two_stage+ node_merge_strategy: llm_balanced # graph 类型使用,不填默认为 llm_balanced+ edge_merge_strategy: llm_balanced # graph 类型使用,不填默认为 llm_balanced+ observation_time: "2024-01-01" # temporal_graph / spatio_temporal_graph 使用+ observation_location: "北京" # spatial_graph / spatio_temporal_graph 使用+ chunk_size: 2048+ chunk_overlap: 256+ max_workers: 10+ verbose: false++# 展示配置(必需)+# 注意:支持模板字符串格式,使用 {字段名} 占位,可组合多个字段+display:+ label: 字段名 # model / list / set 使用+ node_label: "{字段1} ({字段2})" # graph 类型使用,支持模板格式如 "{name} ({type})"+ edge_label: "{字段1}" # graph 类型使用,可使用模板如 "{relation_type}"+```++---++## 多语言字段格式要求++**重要**:以下字段都需要使用 `zh:` 格式,即使只有一个语言:++### 1. 整体description++```yaml+# 正确格式+description:+ zh: 这是一个描述文字+```++### 2. Schema字段的description++```yaml+# 正确格式(每个字段的description都要用zh:格式)+schema:+ fields:+ - name: company_name+ type: string+ description:+ zh: 公司名称+ required: false+```++### 3. extraction_guide中的字段++```yaml+# 正确格式(每个子字段都要用zh:格式)+extraction_guide:+ target:+ zh: |+ 你是一位专业的财务分析师,擅长从财报电话会议中提取关键信息。+ 请从财报电话会议记录中提取关键财务指标、业绩指引和整体基调。++ rules:+ zh: |+ 1. 每个字段对应一个独立的信息项,禁止合并+ 2. 数据必须与原文保持一致,不得编造+ 3. 如果信息缺失,该字段留空+```++---++## 各AutoType配置对照表++| AutoType | Schema字段 | identifiers必需字段 | 特有parameters |+|----------|-----------|-------------------|---------------|+| model | schema | - | - |+| list | item_schema | - | - |+| set | item_schema | item_id | - |+| graph | node_schema + edge_schema | node_id, edge_id, edge_members | extraction_mode |+| hypergraph | node_schema + edge_schema | node_id, edge_id, edge_members | extraction_mode |+| temporal_graph | node_schema + edge_schema | node_id, edge_id, edge_members, time_field | extraction_mode, observation_time |+| spatial_graph | node_schema + edge_schema | node_id, edge_id, edge_members, location_field | extraction_mode, observation_location |+| spatio_temporal_graph | node_schema + edge_schema | node_id, edge_id, edge_members, time_field, location_field | extraction_mode, observation_time, observation_location |++**注意**:parameters不填时使用默认值(merge_strategy默认为llm_balanced)++---++## 转换示例++### Python模板 (原格式)++```python+class EarningsCallSummary(AutoModel):+ schema = EarningsCallSummarySchema++ def __init__(self, llm_client, embedder):+ super().__init__(+ data_schema=EarningsCallSummarySchema,+ llm_client=llm_client,+ embedder=embedder,+ prompt="""你是一位专业的财务分析师...""",+ strategy_or_merger=MergeStrategy.LLM.BALANCED,+ )+```++### YAML配置 (目标格式)++```yaml+name: EarningsCallSummary+autotype: model+tag: [finance]++language: zh++description:+ zh: 财报电话会议摘要++schema:+ fields:+ - name: company_name+ type: string+ description:+ zh: 公司名称+ - name: quarter+ type: string+ description:+ zh: 报告季度+ - name: revenue+ type: string+ description:+ zh: 营收数据+ - name: guidance+ type: string+ description:+ zh: 业绩指引++extraction_guide:+ target:+ zh: |+ 你是一位专业的财务分析师,擅长从财报电话会议中提取关键信息。+ 请从财报电话会议记录中提取关键财务指标、业绩指引和整体基调。+ rules:+ zh: |+ 1. 每个字段对应一个独立的信息项,禁止合并+ 2. 数据必须与原文保持一致,不得编造+ 3. 如果信息缺失,该字段留空++identifiers: {}++parameters: {}++display:+ label: company_name+```++---++## 常用配置值++### merge_strategy(不填默认为 llm_balanced)+- `none`: 不合并+- `field`: 基于字段合并+- `llm_balanced`: LLM平衡合并(默认)+- `llm_conservative`: LLM保守合并++### extraction_mode (graph类型)+- `one_stage`: 单阶段提取(同时提取节点和边)+- `two_stage`: 双阶段提取(先提取节点,再提取边)++---++## 时空图参数的特殊处理++对于 `temporal_graph`、`spatial_graph`、`spatio_temporal_graph` 类型的模板,有两个特殊的参数:++### observation_time 和 observation_location++- **observation_time**: 观察日期,用于解析相对时间表达式(如"去年"、"昨天")+- **observation_location**: 观察位置,用于解析相对位置表达式(如"这里"、"附近")++### 在YAML配置中++这两个参数**不应该在YAML配置文件中硬编码**,应该由用户在运行时提供:++```yaml+parameters:+ extraction_mode: two_stage+ # observation_time 和 observation_location 由用户在运行时提供+```++### 在运行时传入++使用 `TemplateFactory.create` 时,可以通过 kwargs 传入这些参数:++```python+from hyperextract.templates.generator import TemplateRegistry, TemplateFactory++# 加载配置+registry = TemplateRegistry()+registry.load_from_directory("hyperextract/templates/presets")+config = registry.get("FinancialDataTemporalGraph")++# 创建模板时传入参数+template = TemplateFactory.create(+ config,+ llm,+ embedder,+ observation_time="2024-06-15", # 覆盖默认值+ observation_location="北京", # 覆盖默认值+ chunk_size=4096, # 也可以覆盖其他参数+)+```++### 在提示词中引用++可以在 extraction_guide 中使用这些参数占位符:++```yaml+extraction_guide:+ rules_for_time:+ zh: |+ 1. 相对时间解析(基于观察日期)+ - 当前观察日期为 {observation_time}+ - "去年" -> 计算 {observation_time} 前一年的年份+ - "昨天" -> 计算 {observation_time} 前一天的日期++ rules_for_location:+ zh: |+ 1. 相对位置解析(基于观察位置)+ - 当前观察位置为 {observation_location}+ - "这里"、"本地" -> {observation_location}+ - "附近"、"周边" -> {observation_location} 附近区域+```++---++## 转换检查清单++转换时请确认:++- [ ] name 字段正确+- [ ] autotype 字段正确+- [ ] tag 数组包含正确的领域标签+- [ ] description 使用 `zh:` 格式+- [ ] schema/item_schema/node_schema/edge_schema 的每个字段的 description 都使用 `zh:` 格式+- [ ] extraction_guide 的每个子字段(target, rules, rules_for_nodes 等)都使用 `zh:` 格式+- [ ] identifiers 配置正确(graph类型需要完整配置)+- [ ] parameters 可选配置+- [ ] display 配置必须存在(label / node_label + edge_label)diff --git a/hyperextract/templates/README.md b/hyperextract/templates/README.mdindex 5d086a9..f2af44a 100644--- a/hyperextract/templates/README.md+++ b/hyperextract/templates/README.md@@ -8,6 +8,84 @@ This library is organized by **Domain**, ensuring that the extraction logic matc---+## 📁 Directory Structure++```+templates/+├── presets/ # Preset templates (system-provided)+│ ├── agriculture/+│ ├── biology/+│ ├── finance/+│ └── ...+├── customs/ # Custom templates (user-created)+│ └── (user templates)+├── legacy/ # Deprecated Python templates+│ ├── zh/+│ └── en/+├── README.md+└── README_ZH.md+```++### presets vs customs++| Directory | Purpose | Description |+|-----------|---------|-------------|+| `presets/` | Preset templates | System-provided knowledge templates, read-only |+| `customs/` | Custom templates | User-created templates, can override presets |++---++## 🚀 Usage++### Recommended: Using YAML Config++```python+from hyperextract.utils.template_engine import Gallery, TemplateFactory+from langchain_openai import ChatOpenAI, OpenAIEmbeddings++llm = ChatOpenAI(model="gpt-4o-mini")+embedder = OpenAIEmbeddings()++# Get template (auto-loaded presets and customs)+config = Gallery.get("KnowledgeGraph")++# Create template+template = TemplateFactory.create(config, llm, embedder)+result = template.parse("Your text here...")++# List all available templates+print(Gallery.list_all())+```++### Creating Custom Templates++Users can create their own templates in `templates/customs/`:++```python+# Add custom template directory (auto-loaded)+Gallery.add_path("/path/to/my/templates")++# Get custom template+config = Gallery.get("MyCustomTemplate")+```++### Deprecated: Using Python Class++```python+from hyperextract.templates.legacy.zh.general import KnowledgeGraph+from langchain_openai import ChatOpenAI, OpenAIEmbeddings++llm = ChatOpenAI(model="gpt-4o-mini")+embedder = OpenAIEmbeddings()++template = KnowledgeGraph(llm_client=llm, embedder=embedder)+result = template.parse("Your text here...")+```++> ⚠️ **Warning**: The Python class templates in `legacy/` are deprecated and will be removed in a future version. Please migrate to YAML config based templates.++---+## 📋 Table of Contents- [📚 General](#1-general-general-purpose)diff --git a/hyperextract/templates/README_ZH.md b/hyperextract/templates/README_ZH.mdindex a673630..a816157 100644--- a/hyperextract/templates/README_ZH.md+++ b/hyperextract/templates/README_ZH.md@@ -8,6 +8,84 @@---+## 📁 目录结构++```+templates/+├── presets/ # 预设模板(系统预置)+│ ├── agriculture/+│ ├── biology/+│ ├── finance/+│ └── ...+├── customs/ # 自定义模板(用户可自行创建)+│ └── (用户模板)+├── legacy/ # 废弃的 Python 模板+│ ├── zh/+│ └── en/+├── README.md+└── README_ZH.md+```++### presets vs customs++| 目录 | 用途 | 说明 |+|------|------|------|+| `presets/` | 预设模板 | 系统预置的知识模板,用户只能读取使用 |+| `customs/` | 自定义模板 | 用户自行创建的模板,可覆盖同名预设 |++---++## 🚀 使用方式++### 推荐方式:使用 YAML 配置++```python+from hyperextract.utils.template_engine import Gallery, TemplateFactory+from langchain_openai import ChatOpenAI, OpenAIEmbeddings++llm = ChatOpenAI(model="gpt-4o-mini")+embedder = OpenAIEmbeddings()++# 直接获取模板(自动加载 presets 和 customs)+config = Gallery.get("KnowledgeGraph")++# 创建模板+template = TemplateFactory.create(config, llm, embedder)+result = template.parse("您的文本内容...")++# 列出所有可用模板+print(Gallery.list_all())+```++### 创建自定义模板++用户可以在 `templates/customs/` 目录下创建自己的模板:++```python+# 添加自定义模板目录(自动加载)+Gallery.add_path("/path/to/my/templates")++# 获取自定义模板+config = Gallery.get("MyCustomTemplate")+```++### 废弃方式:使用 Python 类++```python+from hyperextract.templates.legacy.zh.general import KnowledgeGraph+from langchain_openai import ChatOpenAI, OpenAIEmbeddings++llm = ChatOpenAI(model="gpt-4o-mini")+embedder = OpenAIEmbeddings()++template = KnowledgeGraph(llm_client=llm, embedder=embedder)+result = template.parse("您的文本内容...")+```++> ⚠️ **警告**: `legacy/` 目录下的 Python 类模板已废弃,将在未来版本中删除。请迁移到基于 YAML 配置的模板。++---+## 📋 目录- [📚 通用](#1-general-通用general-purpose)diff --git a/hyperextract/templates/__init__.py b/hyperextract/templates/__init__.pyindex 7f2a477..903653b 100644--- a/hyperextract/templates/__init__.py+++ b/hyperextract/templates/__init__.py@@ -1,6 +1,33 @@-from . import en, zh+"""Hyperextract templates module.++此模块提供知识模板的配置文件和废弃的 Python 模板。++目录结构:+ templates/+ ├── presets/ # 预设模板(系统预置)+ ├── customs/ # 自定义模板(用户可自行创建)+ └── legacy/ # 废弃的 Python 模板++推荐使用方式:+ >>> from hyperextract.utils.template_engine import Gallery, TemplateFactory++ # 直接获取模板(自动加载 presets 和 customs)+ >>> config = Gallery.get("KnowledgeGraph")+ >>> template = TemplateFactory.create(config, llm_client, embedder)++ # 列出所有可用模板+ >>> print(Gallery.list_all())++ # 添加自定义模板目录+ >>> Gallery.add_path("/path/to/my/templates")++废弃的使用方式:+ >>> from hyperextract.templates.legacy.zh.general import KnowledgeGraph+ >>> template = KnowledgeGraph(llm_client=llm, embedder=embedder)+"""++from . import legacy__all__ = [- "en",- "zh",+ "legacy",]diff --git a/hyperextract/templates/en/__init__.py b/hyperextract/templates/customs/.gitkeepsimilarity index 100%rename from hyperextract/templates/en/__init__.pyrename to hyperextract/templates/customs/.gitkeepdiff --git a/hyperextract/templates/legacy/README.md b/hyperextract/templates/legacy/README.mdnew file mode 100644index 0000000..b46f875--- /dev/null+++ b/hyperextract/templates/legacy/README.md@@ -0,0 +1,38 @@+# Legacy Templates (废弃模板)++> ⚠️ **警告**: 此目录下的所有 Python 模板文件已被废弃,将在未来版本中删除。++## 说明++此目录包含旧版本的 Python 类模板,已被 YAML 配置文件模板取代。++## 迁移指南++### 旧的使用方式(已废弃)+```python+from hyperextract.templates.legacy.zh.general import LifeEventTimeline++template = LifeEventTimeline(llm_client=llm, embedder=embedder)+```++### 新的使用方式(推荐)+```python+from hyperextract.utils.template_engine import Gallery, TemplateFactory++# 直接获取模板(自动加载 presets 和 customs)+config = Gallery.get("LifeEventTimeline")++# 创建模板+template = TemplateFactory.create(config, llm_client, embedder)+```++## 删除时间线++- **当前版本**: 标记为废弃,但仍可使用+- **下个版本**: 在文档中明确推荐使用 YAML 配置方式+- **未来版本 (v2.0)**: 删除此目录++## 相关文档++- [PYTHON转YAML配置指南](../PYTHON转YAML配置指南.md)+- [模板使用说明](../README.md)diff --git a/hyperextract/templates/legacy/__init__.py b/hyperextract/templates/legacy/__init__.pynew file mode 100644index 0000000..e088436--- /dev/null+++ b/hyperextract/templates/legacy/__init__.py@@ -0,0 +1,13 @@+"""Legacy templates - 已废弃的 Python 模板。++⚠️ 警告: 此目录下的所有模板已被废弃,将在未来版本中删除。+请使用 hyperextract.utils.template_engine 中的新 API。+"""++from . import zh+from . import en++__all__ = [+ "zh",+ "en",+]diff --git a/hyperextract/templates/en/INSTRUCTION.md b/hyperextract/templates/legacy/en/INSTRUCTION.mdsimilarity index 100%rename from hyperextract/templates/en/INSTRUCTION.mdrename to hyperextract/templates/legacy/en/INSTRUCTION.mddiff --git a/hyperextract/templates/en/biology/__init__.py b/hyperextract/templates/legacy/en/__init__.pysimilarity index 100%rename from hyperextract/templates/en/biology/__init__.pyrename to hyperextract/templates/legacy/en/__init__.pydiff --git a/hyperextract/templates/en/agriculture/__init__.py b/hyperextract/templates/legacy/en/agriculture/__init__.pysimilarity index 100%rename from hyperextract/templates/en/agriculture/__init__.pyrename to hyperextract/templates/legacy/en/agriculture/__init__.pydiff --git a/hyperextract/templates/en/finance/__init__.py b/hyperextract/templates/legacy/en/biology/__init__.pysimilarity index 100%rename from hyperextract/templates/en/finance/__init__.pyrename to hyperextract/templates/legacy/en/biology/__init__.pydiff --git a/hyperextract/templates/en/food/__init__.py b/hyperextract/templates/legacy/en/finance/__init__.pysimilarity index 100%rename from hyperextract/templates/en/food/__init__.pyrename to hyperextract/templates/legacy/en/finance/__init__.pydiff --git a/hyperextract/templates/en/general/__init__.py b/hyperextract/templates/legacy/en/food/__init__.pysimilarity index 100%rename from hyperextract/templates/en/general/__init__.pyrename to hyperextract/templates/legacy/en/food/__init__.pydiff --git a/hyperextract/templates/en/history/__init__.py b/hyperextract/templates/legacy/en/general/__init__.pysimilarity index 100%rename from hyperextract/templates/en/history/__init__.pyrename to hyperextract/templates/legacy/en/general/__init__.pydiff --git a/hyperextract/templates/en/industry/__init__.py b/hyperextract/templates/legacy/en/history/__init__.pysimilarity index 100%rename from hyperextract/templates/en/industry/__init__.pyrename to hyperextract/templates/legacy/en/history/__init__.pydiff --git a/hyperextract/templates/en/legal/__init__.py b/hyperextract/templates/legacy/en/industry/__init__.pysimilarity index 100%rename from hyperextract/templates/en/legal/__init__.pyrename to hyperextract/templates/legacy/en/industry/__init__.pydiff --git a/hyperextract/templates/en/literature/__init__.py b/hyperextract/templates/legacy/en/legal/__init__.pysimilarity index 100%rename from hyperextract/templates/en/literature/__init__.pyrename to hyperextract/templates/legacy/en/legal/__init__.pydiff --git a/hyperextract/templates/en/medicine/__init__.py b/hyperextract/templates/legacy/en/literature/__init__.pysimilarity index 100%rename from hyperextract/templates/en/medicine/__init__.pyrename to hyperextract/templates/legacy/en/literature/__init__.pydiff --git a/hyperextract/templates/en/news/__init__.py b/hyperextract/templates/legacy/en/medicine/__init__.pysimilarity index 100%rename from hyperextract/templates/en/news/__init__.pyrename to hyperextract/templates/legacy/en/medicine/__init__.pydiff --git a/hyperextract/templates/en/tcm/__init__.py b/hyperextract/templates/legacy/en/news/__init__.pysimilarity index 100%rename from hyperextract/templates/en/tcm/__init__.pyrename to hyperextract/templates/legacy/en/news/__init__.pydiff --git a/hyperextract/templates/legacy/en/tcm/__init__.py b/hyperextract/templates/legacy/en/tcm/__init__.pynew file mode 100644index 0000000..e69de29diff --git a/hyperextract/templates/zh/INSTRUCTION.md b/hyperextract/templates/legacy/zh/INSTRUCTION.mdsimilarity index 100%rename from hyperextract/templates/zh/INSTRUCTION.mdrename to hyperextract/templates/legacy/zh/INSTRUCTION.mddiff --git a/hyperextract/templates/zh/__init__.py b/hyperextract/templates/legacy/zh/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/__init__.pyrename to hyperextract/templates/legacy/zh/__init__.pydiff --git a/hyperextract/templates/zh/agriculture/__init__.py b/hyperextract/templates/legacy/zh/agriculture/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/agriculture/__init__.pyrename to hyperextract/templates/legacy/zh/agriculture/__init__.pydiff --git a/hyperextract/templates/zh/agriculture/amendment_plan.py b/hyperextract/templates/legacy/zh/agriculture/amendment_plan.pysimilarity index 100%rename from hyperextract/templates/zh/agriculture/amendment_plan.pyrename to hyperextract/templates/legacy/zh/agriculture/amendment_plan.pydiff --git a/hyperextract/templates/zh/agriculture/crop_growth_cycle.py b/hyperextract/templates/legacy/zh/agriculture/crop_growth_cycle.pysimilarity index 100%rename from hyperextract/templates/zh/agriculture/crop_growth_cycle.pyrename to hyperextract/templates/legacy/zh/agriculture/crop_growth_cycle.pydiff --git a/hyperextract/templates/zh/agriculture/field_observation_list.py b/hyperextract/templates/legacy/zh/agriculture/field_observation_list.pysimilarity index 100%rename from hyperextract/templates/zh/agriculture/field_observation_list.pyrename to hyperextract/templates/legacy/zh/agriculture/field_observation_list.pydiff --git a/hyperextract/templates/zh/agriculture/pest_control_hypergraph.py b/hyperextract/templates/legacy/zh/agriculture/pest_control_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/agriculture/pest_control_hypergraph.pyrename to hyperextract/templates/legacy/zh/agriculture/pest_control_hypergraph.pydiff --git a/hyperextract/templates/zh/agriculture/soil_nutrient_model.py b/hyperextract/templates/legacy/zh/agriculture/soil_nutrient_model.pysimilarity index 100%rename from hyperextract/templates/zh/agriculture/soil_nutrient_model.pyrename to hyperextract/templates/legacy/zh/agriculture/soil_nutrient_model.pydiff --git a/hyperextract/templates/zh/biology/__init__.py b/hyperextract/templates/legacy/zh/biology/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/biology/__init__.pyrename to hyperextract/templates/legacy/zh/biology/__init__.pydiff --git a/hyperextract/templates/zh/biology/binding_site_model.py b/hyperextract/templates/legacy/zh/biology/binding_site_model.pysimilarity index 100%rename from hyperextract/templates/zh/biology/binding_site_model.pyrename to hyperextract/templates/legacy/zh/biology/binding_site_model.pydiff --git a/hyperextract/templates/zh/biology/biochemical_reaction_hypergraph.py b/hyperextract/templates/legacy/zh/biology/biochemical_reaction_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/biology/biochemical_reaction_hypergraph.pyrename to hyperextract/templates/legacy/zh/biology/biochemical_reaction_hypergraph.pydiff --git a/hyperextract/templates/zh/biology/biodiversity_registry.py b/hyperextract/templates/legacy/zh/biology/biodiversity_registry.pysimilarity index 100%rename from hyperextract/templates/zh/biology/biodiversity_registry.pyrename to hyperextract/templates/legacy/zh/biology/biodiversity_registry.pydiff --git a/hyperextract/templates/zh/biology/phylogenetic_relation_graph.py b/hyperextract/templates/legacy/zh/biology/phylogenetic_relation_graph.pysimilarity index 100%rename from hyperextract/templates/zh/biology/phylogenetic_relation_graph.pyrename to hyperextract/templates/legacy/zh/biology/phylogenetic_relation_graph.pydiff --git a/hyperextract/templates/zh/biology/protein_complex_map.py b/hyperextract/templates/legacy/zh/biology/protein_complex_map.pysimilarity index 100%rename from hyperextract/templates/zh/biology/protein_complex_map.pyrename to hyperextract/templates/legacy/zh/biology/protein_complex_map.pydiff --git a/hyperextract/templates/zh/biology/regulatory_network.py b/hyperextract/templates/legacy/zh/biology/regulatory_network.pysimilarity index 100%rename from hyperextract/templates/zh/biology/regulatory_network.pyrename to hyperextract/templates/legacy/zh/biology/regulatory_network.pydiff --git a/hyperextract/templates/zh/biology/species_interaction_web.py b/hyperextract/templates/legacy/zh/biology/species_interaction_web.pysimilarity index 100%rename from hyperextract/templates/zh/biology/species_interaction_web.pyrename to hyperextract/templates/legacy/zh/biology/species_interaction_web.pydiff --git a/hyperextract/templates/zh/biology/taxonomic_tree.py b/hyperextract/templates/legacy/zh/biology/taxonomic_tree.pysimilarity index 100%rename from hyperextract/templates/zh/biology/taxonomic_tree.pyrename to hyperextract/templates/legacy/zh/biology/taxonomic_tree.pydiff --git a/hyperextract/templates/zh/finance/__init__.py b/hyperextract/templates/legacy/zh/finance/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/finance/__init__.pyrename to hyperextract/templates/legacy/zh/finance/__init__.pydiff --git a/hyperextract/templates/zh/finance/call_sentiment_hypergraph.py b/hyperextract/templates/legacy/zh/finance/call_sentiment_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/finance/call_sentiment_hypergraph.pyrename to hyperextract/templates/legacy/zh/finance/call_sentiment_hypergraph.pydiff --git a/hyperextract/templates/zh/finance/company_history_timeline.py b/hyperextract/templates/legacy/zh/finance/company_history_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/finance/company_history_timeline.pyrename to hyperextract/templates/legacy/zh/finance/company_history_timeline.pydiff --git a/hyperextract/templates/zh/finance/discussion_graph.py b/hyperextract/templates/legacy/zh/finance/discussion_graph.pysimilarity index 100%rename from hyperextract/templates/zh/finance/discussion_graph.pyrename to hyperextract/templates/legacy/zh/finance/discussion_graph.pydiff --git a/hyperextract/templates/zh/finance/earnings_call_summary.py b/hyperextract/templates/legacy/zh/finance/earnings_call_summary.pysimilarity index 100%rename from hyperextract/templates/zh/finance/earnings_call_summary.pyrename to hyperextract/templates/legacy/zh/finance/earnings_call_summary.pydiff --git a/hyperextract/templates/zh/finance/factor_influence_hypergraph.py b/hyperextract/templates/legacy/zh/finance/factor_influence_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/finance/factor_influence_hypergraph.pyrename to hyperextract/templates/legacy/zh/finance/factor_influence_hypergraph.pydiff --git a/hyperextract/templates/zh/finance/filing_financial_snapshot.py b/hyperextract/templates/legacy/zh/finance/filing_financial_snapshot.pysimilarity index 100%rename from hyperextract/templates/zh/finance/filing_financial_snapshot.pyrename to hyperextract/templates/legacy/zh/finance/filing_financial_snapshot.pydiff --git a/hyperextract/templates/zh/finance/filing_risk_factor_set.py b/hyperextract/templates/legacy/zh/finance/filing_risk_factor_set.pysimilarity index 100%rename from hyperextract/templates/zh/finance/filing_risk_factor_set.pyrename to hyperextract/templates/legacy/zh/finance/filing_risk_factor_set.pydiff --git a/hyperextract/templates/zh/finance/financial_data_temporal_graph.py b/hyperextract/templates/legacy/zh/finance/financial_data_temporal_graph.pysimilarity index 100%rename from hyperextract/templates/zh/finance/financial_data_temporal_graph.pyrename to hyperextract/templates/legacy/zh/finance/financial_data_temporal_graph.pydiff --git a/hyperextract/templates/zh/finance/financial_event_causal_graph.py b/hyperextract/templates/legacy/zh/finance/financial_event_causal_graph.pysimilarity index 100%rename from hyperextract/templates/zh/finance/financial_event_causal_graph.pyrename to hyperextract/templates/legacy/zh/finance/financial_event_causal_graph.pydiff --git a/hyperextract/templates/zh/finance/financial_forecast.py b/hyperextract/templates/legacy/zh/finance/financial_forecast.pysimilarity index 100%rename from hyperextract/templates/zh/finance/financial_forecast.pyrename to hyperextract/templates/legacy/zh/finance/financial_forecast.pydiff --git a/hyperextract/templates/zh/finance/management_guidance_list.py b/hyperextract/templates/legacy/zh/finance/management_guidance_list.pysimilarity index 100%rename from hyperextract/templates/zh/finance/management_guidance_list.pyrename to hyperextract/templates/legacy/zh/finance/management_guidance_list.pydiff --git a/hyperextract/templates/zh/finance/market_narrative_timeline.py b/hyperextract/templates/legacy/zh/finance/market_narrative_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/finance/market_narrative_timeline.pyrename to hyperextract/templates/legacy/zh/finance/market_narrative_timeline.pydiff --git a/hyperextract/templates/zh/finance/market_sentiment_model.py b/hyperextract/templates/legacy/zh/finance/market_sentiment_model.pysimilarity index 100%rename from hyperextract/templates/zh/finance/market_sentiment_model.pyrename to hyperextract/templates/legacy/zh/finance/market_sentiment_model.pydiff --git a/hyperextract/templates/zh/finance/material_event_timeline.py b/hyperextract/templates/legacy/zh/finance/material_event_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/finance/material_event_timeline.pyrename to hyperextract/templates/legacy/zh/finance/material_event_timeline.pydiff --git a/hyperextract/templates/zh/finance/mda_narrative_graph.py b/hyperextract/templates/legacy/zh/finance/mda_narrative_graph.pysimilarity index 100%rename from hyperextract/templates/zh/finance/mda_narrative_graph.pyrename to hyperextract/templates/legacy/zh/finance/mda_narrative_graph.pydiff --git a/hyperextract/templates/zh/finance/multi_source_sentiment_hypergraph.py b/hyperextract/templates/legacy/zh/finance/multi_source_sentiment_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/finance/multi_source_sentiment_hypergraph.pyrename to hyperextract/templates/legacy/zh/finance/multi_source_sentiment_hypergraph.pydiff --git a/hyperextract/templates/zh/finance/proceeds_usage.py b/hyperextract/templates/legacy/zh/finance/proceeds_usage.pysimilarity index 100%rename from hyperextract/templates/zh/finance/proceeds_usage.pyrename to hyperextract/templates/legacy/zh/finance/proceeds_usage.pydiff --git a/hyperextract/templates/zh/finance/research_note_summary.py b/hyperextract/templates/legacy/zh/finance/research_note_summary.pysimilarity index 100%rename from hyperextract/templates/zh/finance/research_note_summary.pyrename to hyperextract/templates/legacy/zh/finance/research_note_summary.pydiff --git a/hyperextract/templates/zh/finance/risk_assessment.py b/hyperextract/templates/legacy/zh/finance/risk_assessment.pysimilarity index 100%rename from hyperextract/templates/zh/finance/risk_assessment.pyrename to hyperextract/templates/legacy/zh/finance/risk_assessment.pydiff --git a/hyperextract/templates/zh/finance/risk_factor_list.py b/hyperextract/templates/legacy/zh/finance/risk_factor_list.pysimilarity index 100%rename from hyperextract/templates/zh/finance/risk_factor_list.pyrename to hyperextract/templates/legacy/zh/finance/risk_factor_list.pydiff --git a/hyperextract/templates/zh/finance/segment_performance_list.py b/hyperextract/templates/legacy/zh/finance/segment_performance_list.pysimilarity index 100%rename from hyperextract/templates/zh/finance/segment_performance_list.pyrename to hyperextract/templates/legacy/zh/finance/segment_performance_list.pydiff --git a/hyperextract/templates/zh/finance/shareholder_structure.py b/hyperextract/templates/legacy/zh/finance/shareholder_structure.pysimilarity index 100%rename from hyperextract/templates/zh/finance/shareholder_structure.pyrename to hyperextract/templates/legacy/zh/finance/shareholder_structure.pydiff --git a/hyperextract/templates/zh/finance/supply_chain.py b/hyperextract/templates/legacy/zh/finance/supply_chain.pysimilarity index 100%rename from hyperextract/templates/zh/finance/supply_chain.pyrename to hyperextract/templates/legacy/zh/finance/supply_chain.pydiff --git a/hyperextract/templates/zh/finance/valuation_logic_map.py b/hyperextract/templates/legacy/zh/finance/valuation_logic_map.pysimilarity index 100%rename from hyperextract/templates/zh/finance/valuation_logic_map.pyrename to hyperextract/templates/legacy/zh/finance/valuation_logic_map.pydiff --git a/hyperextract/templates/zh/food/__init__.py b/hyperextract/templates/legacy/zh/food/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/food/__init__.pyrename to hyperextract/templates/legacy/zh/food/__init__.pydiff --git a/hyperextract/templates/zh/food/dish_review_summary.py b/hyperextract/templates/legacy/zh/food/dish_review_summary.pysimilarity index 100%rename from hyperextract/templates/zh/food/dish_review_summary.pyrename to hyperextract/templates/legacy/zh/food/dish_review_summary.pydiff --git a/hyperextract/templates/zh/food/ingredient_composition_hypergraph.py b/hyperextract/templates/legacy/zh/food/ingredient_composition_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/food/ingredient_composition_hypergraph.pyrename to hyperextract/templates/legacy/zh/food/ingredient_composition_hypergraph.pydiff --git a/hyperextract/templates/zh/food/recipe_collection.py b/hyperextract/templates/legacy/zh/food/recipe_collection.pysimilarity index 100%rename from hyperextract/templates/zh/food/recipe_collection.pyrename to hyperextract/templates/legacy/zh/food/recipe_collection.pydiff --git a/hyperextract/templates/zh/food/sensory_evaluation_graph.py b/hyperextract/templates/legacy/zh/food/sensory_evaluation_graph.pysimilarity index 100%rename from hyperextract/templates/zh/food/sensory_evaluation_graph.pyrename to hyperextract/templates/legacy/zh/food/sensory_evaluation_graph.pydiff --git a/hyperextract/templates/zh/food/standard_recipe_card.py b/hyperextract/templates/legacy/zh/food/standard_recipe_card.pysimilarity index 100%rename from hyperextract/templates/zh/food/standard_recipe_card.pyrename to hyperextract/templates/legacy/zh/food/standard_recipe_card.pydiff --git a/hyperextract/templates/zh/general/__init__.py b/hyperextract/templates/legacy/zh/general/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/general/__init__.pyrename to hyperextract/templates/legacy/zh/general/__init__.pydiff --git a/hyperextract/templates/zh/general/clause_list.py b/hyperextract/templates/legacy/zh/general/clause_list.pysimilarity index 100%rename from hyperextract/templates/zh/general/clause_list.pyrename to hyperextract/templates/legacy/zh/general/clause_list.pydiff --git a/hyperextract/templates/zh/general/compliance_logic.py b/hyperextract/templates/legacy/zh/general/compliance_logic.pysimilarity index 100%rename from hyperextract/templates/zh/general/compliance_logic.pyrename to hyperextract/templates/legacy/zh/general/compliance_logic.pydiff --git a/hyperextract/templates/zh/general/concept_hierarchy.py b/hyperextract/templates/legacy/zh/general/concept_hierarchy.pysimilarity index 100%rename from hyperextract/templates/zh/general/concept_hierarchy.pyrename to hyperextract/templates/legacy/zh/general/concept_hierarchy.pydiff --git a/hyperextract/templates/zh/general/cross_reference_net.py b/hyperextract/templates/legacy/zh/general/cross_reference_net.pysimilarity index 100%rename from hyperextract/templates/zh/general/cross_reference_net.pyrename to hyperextract/templates/legacy/zh/general/cross_reference_net.pydiff --git a/hyperextract/templates/zh/general/encyclopedia_item.py b/hyperextract/templates/legacy/zh/general/encyclopedia_item.pysimilarity index 100%rename from hyperextract/templates/zh/general/encyclopedia_item.pyrename to hyperextract/templates/legacy/zh/general/encyclopedia_item.pydiff --git a/hyperextract/templates/zh/general/entity_registry.py b/hyperextract/templates/legacy/zh/general/entity_registry.pysimilarity index 100%rename from hyperextract/templates/zh/general/entity_registry.pyrename to hyperextract/templates/legacy/zh/general/entity_registry.pydiff --git a/hyperextract/templates/zh/general/keyword_list.py b/hyperextract/templates/legacy/zh/general/keyword_list.pysimilarity index 100%rename from hyperextract/templates/zh/general/keyword_list.pyrename to hyperextract/templates/legacy/zh/general/keyword_list.pydiff --git a/hyperextract/templates/zh/general/knowledge_graph.py b/hyperextract/templates/legacy/zh/general/knowledge_graph.pysimilarity index 100%rename from hyperextract/templates/zh/general/knowledge_graph.pyrename to hyperextract/templates/legacy/zh/general/knowledge_graph.pydiff --git a/hyperextract/templates/zh/general/life_event_timeline.py b/hyperextract/templates/legacy/zh/general/life_event_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/general/life_event_timeline.pyrename to hyperextract/templates/legacy/zh/general/life_event_timeline.pydiff --git a/hyperextract/templates/zh/general/operational_procedure.py b/hyperextract/templates/legacy/zh/general/operational_procedure.pysimilarity index 100%rename from hyperextract/templates/zh/general/operational_procedure.pyrename to hyperextract/templates/legacy/zh/general/operational_procedure.pydiff --git a/hyperextract/templates/zh/general/penalty_mapping.py b/hyperextract/templates/legacy/zh/general/penalty_mapping.pysimilarity index 100%rename from hyperextract/templates/zh/general/penalty_mapping.pyrename to hyperextract/templates/legacy/zh/general/penalty_mapping.pydiff --git a/hyperextract/templates/zh/general/penalty_registry.py b/hyperextract/templates/legacy/zh/general/penalty_registry.pysimilarity index 100%rename from hyperextract/templates/zh/general/penalty_registry.pyrename to hyperextract/templates/legacy/zh/general/penalty_registry.pydiff --git a/hyperextract/templates/zh/general/personal_profile.py b/hyperextract/templates/legacy/zh/general/personal_profile.pysimilarity index 100%rename from hyperextract/templates/zh/general/personal_profile.pyrename to hyperextract/templates/legacy/zh/general/personal_profile.pydiff --git a/hyperextract/templates/zh/general/regulation_profile.py b/hyperextract/templates/legacy/zh/general/regulation_profile.pysimilarity index 100%rename from hyperextract/templates/zh/general/regulation_profile.pyrename to hyperextract/templates/legacy/zh/general/regulation_profile.pydiff --git a/hyperextract/templates/zh/general/social_network.py b/hyperextract/templates/legacy/zh/general/social_network.pysimilarity index 100%rename from hyperextract/templates/zh/general/social_network.pyrename to hyperextract/templates/legacy/zh/general/social_network.pydiff --git a/hyperextract/templates/zh/history/__init__.py b/hyperextract/templates/legacy/zh/history/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/history/__init__.pyrename to hyperextract/templates/legacy/zh/history/__init__.pydiff --git a/hyperextract/templates/zh/history/chronological_event_chain.py b/hyperextract/templates/legacy/zh/history/chronological_event_chain.pysimilarity index 100%rename from hyperextract/templates/zh/history/chronological_event_chain.pyrename to hyperextract/templates/legacy/zh/history/chronological_event_chain.pydiff --git a/hyperextract/templates/zh/history/epistolary_knowledge_graph.py b/hyperextract/templates/legacy/zh/history/epistolary_knowledge_graph.pysimilarity index 100%rename from hyperextract/templates/zh/history/epistolary_knowledge_graph.pyrename to hyperextract/templates/legacy/zh/history/epistolary_knowledge_graph.pydiff --git a/hyperextract/templates/zh/history/historical_context_graph.py b/hyperextract/templates/legacy/zh/history/historical_context_graph.pysimilarity index 100%rename from hyperextract/templates/zh/history/historical_context_graph.pyrename to hyperextract/templates/legacy/zh/history/historical_context_graph.pydiff --git a/hyperextract/templates/zh/history/historical_knowledge_graph.py b/hyperextract/templates/legacy/zh/history/historical_knowledge_graph.pysimilarity index 100%rename from hyperextract/templates/zh/history/historical_knowledge_graph.pyrename to hyperextract/templates/legacy/zh/history/historical_knowledge_graph.pydiff --git a/hyperextract/templates/zh/history/memory_flashback_list.py b/hyperextract/templates/legacy/zh/history/memory_flashback_list.pysimilarity index 100%rename from hyperextract/templates/zh/history/memory_flashback_list.pyrename to hyperextract/templates/legacy/zh/history/memory_flashback_list.pydiff --git a/hyperextract/templates/zh/history/multi_participant_event_map.py b/hyperextract/templates/legacy/zh/history/multi_participant_event_map.pysimilarity index 100%rename from hyperextract/templates/zh/history/multi_participant_event_map.pyrename to hyperextract/templates/legacy/zh/history/multi_participant_event_map.pydiff --git a/hyperextract/templates/zh/history/narrative_relation_graph.py b/hyperextract/templates/legacy/zh/history/narrative_relation_graph.pysimilarity index 100%rename from hyperextract/templates/zh/history/narrative_relation_graph.pyrename to hyperextract/templates/legacy/zh/history/narrative_relation_graph.pydiff --git a/hyperextract/templates/zh/history/personal_trajectory_hypergraph.py b/hyperextract/templates/legacy/zh/history/personal_trajectory_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/history/personal_trajectory_hypergraph.pyrename to hyperextract/templates/legacy/zh/history/personal_trajectory_hypergraph.pydiff --git a/hyperextract/templates/zh/history/political_struggle_hypergraph.py b/hyperextract/templates/legacy/zh/history/political_struggle_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/history/political_struggle_hypergraph.pyrename to hyperextract/templates/legacy/zh/history/political_struggle_hypergraph.pydiff --git a/hyperextract/templates/zh/industry/__init__.py b/hyperextract/templates/legacy/zh/industry/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/industry/__init__.pyrename to hyperextract/templates/legacy/zh/industry/__init__.pydiff --git a/hyperextract/templates/zh/industry/emergency_response_graph.py b/hyperextract/templates/legacy/zh/industry/emergency_response_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/emergency_response_graph.pyrename to hyperextract/templates/legacy/zh/industry/emergency_response_graph.pydiff --git a/hyperextract/templates/zh/industry/equipment_topology_graph.py b/hyperextract/templates/legacy/zh/industry/equipment_topology_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/equipment_topology_graph.pyrename to hyperextract/templates/legacy/zh/industry/equipment_topology_graph.pydiff --git a/hyperextract/templates/zh/industry/failure_case_graph.py b/hyperextract/templates/legacy/zh/industry/failure_case_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/failure_case_graph.pyrename to hyperextract/templates/legacy/zh/industry/failure_case_graph.pydiff --git a/hyperextract/templates/zh/industry/failure_knowledge_hypergraph.py b/hyperextract/templates/legacy/zh/industry/failure_knowledge_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/failure_knowledge_hypergraph.pyrename to hyperextract/templates/legacy/zh/industry/failure_knowledge_hypergraph.pydiff --git a/hyperextract/templates/zh/industry/incident_causality_map.py b/hyperextract/templates/legacy/zh/industry/incident_causality_map.pysimilarity index 100%rename from hyperextract/templates/zh/industry/incident_causality_map.pyrename to hyperextract/templates/legacy/zh/industry/incident_causality_map.pydiff --git a/hyperextract/templates/zh/industry/inspection_record_graph.py b/hyperextract/templates/legacy/zh/industry/inspection_record_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/inspection_record_graph.pyrename to hyperextract/templates/legacy/zh/industry/inspection_record_graph.pydiff --git a/hyperextract/templates/zh/industry/maintenace_operation_map.py b/hyperextract/templates/legacy/zh/industry/maintenace_operation_map.pysimilarity index 100%rename from hyperextract/templates/zh/industry/maintenace_operation_map.pyrename to hyperextract/templates/legacy/zh/industry/maintenace_operation_map.pydiff --git a/hyperextract/templates/zh/industry/operating_mode_graph.py b/hyperextract/templates/legacy/zh/industry/operating_mode_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/operating_mode_graph.pyrename to hyperextract/templates/legacy/zh/industry/operating_mode_graph.pydiff --git a/hyperextract/templates/zh/industry/operation_flow_graph.py b/hyperextract/templates/legacy/zh/industry/operation_flow_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/operation_flow_graph.pyrename to hyperextract/templates/legacy/zh/industry/operation_flow_graph.pydiff --git a/hyperextract/templates/zh/industry/part_replacement_list.py b/hyperextract/templates/legacy/zh/industry/part_replacement_list.pysimilarity index 100%rename from hyperextract/templates/zh/industry/part_replacement_list.pyrename to hyperextract/templates/legacy/zh/industry/part_replacement_list.pydiff --git a/hyperextract/templates/zh/industry/safety_control_graph.py b/hyperextract/templates/legacy/zh/industry/safety_control_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/safety_control_graph.pyrename to hyperextract/templates/legacy/zh/industry/safety_control_graph.pydiff --git a/hyperextract/templates/zh/industry/safety_timeline.py b/hyperextract/templates/legacy/zh/industry/safety_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/industry/safety_timeline.pyrename to hyperextract/templates/legacy/zh/industry/safety_timeline.pydiff --git a/hyperextract/templates/zh/industry/spec_parameter_table.py b/hyperextract/templates/legacy/zh/industry/spec_parameter_table.pysimilarity index 100%rename from hyperextract/templates/zh/industry/spec_parameter_table.pyrename to hyperextract/templates/legacy/zh/industry/spec_parameter_table.pydiff --git a/hyperextract/templates/zh/industry/system_compatibility_graph.py b/hyperextract/templates/legacy/zh/industry/system_compatibility_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/system_compatibility_graph.pyrename to hyperextract/templates/legacy/zh/industry/system_compatibility_graph.pydiff --git a/hyperextract/templates/zh/industry/system_topology_graph.py b/hyperextract/templates/legacy/zh/industry/system_topology_graph.pysimilarity index 100%rename from hyperextract/templates/zh/industry/system_topology_graph.pyrename to hyperextract/templates/legacy/zh/industry/system_topology_graph.pydiff --git a/hyperextract/templates/zh/legal/__init__.py b/hyperextract/templates/legacy/zh/legal/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/legal/__init__.pyrename to hyperextract/templates/legacy/zh/legal/__init__.pydiff --git a/hyperextract/templates/zh/legal/adjudication_logic.py b/hyperextract/templates/legacy/zh/legal/adjudication_logic.pysimilarity index 100%rename from hyperextract/templates/zh/legal/adjudication_logic.pyrename to hyperextract/templates/legacy/zh/legal/adjudication_logic.pydiff --git a/hyperextract/templates/zh/legal/beneficial_ownership_graph.py b/hyperextract/templates/legacy/zh/legal/beneficial_ownership_graph.pysimilarity index 100%rename from hyperextract/templates/zh/legal/beneficial_ownership_graph.pyrename to hyperextract/templates/legacy/zh/legal/beneficial_ownership_graph.pydiff --git a/hyperextract/templates/zh/legal/case_fact_timeline.py b/hyperextract/templates/legacy/zh/legal/case_fact_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/legal/case_fact_timeline.pyrename to hyperextract/templates/legacy/zh/legal/case_fact_timeline.pydiff --git a/hyperextract/templates/zh/legal/case_law_citation_net.py b/hyperextract/templates/legacy/zh/legal/case_law_citation_net.pysimilarity index 100%rename from hyperextract/templates/zh/legal/case_law_citation_net.pyrename to hyperextract/templates/legacy/zh/legal/case_law_citation_net.pydiff --git a/hyperextract/templates/zh/legal/compliance_requirement_list.py b/hyperextract/templates/legacy/zh/legal/compliance_requirement_list.pysimilarity index 100%rename from hyperextract/templates/zh/legal/compliance_requirement_list.pyrename to hyperextract/templates/legacy/zh/legal/compliance_requirement_list.pydiff --git a/hyperextract/templates/zh/legal/contract_obligation_hypergraph.py b/hyperextract/templates/legacy/zh/legal/contract_obligation_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/legal/contract_obligation_hypergraph.pyrename to hyperextract/templates/legacy/zh/legal/contract_obligation_hypergraph.pydiff --git a/hyperextract/templates/zh/legal/defined_term_registry.py b/hyperextract/templates/legacy/zh/legal/defined_term_registry.pysimilarity index 100%rename from hyperextract/templates/zh/legal/defined_term_registry.pyrename to hyperextract/templates/legacy/zh/legal/defined_term_registry.pydiff --git a/hyperextract/templates/zh/legal/legal_concept_ontology.py b/hyperextract/templates/legacy/zh/legal/legal_concept_ontology.pysimilarity index 100%rename from hyperextract/templates/zh/legal/legal_concept_ontology.pyrename to hyperextract/templates/legacy/zh/legal/legal_concept_ontology.pydiff --git a/hyperextract/templates/zh/legal/liability_clause_list.py b/hyperextract/templates/legacy/zh/legal/liability_clause_list.pysimilarity index 100%rename from hyperextract/templates/zh/legal/liability_clause_list.pyrename to hyperextract/templates/legacy/zh/legal/liability_clause_list.pydiff --git a/hyperextract/templates/zh/legal/litigation_participant_map.py b/hyperextract/templates/legacy/zh/legal/litigation_participant_map.pysimilarity index 100%rename from hyperextract/templates/zh/legal/litigation_participant_map.pyrename to hyperextract/templates/legacy/zh/legal/litigation_participant_map.pydiff --git a/hyperextract/templates/zh/literature/__init__.py b/hyperextract/templates/legacy/zh/literature/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/literature/__init__.pyrename to hyperextract/templates/legacy/zh/literature/__init__.pydiff --git a/hyperextract/templates/zh/literature/character_arc_timeline.py b/hyperextract/templates/legacy/zh/literature/character_arc_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/literature/character_arc_timeline.pyrename to hyperextract/templates/legacy/zh/literature/character_arc_timeline.pydiff --git a/hyperextract/templates/zh/literature/complex_character_relation.py b/hyperextract/templates/legacy/zh/literature/complex_character_relation.pysimilarity index 100%rename from hyperextract/templates/zh/literature/complex_character_relation.pyrename to hyperextract/templates/legacy/zh/literature/complex_character_relation.pydiff --git a/hyperextract/templates/zh/literature/critique_argument_hypergraph.py b/hyperextract/templates/legacy/zh/literature/critique_argument_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/literature/critique_argument_hypergraph.pyrename to hyperextract/templates/legacy/zh/literature/critique_argument_hypergraph.pydiff --git a/hyperextract/templates/zh/literature/motif_association_net.py b/hyperextract/templates/legacy/zh/literature/motif_association_net.pysimilarity index 100%rename from hyperextract/templates/zh/literature/motif_association_net.pyrename to hyperextract/templates/legacy/zh/literature/motif_association_net.pydiff --git a/hyperextract/templates/zh/literature/narrative_event_chain.py b/hyperextract/templates/legacy/zh/literature/narrative_event_chain.pysimilarity index 100%rename from hyperextract/templates/zh/literature/narrative_event_chain.pyrename to hyperextract/templates/legacy/zh/literature/narrative_event_chain.pydiff --git a/hyperextract/templates/zh/literature/narrative_structure_tree.py b/hyperextract/templates/legacy/zh/literature/narrative_structure_tree.pysimilarity index 100%rename from hyperextract/templates/zh/literature/narrative_structure_tree.pyrename to hyperextract/templates/legacy/zh/literature/narrative_structure_tree.pydiff --git a/hyperextract/templates/zh/literature/scene_event_hypergraph.py b/hyperextract/templates/legacy/zh/literature/scene_event_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/literature/scene_event_hypergraph.pyrename to hyperextract/templates/legacy/zh/literature/scene_event_hypergraph.pydiff --git a/hyperextract/templates/zh/literature/story_entity_graph.py b/hyperextract/templates/legacy/zh/literature/story_entity_graph.pysimilarity index 100%rename from hyperextract/templates/zh/literature/story_entity_graph.pyrename to hyperextract/templates/legacy/zh/literature/story_entity_graph.pydiff --git a/hyperextract/templates/legacy/zh/medicine/__init__.py b/hyperextract/templates/legacy/zh/medicine/__init__.pynew file mode 100644index 0000000..2358c9d--- /dev/null+++ b/hyperextract/templates/legacy/zh/medicine/__init__.py@@ -0,0 +1,42 @@+"""医学领域知识模板"""++from hyperextract.templates.legacy.zh.medicine.pathology_hypergraph import PathologyHypergraph+from hyperextract.templates.legacy.zh.medicine.medical_concept_net import MedicalConceptNet+from hyperextract.templates.legacy.zh.medicine.pharmacology_graph import PharmacologyGraph+from hyperextract.templates.legacy.zh.medicine.anatomy_hierarchy import AnatomyHierarchy+from hyperextract.templates.legacy.zh.medicine.symptom_differential import SymptomDifferential+from hyperextract.templates.legacy.zh.medicine.treatment_regimen_map import TreatmentRegimenMap+from hyperextract.templates.legacy.zh.medicine.clinical_pathway import ClinicalPathway+from hyperextract.templates.legacy.zh.medicine.level_of_evidence import LevelOfEvidence+from hyperextract.templates.legacy.zh.medicine.surgical_event_graph import SurgicalEventGraph+from hyperextract.templates.legacy.zh.medicine.hospital_course_timeline import HospitalCourseTimeline+from hyperextract.templates.legacy.zh.medicine.discharge_instruction import DischargeInstruction+from hyperextract.templates.legacy.zh.medicine.tumor_staging_item import TumorStagingItem+from hyperextract.templates.legacy.zh.medicine.microscopic_feature_set import MicroscopicFeatureSet+from hyperextract.templates.legacy.zh.medicine.complex_interaction_net import ComplexInteractionNet+from hyperextract.templates.legacy.zh.medicine.contraindication_list import ContraindicationList+from hyperextract.templates.legacy.zh.medicine.adverse_reaction_stats import AdverseReactionStats++__all__ = [+ # 医学教科书与专著+ "PathologyHypergraph",+ "MedicalConceptNet",+ "PharmacologyGraph",+ "AnatomyHierarchy",+ "SymptomDifferential",+ # 临床诊疗指南+ "TreatmentRegimenMap",+ "ClinicalPathway",+ "LevelOfEvidence",+ # 出院小结+ "SurgicalEventGraph",+ "HospitalCourseTimeline",+ "DischargeInstruction",+ # 病理报告+ "TumorStagingItem",+ "MicroscopicFeatureSet",+ # 药品说明书+ "ComplexInteractionNet",+ "ContraindicationList",+ "AdverseReactionStats",+]\ No newline at end of filediff --git a/hyperextract/templates/zh/medicine/adverse_reaction_stats.py b/hyperextract/templates/legacy/zh/medicine/adverse_reaction_stats.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/adverse_reaction_stats.pyrename to hyperextract/templates/legacy/zh/medicine/adverse_reaction_stats.pydiff --git a/hyperextract/templates/zh/medicine/anatomy_hierarchy.py b/hyperextract/templates/legacy/zh/medicine/anatomy_hierarchy.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/anatomy_hierarchy.pyrename to hyperextract/templates/legacy/zh/medicine/anatomy_hierarchy.pydiff --git a/hyperextract/templates/zh/medicine/clinical_pathway.py b/hyperextract/templates/legacy/zh/medicine/clinical_pathway.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/clinical_pathway.pyrename to hyperextract/templates/legacy/zh/medicine/clinical_pathway.pydiff --git a/hyperextract/templates/zh/medicine/complex_interaction_net.py b/hyperextract/templates/legacy/zh/medicine/complex_interaction_net.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/complex_interaction_net.pyrename to hyperextract/templates/legacy/zh/medicine/complex_interaction_net.pydiff --git a/hyperextract/templates/zh/medicine/contraindication_list.py b/hyperextract/templates/legacy/zh/medicine/contraindication_list.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/contraindication_list.pyrename to hyperextract/templates/legacy/zh/medicine/contraindication_list.pydiff --git a/hyperextract/templates/zh/medicine/discharge_instruction.py b/hyperextract/templates/legacy/zh/medicine/discharge_instruction.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/discharge_instruction.pyrename to hyperextract/templates/legacy/zh/medicine/discharge_instruction.pydiff --git a/hyperextract/templates/zh/medicine/hospital_course_timeline.py b/hyperextract/templates/legacy/zh/medicine/hospital_course_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/hospital_course_timeline.pyrename to hyperextract/templates/legacy/zh/medicine/hospital_course_timeline.pydiff --git a/hyperextract/templates/zh/medicine/level_of_evidence.py b/hyperextract/templates/legacy/zh/medicine/level_of_evidence.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/level_of_evidence.pyrename to hyperextract/templates/legacy/zh/medicine/level_of_evidence.pydiff --git a/hyperextract/templates/zh/medicine/medical_concept_net.py b/hyperextract/templates/legacy/zh/medicine/medical_concept_net.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/medical_concept_net.pyrename to hyperextract/templates/legacy/zh/medicine/medical_concept_net.pydiff --git a/hyperextract/templates/zh/medicine/microscopic_feature_set.py b/hyperextract/templates/legacy/zh/medicine/microscopic_feature_set.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/microscopic_feature_set.pyrename to hyperextract/templates/legacy/zh/medicine/microscopic_feature_set.pydiff --git a/hyperextract/templates/zh/medicine/pathology_hypergraph.py b/hyperextract/templates/legacy/zh/medicine/pathology_hypergraph.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/pathology_hypergraph.pyrename to hyperextract/templates/legacy/zh/medicine/pathology_hypergraph.pydiff --git a/hyperextract/templates/zh/medicine/pharmacology_graph.py b/hyperextract/templates/legacy/zh/medicine/pharmacology_graph.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/pharmacology_graph.pyrename to hyperextract/templates/legacy/zh/medicine/pharmacology_graph.pydiff --git a/hyperextract/templates/zh/medicine/surgical_event_graph.py b/hyperextract/templates/legacy/zh/medicine/surgical_event_graph.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/surgical_event_graph.pyrename to hyperextract/templates/legacy/zh/medicine/surgical_event_graph.pydiff --git a/hyperextract/templates/zh/medicine/symptom_differential.py b/hyperextract/templates/legacy/zh/medicine/symptom_differential.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/symptom_differential.pyrename to hyperextract/templates/legacy/zh/medicine/symptom_differential.pydiff --git a/hyperextract/templates/zh/medicine/treatment_regimen_map.py b/hyperextract/templates/legacy/zh/medicine/treatment_regimen_map.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/treatment_regimen_map.pyrename to hyperextract/templates/legacy/zh/medicine/treatment_regimen_map.pydiff --git a/hyperextract/templates/zh/medicine/tumor_staging_item.py b/hyperextract/templates/legacy/zh/medicine/tumor_staging_item.pysimilarity index 100%rename from hyperextract/templates/zh/medicine/tumor_staging_item.pyrename to hyperextract/templates/legacy/zh/medicine/tumor_staging_item.pydiff --git a/hyperextract/templates/zh/news/__init__.py b/hyperextract/templates/legacy/zh/news/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/news/__init__.pyrename to hyperextract/templates/legacy/zh/news/__init__.pydiff --git a/hyperextract/templates/zh/news/complex_relation_net.py b/hyperextract/templates/legacy/zh/news/complex_relation_net.pysimilarity index 100%rename from hyperextract/templates/zh/news/complex_relation_net.pyrename to hyperextract/templates/legacy/zh/news/complex_relation_net.pydiff --git a/hyperextract/templates/zh/news/impact_chain.py b/hyperextract/templates/legacy/zh/news/impact_chain.pysimilarity index 100%rename from hyperextract/templates/zh/news/impact_chain.pyrename to hyperextract/templates/legacy/zh/news/impact_chain.pydiff --git a/hyperextract/templates/zh/news/investigative_context_graph.py b/hyperextract/templates/legacy/zh/news/investigative_context_graph.pysimilarity index 100%rename from hyperextract/templates/zh/news/investigative_context_graph.pyrename to hyperextract/templates/legacy/zh/news/investigative_context_graph.pydiff --git a/hyperextract/templates/zh/news/key_event_sequence.py b/hyperextract/templates/legacy/zh/news/key_event_sequence.pysimilarity index 100%rename from hyperextract/templates/zh/news/key_event_sequence.pyrename to hyperextract/templates/legacy/zh/news/key_event_sequence.pydiff --git a/hyperextract/templates/zh/news/live_update_timeline.py b/hyperextract/templates/legacy/zh/news/live_update_timeline.pysimilarity index 100%rename from hyperextract/templates/zh/news/live_update_timeline.pyrename to hyperextract/templates/legacy/zh/news/live_update_timeline.pydiff --git a/hyperextract/templates/zh/news/news_entity_graph.py b/hyperextract/templates/legacy/zh/news/news_entity_graph.pysimilarity index 100%rename from hyperextract/templates/zh/news/news_entity_graph.pyrename to hyperextract/templates/legacy/zh/news/news_entity_graph.pydiff --git a/hyperextract/templates/zh/news/news_summary_model.py b/hyperextract/templates/legacy/zh/news/news_summary_model.pysimilarity index 100%rename from hyperextract/templates/zh/news/news_summary_model.pyrename to hyperextract/templates/legacy/zh/news/news_summary_model.pydiff --git a/hyperextract/templates/zh/news/viewpoint_structure.py b/hyperextract/templates/legacy/zh/news/viewpoint_structure.pysimilarity index 100%rename from hyperextract/templates/zh/news/viewpoint_structure.pyrename to hyperextract/templates/legacy/zh/news/viewpoint_structure.pydiff --git a/hyperextract/templates/zh/tcm/__init__.py b/hyperextract/templates/legacy/zh/tcm/__init__.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/__init__.pyrename to hyperextract/templates/legacy/zh/tcm/__init__.pydiff --git a/hyperextract/templates/zh/tcm/acupoint_location_map.py b/hyperextract/templates/legacy/zh/tcm/acupoint_location_map.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/acupoint_location_map.pyrename to hyperextract/templates/legacy/zh/tcm/acupoint_location_map.pydiff --git a/hyperextract/templates/zh/tcm/compatibility_net.py b/hyperextract/templates/legacy/zh/tcm/compatibility_net.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/compatibility_net.pyrename to hyperextract/templates/legacy/zh/tcm/compatibility_net.pydiff --git a/hyperextract/templates/zh/tcm/formula_composition.py b/hyperextract/templates/legacy/zh/tcm/formula_composition.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/formula_composition.pyrename to hyperextract/templates/legacy/zh/tcm/formula_composition.pydiff --git a/hyperextract/templates/zh/tcm/function_indication_map.py b/hyperextract/templates/legacy/zh/tcm/function_indication_map.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/function_indication_map.pyrename to hyperextract/templates/legacy/zh/tcm/function_indication_map.pydiff --git a/hyperextract/templates/zh/tcm/herb_property_model.py b/hyperextract/templates/legacy/zh/tcm/herb_property_model.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/herb_property_model.pyrename to hyperextract/templates/legacy/zh/tcm/herb_property_model.pydiff --git a/hyperextract/templates/zh/tcm/meridian_flow_graph.py b/hyperextract/templates/legacy/zh/tcm/meridian_flow_graph.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/meridian_flow_graph.pyrename to hyperextract/templates/legacy/zh/tcm/meridian_flow_graph.pydiff --git a/hyperextract/templates/zh/tcm/prescription_modification.py b/hyperextract/templates/legacy/zh/tcm/prescription_modification.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/prescription_modification.pyrename to hyperextract/templates/legacy/zh/tcm/prescription_modification.pydiff --git a/hyperextract/templates/zh/tcm/processing_method.py b/hyperextract/templates/legacy/zh/tcm/processing_method.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/processing_method.pyrename to hyperextract/templates/legacy/zh/tcm/processing_method.pydiff --git a/hyperextract/templates/zh/tcm/pulse_tongue_record.py b/hyperextract/templates/legacy/zh/tcm/pulse_tongue_record.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/pulse_tongue_record.pyrename to hyperextract/templates/legacy/zh/tcm/pulse_tongue_record.pydiff --git a/hyperextract/templates/zh/tcm/syndrome_reasoning_graph.py b/hyperextract/templates/legacy/zh/tcm/syndrome_reasoning_graph.pysimilarity index 100%rename from hyperextract/templates/zh/tcm/syndrome_reasoning_graph.pyrename to hyperextract/templates/legacy/zh/tcm/syndrome_reasoning_graph.pydiff --git a/hyperextract/templates/presets/agriculture/amendment_plan.yaml b/hyperextract/templates/presets/agriculture/amendment_plan.yamlnew file mode 100644index 0000000..e2a96a0--- /dev/null+++ b/hyperextract/templates/presets/agriculture/amendment_plan.yaml@@ -0,0 +1,80 @@+name: "AmendmentPlan"+autotype: graph+tag: [agriculture]++language: zh++description:+ zh: "改良方案图 - 从土壤改良方案报告中提取检测结果到改良措施的逻辑链条"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "节点名称(限制因子、改良措施、预期目标)"+ - name: node_type+ type: "string"+ description:+ zh: "节点类型:检测结果、限制因子、改良措施、预期目标"+ - name: description+ type: "string"+ description:+ zh: "详细描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源节点"+ - name: target+ type: "string"+ description:+ zh: "目标节点"+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型:针对、达成"+ - name: details+ type: "string"+ description:+ zh: "详细描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的土壤肥料专家,请从土壤改良方案报告中提取改良方案图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 边只能从已知实体列表中提取,不要创建未列出的实体+ 4. 关系描述应与原文保持一致++ rules_for_nodes:+ zh: |+ - 检测结果:如pH5.2、有机质18.5g/kg、有效磷12.3mg/kg等+ - 限制因子:如土壤酸化、磷钾缺乏、微量元素失衡、有机质不足+ - 改良措施:如施用生石灰、增施有机肥、施用复合肥等+ - 预期目标:如pH提高至6.0、有机质提升至22g/kg等++ rules_for_edges:+ zh: |+ - 关系类型"针对":表示改良措施针对某个限制因子+ - 关系类型"达成":表示预期目标与改良措施的关联++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({node_type})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/agriculture/crop_growth_cycle.yaml b/hyperextract/templates/presets/agriculture/crop_growth_cycle.yamlnew file mode 100644index 0000000..38cf5bf--- /dev/null+++ b/hyperextract/templates/presets/agriculture/crop_growth_cycle.yaml@@ -0,0 +1,93 @@+name: "CropGrowthCycle"+autotype: temporal_graph+tag: [agriculture]++language: zh++description:+ zh: "作物生长周期图 - 从农业技术手册中提取作物各生长阶段的农事操作与环境要求"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "节点名称"+ - name: category+ type: "string"+ description:+ zh: "节点类型:生长阶段、农事操作、环境条件"+ - name: description+ type: "string"+ description:+ zh: "详细描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源节点"+ - name: target+ type: "string"+ description:+ zh: "目标节点"+ - name: time+ type: "string"+ description:+ zh: "时间点或时间段"+ - name: description+ type: "string"+ description:+ zh: "关系描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的农业技术专家,请从农业技术手册中提取作物生长周期图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 边只能从已知实体列表中提取,不要创建未列出的实体+ 4. 关系描述应与原文保持一致++ rules_for_nodes:+ zh: |+ - 生长阶段:如播种期、幼苗期、分蘖期、孕穗抽穗期、灌浆成熟期+ - 农事操作:如苗床准备、种子处理、移栽、施肥、病虫害防治+ - 环境条件:如温度、湿度、光照、水分要求++ rules_for_edges:+ zh: |+ - 提取时间信息:时间范围描述、生长阶段名称、相对时间表达+ - 精确时间 → 保持原样,如"4月上旬"、"3叶1心期"+ - 生长阶段 → 视为时间标记,如"幼苗期"、"分蘖期"直接作为时间+ - 相对时间解析:基于观察日期进行偏移计算++ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 精确时间 → 保持原样,如"4月上旬"、"3叶1心期"+ 2. 生长阶段 → 视为时间标记,如"幼苗期"、"分蘖期"直接作为时间+ 3. 相对时间解析(基于观察日期):+ - "播种后5-7天" → 相对于播种期的时间偏移+ - "移栽后5-7天" → 相对于移栽期的时间偏移+ 4. 时间缺失 → 留空,不要猜测++identifiers:+ node_id: "name"+ edge_id: "{source}|{time}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "time"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{time}"diff --git a/hyperextract/templates/presets/agriculture/field_observation_list.yaml b/hyperextract/templates/presets/agriculture/field_observation_list.yamlnew file mode 100644index 0000000..111454e--- /dev/null+++ b/hyperextract/templates/presets/agriculture/field_observation_list.yaml@@ -0,0 +1,61 @@+name: "FieldObservationList"+autotype: list+tag: [agriculture]++language: zh++description:+ zh: "田间观测清单 - 从巡田报告中提取结构化的田间观测记录"++item_schema:+ fields:+ - name: plot_id+ type: "string"+ description:+ zh: "地块编号"+ - name: crop+ type: "string"+ description:+ zh: "作物种类和品种"+ - name: growth_stage+ type: "string"+ description:+ zh: "当前生长阶段"+ - name: observation_date+ type: "string"+ description:+ zh: "观测日期,统一格式为年-月-日(如2025-06-15)"+ - name: issues+ type: "array"+ description:+ zh: "观测到的问题列表,如杂草、虫害、病害、生长异常"+ - name: severity_level+ type: "string"+ description:+ zh: "严重等级:轻微、中等、严重"+ - name: recommendations+ type: "array"+ description:+ zh: "建议措施列表"++extraction_guide:+ target:+ zh: |+ 你是一位专业的农技人员,请从巡田报告中提取结构化的田间观测记录。++ rules:+ zh: |+ 1. 每个地块的观测记录提取为一个独立的条目+ 2. 问题列表和建议措施列表必须完整提取+ 3. 严重等级必须明确提取+ 4. 数据必须与原文保持一致,不得编造++ rules_for_nodes:+ zh: |+ - 地块编号:如D-001、A-12、光明村一组北畈等+ - 生长阶段:播种期、幼苗期、分蘖期、孕穗抽穗期、灌浆成熟期+ - 问题类型:杂草、虫害、病害、生长异常、肥害、药害+ - 严重等级:轻微(可忽略或轻微影响)、中等(需要关注或部分影响)、严重(必须处理或严重影响)++display:+ label: "plot_id"diff --git a/hyperextract/templates/presets/agriculture/pest_control_hypergraph.yaml b/hyperextract/templates/presets/agriculture/pest_control_hypergraph.yamlnew file mode 100644index 0000000..198ed24--- /dev/null+++ b/hyperextract/templates/presets/agriculture/pest_control_hypergraph.yaml@@ -0,0 +1,90 @@+name: "PestControlHypergraph"+autotype: hypergraph+tag: [agriculture]++language: zh++description:+ zh: "病虫害防治超图 - 从农业技术手册中提取病虫害与防治措施的复杂关联关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(病虫害名、药剂名、作物名、生长阶段名)"+ - name: entity_type+ type: "string"+ description:+ zh: "实体类型:病虫害、药剂、作物、生长阶段"+ - name: description+ type: "string"+ description:+ zh: "详细描述"++edge_schema:+ fields:+ - name: crop+ type: "string"+ description:+ zh: "作物名称"+ - name: stage+ type: "string"+ description:+ zh: "生长阶段"+ - name: pest+ type: "string"+ description:+ zh: "病虫害名称"+ - name: pesticide+ type: "string"+ description:+ zh: "推荐药剂"+ - name: dosage+ type: "string"+ description:+ zh: "亩用量"+ - name: safety_interval+ type: "string"+ description:+ zh: "安全间隔期"++extraction_guide:+ target:+ zh: |+ 你是一位专业的植物保护专家,请从农业技术手册中提取病虫害防治超图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边连接作物、生长阶段、病虫害、药剂等多类实体+ 4. 每条超边必须包含作物、生长阶段、病虫害、药剂等要素++ rules_for_nodes:+ zh: |+ - 病虫害:如稻飞虱、稻纵卷叶螟、纹枯病、稻瘟病+ - 药剂:如25%噻嗪酮可湿性粉剂、20%氯虫苯甲酰胺悬浮剂+ - 作物:如水稻、小麦、玉米+ - 生长阶段:如播种期、分蘖期、孕穗期、灌浆期++ rules_for_edges:+ zh: |+ - 超边格式:《作物 + 生长阶段 + 病虫害 -> 药剂 + 剂量 + 安全间隔期》+ - 病虫害名称保持原文+ - 药剂名称保持原文,包括商品名和有效成分+ - 安全间隔期:最后一次施药至收获的天数++identifiers:+ node_id: "name"+ edge_id: "{crop}_{stage}_{pest}_{pesticide}"+ edge_members:+ source: "crop"+ target: "pest"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({entity_type})"+ edge_label: "crop"diff --git a/hyperextract/templates/presets/agriculture/soil_nutrient_model.yaml b/hyperextract/templates/presets/agriculture/soil_nutrient_model.yamlnew file mode 100644index 0000000..df97a3a--- /dev/null+++ b/hyperextract/templates/presets/agriculture/soil_nutrient_model.yaml@@ -0,0 +1,131 @@+name: "SoilNutrientModel"+autotype: model+tag: [agriculture]++language: zh++description:+ zh: "土壤养分模型 - 从土壤检测报告中提取核心理化指标"++schema:+ fields:+ - name: plot_id+ type: "string"+ description:+ zh: "地块编号"+ - name: soil_type+ type: "string"+ description:+ zh: "土壤类型"+ required: false+ - name: ph+ type: "float"+ description:+ zh: "pH值"+ required: false+ - name: ph_level+ type: "string"+ description:+ zh: "pH丰缺等级:酸性、弱酸性、中性、弱碱性、碱性"+ required: false+ - name: organic_matter+ type: "float"+ description:+ zh: "有机质含量,单位g/kg"+ required: false+ - name: organic_matter_level+ type: "string"+ description:+ zh: "有机质丰缺等级"+ required: false+ - name: nitrogen+ type: "float"+ description:+ zh: "碱解氮含量,单位mg/kg"+ required: false+ - name: nitrogen_level+ type: "string"+ description:+ zh: "氮素丰缺等级"+ required: false+ - name: phosphorus+ type: "float"+ description:+ zh: "有效磷含量,单位mg/kg"+ required: false+ - name: phosphorus_level+ type: "string"+ description:+ zh: "磷素丰缺等级"+ required: false+ - name: potassium+ type: "float"+ description:+ zh: "速效钾含量,单位mg/kg"+ required: false+ - name: potassium_level+ type: "string"+ description:+ zh: "钾素丰缺等级"+ required: false+ - name: calcium+ type: "float"+ description:+ zh: "交换性钙含量,单位mg/kg"+ required: false+ - name: magnesium+ type: "float"+ description:+ zh: "交换性镁含量,单位mg/kg"+ required: false+ - name: sulfur+ type: "float"+ description:+ zh: "有效硫含量,单位mg/kg"+ required: false+ - name: iron+ type: "float"+ description:+ zh: "有效铁含量,单位mg/kg"+ required: false+ - name: manganese+ type: "float"+ description:+ zh: "有效锰含量,单位mg/kg"+ required: false+ - name: copper+ type: "float"+ description:+ zh: "有效铜含量,单位mg/kg"+ required: false+ - name: zinc+ type: "float"+ description:+ zh: "有效锌含量,单位mg/kg"+ required: false+ - name: boron+ type: "float"+ description:+ zh: "有效硼含量,单位mg/kg"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的土壤肥料专家,请从土壤检测报告中提取土壤养分指标。++ rules:+ zh: |+ 1. 每个文档只提取一个土壤养分模型对象+ 2. 检测值和丰缺等级必须同时提取+ 3. 数值保留原始精度,单位按照原文+ 4. 数据必须与原文保持一致,不得编造++ rules_for_nodes:+ zh: |+ - 土壤类型:潴育性水稻土、淹育型水稻土、潜育型水稻土、红壤、黄壤等+ - 丰缺等级:缺乏、偏低、适宜、丰富、极丰富+ - pH等级:酸性(<6.0)、弱酸性(6.0-6.5)、中性(6.5-7.0)、弱碱性(7.0-7.5)、碱性(>7.5)++display:+ label: "plot_id"diff --git a/hyperextract/templates/presets/biology/binding_site_model.yaml b/hyperextract/templates/presets/biology/binding_site_model.yamlnew file mode 100644index 0000000..c764c9c--- /dev/null+++ b/hyperextract/templates/presets/biology/binding_site_model.yaml@@ -0,0 +1,62 @@+name: "BindingSiteModel"+autotype: model+tag: [biology]++language: zh++description:+ zh: "关键位点模型 - 从蛋白质结构文献中提取活性位点、结合位点的残基信息"++schema:+ fields:+ - name: protein_name+ type: "string"+ description:+ zh: "蛋白质名称,如β2-肾上腺素受体"+ - name: site_type+ type: "string"+ description:+ zh: "位点类型:活性位点、结合位点、修饰位点、别构位点"+ - name: residue_numbers+ type: "string"+ description:+ zh: "关键残基编号范围,如Asp169-Lys210"+ - name: residue_details+ type: "array"+ description:+ zh: "关键残基详情列表"+ - name: chemical_properties+ type: "string"+ description:+ zh: "化学性质描述,如疏水口袋、氢键网络、金属离子结合位点"+ - name: function_annotation+ type: "string"+ description:+ zh: "功能注解,如配体识别、底物特异性、信号转导"+ - name: ligand_info+ type: "string"+ description:+ zh: "配体信息,如结合的配体分子或药物"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的结构生物学专家,请从文本中提取蛋白质的关键位点信息。++ rules:+ zh: |+ 1. 识别文本中描述的核心蛋白质及其位点+ 2. 提取位点的类型(活性位点、结合位点、修饰位点等)+ 3. 提取关键残基的编号、化学性质和功能+ 4. 数据必须与原文保持一致,不得编造++ rules_for_nodes:+ zh: |+ - 残基编号:使用标准编号系统,如Asp204表示第204位天冬氨酸+ - 氨基酸中文名称:天冬氨酸(Asp)、苯丙氨酸(Phe)、赖氨酸(Lys)、精氨酸(Arg)等+ - 位点类型:活性位点(直接参与催化)、结合位点(结合底物或配体)、修饰位点(可被修饰)+ - 化学性质:疏水、亲水、极性、带电荷等++display:+ label: "protein_name"diff --git a/hyperextract/templates/presets/biology/biochemical_reaction_hypergraph.yaml b/hyperextract/templates/presets/biology/biochemical_reaction_hypergraph.yamlnew file mode 100644index 0000000..ad7c3cb--- /dev/null+++ b/hyperextract/templates/presets/biology/biochemical_reaction_hypergraph.yaml@@ -0,0 +1,96 @@+name: "BiochemicalReactionHypergraph"+autotype: hypergraph+tag: [biology]++language: zh++description:+ zh: "生化反应超图 - 从代谢通路文献中提取生化反应的多层次关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "分子名称,如葡萄糖、ATP、丙酮酸"+ - name: molecule_type+ type: "string"+ description:+ zh: "分子类型:酶、底物、产物、辅因子"+ - name: molecular_formula+ type: "string"+ description:+ zh: "分子式,如C6H12O6"+ required: false++edge_schema:+ fields:+ - name: enzyme+ type: "string"+ description:+ zh: "催化该反应的酶名称"+ - name: substrates+ type: "array"+ description:+ zh: "反应底物列表"+ - name: products+ type: "array"+ description:+ zh: "反应产物列表"+ - name: cofactors+ type: "array"+ description:+ zh: "辅因子列表,如NAD+、Mg2+"+ required: false+ - name: reaction_type+ type: "string"+ description:+ zh: "反应类型:水解、氧化还原、转移、裂解、合成"+ - name: direction+ type: "string"+ description:+ zh: "反应方向:正向、逆向、可逆"+ - name: details+ type: "string"+ description:+ zh: "反应详细描述,包括反应条件或生物学意义"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的生物化学专家,请从代谢通路文献中提取生化分子及其反应关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的分子,禁止将多个分子合并为一个节点+ 2. 分子名称与原文保持一致+ 3. 超边连接酶、底物、产物等多类分子+ 4. 每条超边必须包含至少一个酶和底物++ rules_for_nodes:+ zh: |+ - 酶:催化生化反应的蛋白质,如己糖激酶、磷酸果糖激酶+ - 底物:被酶作用的分子+ - 产物:反应生成的分子+ - 辅因子:协助酶催化的分子,如NAD+、ATP、Mg2++ - 分子式使用标准化学式++ rules_for_edges:+ zh: |+ - 反应类型:水解、氧化还原、转移、裂解、合成、异构+ - 反应方向:正向、逆向、可逆+ - 格式:{酶 + 底物A + 底物B → 产物C + 产物D}++identifiers:+ node_id: "name"+ edge_id: "{enzyme}_{reaction_type}"+ edge_members:+ - "enzyme"+ - "substrates"+ - "products"+ - "cofactors"++display:+ node_label: "name"+ edge_label: "enzyme"diff --git a/hyperextract/templates/presets/biology/biodiversity_registry.yaml b/hyperextract/templates/presets/biology/biodiversity_registry.yamlnew file mode 100644index 0000000..e635e98--- /dev/null+++ b/hyperextract/templates/presets/biology/biodiversity_registry.yaml@@ -0,0 +1,66 @@+name: "BiodiversityRegistry"+autotype: set+tag: [biology]++language: zh++description:+ zh: "物种名录 - 从生物多样性调查报告中提取物种观测记录及种群数量信息"++item_schema:+ fields:+ - name: species_name+ type: "string"+ description:+ zh: "物种中文名称"+ - name: latin_name+ type: "string"+ description:+ zh: "拉丁学名"+ required: false+ - name: category+ type: "string"+ description:+ zh: "类别:脊椎动物、无脊椎动物、植物、微生物"+ - name: population_count+ type: "string"+ description:+ zh: "种群数量,如约120只、约850只"+ - name: protection_level+ type: "string"+ description:+ zh: "保护级别:国家一级保护、国家二级保护、地方保护、无保护"+ required: false+ - name: habitat+ type: "string"+ description:+ zh: "栖息地或分布区域"+ required: false+ - name: observation_details+ type: "string"+ description:+ zh: "观测详情,包括观测时间、地点和数量记录"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的生态学专家,请从调查报告中提取所有物种观测记录,构建物种名录。++ rules:+ zh: |+ 1. 每个物种只能对应一个唯一的记录,根据物种名称进行去重+ 2. 物种名称与原文保持一致+ 3. 汇总所有观测报告中提到的物种及其种群数量++ rules_for_nodes:+ zh: |+ - 保护级别:国家一级保护、国家二级保护、地方保护、无保护+ - 类别:脊椎动物(鱼类、两栖类、爬行类、鸟类、哺乳动物)、无脊椎动物(昆虫、螺类、蚌类等)、植物(高等植物、藻类、苔藓)+ - 种群数量:使用原文中的数量描述,如"约120只"、"约850尾"++identifiers:+ item_id: "species_name"++display:+ label: "species_name"diff --git a/hyperextract/templates/presets/biology/phylogenetic_relation_graph.yaml b/hyperextract/templates/presets/biology/phylogenetic_relation_graph.yamlnew file mode 100644index 0000000..c5f54d0--- /dev/null+++ b/hyperextract/templates/presets/biology/phylogenetic_relation_graph.yaml@@ -0,0 +1,90 @@+name: "PhylogeneticRelationGraph"+autotype: graph+tag: [biology]++language: zh++description:+ zh: "系统发育关系图 - 从进化生物学文献中提取物种亲缘关系和演化分支信息"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "物种或分类单元名称"+ - name: taxon_level+ type: "string"+ description:+ zh: "分类水平:界、门、纲、目、科、属、种"+ - name: description+ type: "string"+ description:+ zh: "简要描述,包含演化位置或特征"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源物种或分类单元"+ - name: target+ type: "string"+ description:+ zh: "目标物种或分类单元"+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型:亲缘关系、演化距离、分支、姐妹群"+ - name: evolutionary_distance+ type: "string"+ description:+ zh: "演化距离或分支时间估算"+ required: false+ - name: branch_point+ type: "string"+ description:+ zh: "分支点信息,如共同的祖先年代"+ required: false+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的进化生物学专家,请从生物学文献中提取物种或分类单元及其系统发育关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的物种或分类单元,禁止将其合并为一个节点+ 2. 物种名称与原文保持一致+ 3. 边只能连接已提取的物种或分类单元节点++ rules_for_nodes:+ zh: |+ - 分类等级:界(kingdom)、门(phylum)、纲(class)、目(order)、科(family)、属(genus)、种(species)+ - 系统发育关系包括:亲缘关系、演化距离、分支、姐妹群关系++ rules_for_edges:+ zh: |+ - 关系类型:亲缘关系、演化距离、分支、姐妹群+ - 演化距离可用分支时间(百万年)或序列差异度表示+ - 分支点信息包括共同的祖先和分化时间++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({taxon_level})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/biology/protein_complex_map.yaml b/hyperextract/templates/presets/biology/protein_complex_map.yamlnew file mode 100644index 0000000..e20a98b--- /dev/null+++ b/hyperextract/templates/presets/biology/protein_complex_map.yaml@@ -0,0 +1,85 @@+name: "ProteinComplexMap"+autotype: hypergraph+tag: [biology]++language: zh++description:+ zh: "蛋白质复合物超图 - 从蛋白质结构文献中提取蛋白质复合物的多亚基组成关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "蛋白质或亚基名称,如Gαs、Gβ、β2-AR"+ - name: gene_name+ type: "string"+ description:+ zh: "基因名称,如GNAS、GNB1"+ required: false+ - name: subunit_type+ type: "string"+ description:+ zh: "亚基类型:G蛋白α亚基、G蛋白β亚基、G蛋白γ亚基、受体、效应器"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: members+ type: "array"+ description:+ zh: "参与组成复合物的所有蛋白质或亚基名称列表"+ - name: complex_name+ type: "string"+ description:+ zh: "复合物名称,如G蛋白异源三聚体、β2-AR信号复合物"+ - name: function+ type: "string"+ description:+ zh: "复合物功能描述"+ - name: assembly_details+ type: "string"+ description:+ zh: "组装细节,如哪些亚基相互作用"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的结构生物学专家,请从蛋白质结构文献中提取蛋白质及其复合物组成关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的蛋白质或亚基,禁止将多个蛋白质合并为一个节点+ 2. 蛋白质名称与原文保持一致+ 3. 超边连接2个或多个蛋白质节点+ 4. 每条超边必须至少有2个成员++ rules_for_nodes:+ zh: |+ - G蛋白异源三聚体:包括Gα、Gβ、Gγ三个亚基+ - 受体:如β2-肾上腺素受体(β2-AR)+ - 效应器:如腺苷酸环化酶(AC)+ - 基因名称使用标准缩写++ rules_for_edges:+ zh: |+ - 复合物类型:G蛋白异源三聚体、信号转导复合物、酶复合物等+ - 组装信息:亚基之间的相互作用关系++identifiers:+ node_id: "name"+ edge_id: "{complex_name}|{members}"+ edge_members: "members"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({subunit_type})"+ edge_label: "complex_name"diff --git a/hyperextract/templates/presets/biology/regulatory_network.yaml b/hyperextract/templates/presets/biology/regulatory_network.yamlnew file mode 100644index 0000000..7d77eb7--- /dev/null+++ b/hyperextract/templates/presets/biology/regulatory_network.yaml@@ -0,0 +1,91 @@+name: "RegulatoryNetwork"+autotype: graph+tag: [biology]++language: zh++description:+ zh: "基因调控网络 - 从分子生物学文献中提取转录因子与基因之间的调控关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "基因或转录因子名称,如HIF-1α、c-Myc"+ - name: gene_symbol+ type: "string"+ description:+ zh: "基因符号,如HK2、PFKFB3"+ required: false+ - name: type+ type: "string"+ description:+ zh: "类型:转录因子、基因、启动子"+ - name: function+ type: "string"+ description:+ zh: "功能描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "调控因子(转录因子)名称"+ - name: target+ type: "string"+ description:+ zh: "被调控基因名称"+ - name: relation_type+ type: "string"+ description:+ zh: "调控类型:激活、抑制、协同激活"+ - name: mechanism+ type: "string"+ description:+ zh: "调控机制,如结合启动子、组蛋白修饰"+ required: false+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的分子生物学专家,请从文本中提取基因、转录因子及其之间的调控关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的基因或转录因子,禁止将多个基因合并为一个节点+ 2. 基因名称与原文保持一致+ 3. 边只能连接已提取的基因节点+ 4. 关系描述应与原文保持一致++ rules_for_nodes:+ zh: |+ - 转录因子:调控其他基因表达的蛋白质,如HIF-1α、c-Myc+ - 启动子:基因转录起始区域+ - 基因符号使用标准缩写,如HK2(己糖激酶2)、PFKFB3++ rules_for_edges:+ zh: |+ - 调控类型:激活(促进表达)、抑制(阻止表达)、协同激活+ - 调控机制:结合启动子、组蛋白修饰、DNA甲基化等++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({type})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/biology/species_interaction_web.yaml b/hyperextract/templates/presets/biology/species_interaction_web.yamlnew file mode 100644index 0000000..01f4c87--- /dev/null+++ b/hyperextract/templates/presets/biology/species_interaction_web.yaml@@ -0,0 +1,86 @@+name: "SpeciesInteractionWeb"+autotype: graph+tag: [biology]++language: zh++description:+ zh: "物种相互作用网 - 从生态学文献中提取物种间的捕食、竞争、共生等关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "物种名称,如绿藻、鲢鱼、苍鹭"+ - name: category+ type: "string"+ description:+ zh: "物种类别:生产者、消费者、分解者"+ - name: species_type+ type: "string"+ description:+ zh: "具体分类:浮游植物、浮游动物、底栖动物、鱼类、鸟类、哺乳动物、植物、微生物"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源物种名称"+ - name: target+ type: "string"+ description:+ zh: "目标物种名称"+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型:捕食、寄生、竞争、互利共生、共生"+ - name: details+ type: "string"+ description:+ zh: "关系详细描述,包括具体行为或机制"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的生态学专家,请从文本中提取物种及其之间的相互作用关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的物种,禁止将多个物种合并为一个节点+ 2. 物种名称与原文保持一致+ 3. 准确判断物种的营养级:生产者(植物、藻类)、消费者(动物)、分解者(细菌、真菌)+ 4. 边只能连接已提取的物种节点++ rules_for_nodes:+ zh: |+ - 生态学术语保持原文,如物种名称(鲢鱼、绿藻)、生态关系(捕食、竞争)+ - 注意区分不同营养级的物种++ rules_for_edges:+ zh: |+ - 关系类型包括:捕食、寄生、竞争、互利共生、共生+ - 捕食关系:捕食者 → 被捕食者+ - 竞争关系:竞争同一资源的物种之间+ - 互利共生:双方都受益的关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/biology/taxonomic_tree.yaml b/hyperextract/templates/presets/biology/taxonomic_tree.yamlnew file mode 100644index 0000000..7c30c04--- /dev/null+++ b/hyperextract/templates/presets/biology/taxonomic_tree.yaml@@ -0,0 +1,81 @@+name: "TaxonomicTree"+autotype: graph+tag: [biology]++language: zh++description:+ zh: "分类学树 - 从生物学文献中提取生物分类层级包含关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "分类单元名称,如绿藻门、鲤科、鲢鱼"+ - name: rank+ type: "string"+ description:+ zh: "分类等级:界、门、纲、目、科、属、种"+ - name: latin_name+ type: "string"+ description:+ zh: "拉丁学名"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源分类单元(较高等级,如门)"+ - name: target+ type: "string"+ description:+ zh: "目标分类单元(较低等级,如种)"+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型:包含于"+ - name: details+ type: "string"+ description:+ zh: "详细描述,包含具体的分类路径信息"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的生物分类学专家,请从生物学文献中提取分类单元及其层级包含关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的分类单元,禁止将多个分类单元合并为一个节点+ 2. 物种名称与原文保持一致+ 3. 边只能连接已提取的分类单元节点+ 4. 分类关系是层级包含关系,从高等级指向低等级++ rules_for_nodes:+ zh: |+ - 分类等级:界(kingdom)、门(phylum)、纲(class)、目(order)、科(family)、属(genus)、种(species)+ - 拉丁学名保持原文格式(属名首字母大写,种名小写斜体)+ - 常见的分类等级英文缩写:Kingdom, Phylum, Class, Order, Family, Genus, Species++ rules_for_edges:+ zh: |+ - 关系类型统一为"包含于"+ - 提取完整的分类路径信息++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({rank})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/finance/call_sentiment_hypergraph.yaml b/hyperextract/templates/presets/finance/call_sentiment_hypergraph.yamlnew file mode 100644index 0000000..3bb4c00--- /dev/null+++ b/hyperextract/templates/presets/finance/call_sentiment_hypergraph.yaml@@ -0,0 +1,109 @@+name: "CallSentimentHypergraph"+autotype: hypergraph+tag: [finance]++language: zh++description:+ zh: "电话会议情绪超图 - 从财报电话会议中提取多维情绪聚类"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "主题元素名称(例如'收入增长'、'CEO 蒂姆·库克'、'AI 投资周期'、'谨慎')"+ required: true+ default: ""+ - name: element_type+ type: "string"+ description:+ zh: "类型:主题、发言人、情绪、驱动因素"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "该元素的上下文或说明"+ required: false+ default: ""++edge_schema:+ fields:+ - name: cluster_name+ type: "string"+ description:+ zh: "描述性名称(例如'CEO 看好 AI 收入'、'CFO 对利润率持谨慎态度')"+ required: true+ default: ""+ - name: participating_elements+ type: "array"+ description:+ zh: "此情绪聚类中所有元素的名称(主题 + 发言人 + 情绪 + 驱动因素)"+ required: true+ default: ""+ - name: sentiment_polarity+ type: "string"+ description:+ zh: "整体情绪方向:看多、看空、中性、混合"+ required: true+ default: ""+ - name: intensity+ type: "string"+ description:+ zh: "情绪强度:强、中等、轻微"+ required: true+ default: ""+ - name: evidence+ type: "string"+ description:+ zh: "支持情绪判断的关键引述或意译"+ required: false+ default: ""+ - name: shift_from_prior+ type: "string"+ description:+ zh: "与前一季度基调的变化(如显著,例如'比第二季度更为谨慎'、'从中性上调')"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的财报电话会议情绪分析师,请从文本中提取主题、发言人、情绪信号及其多维关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别讨论的关键主题(收入、利润率、指引、战略)+ 4. 识别发言人及其角色+ 5. 评估每个主题-发言人组合的情绪方向和强度+ 6. 超边连接 主题 + 发言人 + 情绪 + 驱动因素+ 7. 记录与前一季度基调的变化+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别讨论的财务主题+ 4. 识别发言人(分析师、管理层)+ 5. 识别情绪标签和驱动因素+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 每个聚类连接 主题 + 发言人 + 情绪 + 驱动因素+ 4. 评估整体情绪方向和强度+ 5. 捕捉支撑证据+ 6. 记录与前几个季度的基调变化++identifiers:+ node_id: "name"+ edge_id: "{cluster_name}|{participating_elements}"+ edge_members: "participating_elements"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} [{element_type}]"+ edge_label: "{cluster_name}"diff --git a/hyperextract/templates/presets/finance/company_history_timeline.yaml b/hyperextract/templates/presets/finance/company_history_timeline.yamlnew file mode 100644index 0000000..5be91ef--- /dev/null+++ b/hyperextract/templates/presets/finance/company_history_timeline.yaml@@ -0,0 +1,120 @@+name: "CompanyHistoryTimeline"+autotype: temporal_graph+tag: [finance]++language: zh++description:+ zh: "公司历史时间线 - 从招股说明书或公司历史文档中提取里程碑事件"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ required: true+ default: ""+ - name: type+ type: "string"+ description:+ zh: "实体类型:公司、创始人、投资机构等"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "事件主体/相关实体"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "事件对象/相关实体"+ required: true+ default: ""+ - name: eventType+ type: "string"+ description:+ zh: "事件类型:成立、融资、并购、IPO、裁员、发布产品、管理层变更、股权变更、获得专利、获奖"+ required: true+ default: ""+ - name: eventDate+ type: "string"+ description:+ zh: "事件日期,格式为年-月-日或年份"+ required: false+ default: ""+ - name: details+ type: "string"+ description:+ zh: "事件详细描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的公司历史分析师,请从文本中提取公司相关的实体以及里程碑事件。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建新的实体+ 4. 关系描述应与原文保持一致+ 5. 仅提取与公司历史直接相关的核心实体+ 6. 重点关注:本公司、子公司、创始人、投资机构+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅提取与公司历史直接相关的核心实体+ 4. 重点关注:本公司、子公司、创始人、投资机构+ 5. 实体类型:公司、创始人、投资机构+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取事件,不要创建未列出的实体+ 2. 时间信息为可选,仅在文本中明确提及时才提取+ 3. source 和 target 只能是单个实体,不能是多个实体的拼接+ 4. 如果多个主体参与同一事件,应为每个主体创建独立的边+ 5. 事件类型:成立、融资、并购、IPO、裁员、发布产品、管理层变更、股权变更、获得专利、获奖+ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "去年" → {observation_time} 前一年+ - "今年" → {observation_time} 所属年份+ - "明年" → {observation_time} 后一年+ - "五年前" → {observation_time} 前五年+ - "最近" → {observation_time} 前1年++ 2. 明确日期:保持原格式+ - 年份(如 2015年)→ 2015+ - 年-月-日 → 保持原格式++ 3. 缺失时间:留空++identifiers:+ node_id: "name"+ edge_id: "{source}|{eventType}|{details}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "eventDate"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({type})"+ edge_label: "{eventType} ({eventDate})"diff --git a/hyperextract/templates/presets/finance/discussion_graph.yaml b/hyperextract/templates/presets/finance/discussion_graph.yamlnew file mode 100644index 0000000..4a3c50d--- /dev/null+++ b/hyperextract/templates/presets/finance/discussion_graph.yaml@@ -0,0 +1,95 @@+name: "DiscussionGraph"+autotype: graph+tag: [finance]++language: zh++description:+ zh: "财报会议讨论图谱 - 从财报电话会议中提取实体及关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ required: true+ default: ""+ - name: type+ type: "string"+ description:+ zh: "实体类型:参会人员、公司、产品、指标、行业"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "实体描述/说明"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体"+ required: true+ default: ""+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的财报会议分析师,请从文本中提取讨论中出现的实体以及它们之间的关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体+ 2. 实体名称与原文保持一致+ 3. 参会人员是核心,必须提取+ 4. 实体类型:参会人员(分析师、管理层)、公司、产品、指标、行业等+ 5. 关系类型:参会人员之间(提问、回答、追问、澄清、反问等)、参会人员与其他实体(提问关于、回答关于、看好、看衰、担忧、质疑等)、其他实体之间(竞争、合作、增长、下降等)+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将其合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 参会人员:分析师、管理层(CEO、CFO等)+ 4. 公司、产品、指标、行业+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 参会人员之间:提问、回答、追问、澄清、反问等+ 4. 参会人员与其他实体:提问关于、回答关于、看好、看衰、担忧、质疑、主导、负责等+ 5. 其他实体之间:竞争、合作、增长、下降等++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({type})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/finance/earnings_call_summary.yaml b/hyperextract/templates/presets/finance/earnings_call_summary.yamlnew file mode 100644index 0000000..f0e8c70--- /dev/null+++ b/hyperextract/templates/presets/finance/earnings_call_summary.yaml@@ -0,0 +1,124 @@+name: "EarningsCallSummary"+autotype: model+tag: [finance]++language: zh++description:+ zh: "财报电话会议摘要 - 从财报电话会议记录中提取关键财务指标、业绩指引和整体基调"++schema:+ fields:+ - name: company_name+ type: "string"+ description:+ zh: "公司名称"+ required: false+ default: ""+ - name: ticker+ type: "string"+ description:+ zh: "股票代码"+ required: false+ default: ""+ - name: quarter+ type: "string"+ description:+ zh: "报告季度(例如'Q3 FY2024'、'2024 年第四季度')"+ required: false+ default: ""+ - name: call_date+ type: "string"+ description:+ zh: "财报电话会议日期"+ required: false+ default: ""+ - name: reported_revenue+ type: "string"+ description:+ zh: "本季度报告收入(例如'948 亿美元')"+ required: false+ default: ""+ - name: revenue_vs_consensus+ type: "string"+ description:+ zh: "收入与市场一致预期对比(例如'超出 12 亿美元'、'符合预期'、'低于预期 5 亿美元')"+ required: false+ default: ""+ - name: reported_eps+ type: "string"+ description:+ zh: "报告的稀释每股收益(例如'1.46 美元')"+ required: false+ default: ""+ - name: eps_vs_consensus+ type: "string"+ description:+ zh: "每股收益与一致预期对比(例如'超出 0.05 美元')"+ required: false+ default: ""+ - name: guidance_revenue+ type: "string"+ description:+ zh: "前瞻性收入指引(例如'第四季度 950-970 亿美元'、'2025 财年收入 3800-3900 亿美元')"+ required: false+ default: ""+ - name: guidance_eps+ type: "string"+ description:+ zh: "前瞻性每股收益指引(如有提供)"+ required: false+ default: ""+ - name: overall_tone+ type: "string"+ description:+ zh: "电话会议整体基调:'积极'、'审慎乐观'、'中性'、'谨慎'、'消极'"+ required: false+ default: ""+ - name: key_highlights+ type: "array"+ description:+ zh: "管理层准备发言中的 3-5 项核心亮点"+ required: false+ default: ""+ - name: key_concerns+ type: "array"+ description:+ zh: "管理层或分析师在问答环节提出的主要关切"+ required: false+ default: ""+ - name: strategic_priorities+ type: "array"+ description:+ zh: "管理层强调的战略重点"+ required: false+ default: ""+ - name: ceo_name+ type: "string"+ description:+ zh: "CEO 或主要发言人姓名"+ required: false+ default: ""+ - name: cfo_name+ type: "string"+ description:+ zh: "CFO 姓名"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的分析师,请从财报电话会议记录中提取关键财务指标、业绩指引和整体基调。+ rules:+ zh: |+ 1. 每个对象对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 提取确切的报告数据(收入、每股收益)并与一致预期进行对比+ 4. 捕捉收入和盈利的前瞻性指引+ 5. 评估电话会议的整体基调(管理层措辞、分析师反应)+ 6. 列出准备发言中的核心亮点和问答环节中的主要关切+ 7. 识别管理层强调的战略重点++display:+ label: "{company_name} - {quarter}"diff --git a/hyperextract/templates/presets/finance/factor_influence_hypergraph.yaml b/hyperextract/templates/presets/finance/factor_influence_hypergraph.yamlnew file mode 100644index 0000000..8a46336--- /dev/null+++ b/hyperextract/templates/presets/finance/factor_influence_hypergraph.yaml@@ -0,0 +1,87 @@+name: "FactorInfluenceHypergraph"+autotype: hypergraph+tag: [finance]++language: zh++description:+ zh: "因子影响超图 - 建模股票分析中的多因子关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "因子名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "因子类别:宏观、行业、公司、市场情绪"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "因子描述/说明"+ required: false+ default: ""++edge_schema:+ fields:+ - name: result+ type: "string"+ description:+ zh: "结果/影响,如'业绩下滑'、'估值提升'、'价格上涨',不超过10字"+ required: true+ default: ""+ - name: factors+ type: "array"+ description:+ zh: "导致该结果的因子列表(至少2个)"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "详细描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的金融多因子分析师,请从文本中提取因子(作为节点)和因子导致的结果(作为超边)。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的因子,禁止将多个因子合并为一个节点+ 2. 因子名称与原文保持一致+ 3. 每条超边必须连接2个或以上因子+ 4. 优先提取包含3个及以上因子的超边+ 5. 因子类别:宏观(GDP增速、CPI、PPI、利率、汇率等)、行业(景气度、政策、供需格局等)、公司(营收、ROE、PE、净利润等)、市场情绪(资金流向、风险偏好等)+ 6. 结果类型:业绩类(业绩下滑、业绩增长、盈利提升等)、估值类(估值提升、估值承压、市值增长等)、价格类(价格上涨、股价下跌、成本上升等)、需求类(需求旺盛、需求疲软、订单增加等)+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的因子,禁止将多个因子合并为一个节点+ 2. 因子名称与原文保持一致+ 3. 因子类别:宏观(GDP、CPI、利率、汇率等)、行业(景气度、政策、供需等)、公司(营收、ROE、PE等)、市场情绪(资金流向、风险偏好等)+ rules_for_edges:+ zh: |+ 1. 仅从已知因子列表中提取超边,不要创建未列出的因子+ 2. 每条超边必须连接至少2个因子+ 3. 优先提取包含3个及以上因子的超边+ 4. 结果描述不超过10字+ 5. 结果类型:业绩类、估值类、价格类、需求类++identifiers:+ node_id: "name"+ edge_id: "{result}_{factors}"+ edge_members: "factors"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{result}"diff --git a/hyperextract/templates/presets/finance/filing_financial_snapshot.yaml b/hyperextract/templates/presets/finance/filing_financial_snapshot.yamlnew file mode 100644index 0000000..3d222f5--- /dev/null+++ b/hyperextract/templates/presets/finance/filing_financial_snapshot.yaml@@ -0,0 +1,107 @@+name: "FilingFinancialSnapshot"+autotype: model+tag: [finance]++language: zh++description:+ zh: "财报财务快照 - 从 SEC 申报文件中提取关键财务数据"++schema:+ fields:+ - name: company_name+ type: "string"+ description:+ zh: "申报实体的法定名称"+ required: false+ default: ""+ - name: ticker+ type: "string"+ description:+ zh: "股票代码(例如 'AAPL'、'MSFT')"+ required: false+ default: ""+ - name: filing_type+ type: "string"+ description:+ zh: "申报类型:'10-K'、'10-Q'、'8-K'、'20-F'"+ required: false+ default: ""+ - name: filing_period+ type: "string"+ description:+ zh: "涵盖的财务期间(例如 'FY2024'、'Q3 2024')"+ required: false+ default: ""+ - name: revenue+ type: "string"+ description:+ zh: "总营收或净销售额(例如 '3943亿美元')"+ required: false+ default: ""+ - name: net_income+ type: "string"+ description:+ zh: "净利润"+ required: false+ default: ""+ - name: earnings_per_share+ type: "string"+ description:+ zh: "稀释每股收益(例如 '$6.13')"+ required: false+ default: ""+ - name: total_assets+ type: "string"+ description:+ zh: "总资产"+ required: false+ default: ""+ - name: total_liabilities+ type: "string"+ description:+ zh: "总负债"+ required: false+ default: ""+ - name: shareholders_equity+ type: "string"+ description:+ zh: "股东权益"+ required: false+ default: ""+ - name: operating_cash_flow+ type: "string"+ description:+ zh: "经营活动现金流"+ required: false+ default: ""+ - name: free_cash_flow+ type: "string"+ description:+ zh: "自由现金流"+ required: false+ default: ""+ - name: key_metrics+ type: "array"+ description:+ zh: "其他关键财务指标列表(如毛利率、ROE、市盈率等)"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的财务分析师,请从 SEC 申报文件中提取关键财务数据。+ rules:+ zh: |+ 1. 每个对象对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 按报告原文提取精确的金额数据,保留单位(百万、十亿)+ 4. 识别申报实体、股票代码、申报类型和财务期间+ 5. 在可获取时同时提取最近期间和前期对比数据+ 6. 捕获申报文件中明确列出的关键财务比率+ 7. 使用表格中的精确数据;除非文件明确给出,否则不要计算衍生数值+++display:+ label: "{company_name} ({ticker}) - {filing_period}"diff --git a/hyperextract/templates/presets/finance/filing_risk_factor_set.yaml b/hyperextract/templates/presets/finance/filing_risk_factor_set.yamlnew file mode 100644index 0000000..f1a6221--- /dev/null+++ b/hyperextract/templates/presets/finance/filing_risk_factor_set.yaml@@ -0,0 +1,72 @@+name: "FilingRiskFactorSet"+autotype: set+tag: [finance]++language: zh++description:+ zh: "申报风险因素集 - 对 SEC 申报文件中的风险因素进行去重和归类"++item_schema:+ fields:+ - name: risk_title+ type: "string"+ description:+ zh: "风险因素的简明标题(例如 '网络安全漏洞风险'、'外汇敞口')"+ required: true+ default: ""+ - name: risk_category+ type: "string"+ description:+ zh: "类别:'市场'、'运营'、'监管'、'财务'、'战略'、'网络安全'、'ESG'、'法律'、'地缘政治'"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "申报文件中披露的风险完整描述"+ required: true+ default: ""+ - name: potential_impact+ type: "string"+ description:+ zh: "所述的潜在财务或运营影响(例如 '对营收产生重大不利影响')"+ required: false+ default: ""+ - name: affected_areas+ type: "array"+ description:+ zh: "受影响的业务板块或职能(例如 ['国际业务', '供应链'])"+ required: false+ default: ""+ - name: mitigation_disclosed+ type: "string"+ description:+ zh: "公司已披露的任何缓解措施或管控手段"+ required: false+ default: ""+ - name: is_new+ type: "bool"+ description:+ zh: "与前期申报相比,该风险因素是否为新增"+ required: false+ default: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的监管申报分析师,请从 SEC 申报文件的风险因素章节中提取并归类所有单项风险因素。+ rules:+ zh: |+ 1. 每个元素对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 规范化:将相关的风险描述归纳到一个简明的风险标题下+ 4. 分类:将每项风险归入其主要类别+ 5. 完整性:提取每一个不同的风险因素,即使只是简要提及+ 6. 累积合并:如果同一风险在不同章节中出现了更多细节,则合并相关信息++identifiers:+ item_id: "risk_title"++display:+ label: "[{risk_category}] {risk_title}"diff --git a/hyperextract/templates/presets/finance/financial_data_temporal_graph.yaml b/hyperextract/templates/presets/finance/financial_data_temporal_graph.yamlnew file mode 100644index 0000000..5726874--- /dev/null+++ b/hyperextract/templates/presets/finance/financial_data_temporal_graph.yaml@@ -0,0 +1,121 @@+name: "FinancialDataTemporalGraph"+autotype: temporal_graph+tag: [finance]++language: zh++description:+ zh: "财务数据时序图谱 - 跨报告期追踪财务指标变化"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体的规范名称(例如 '苹果公司'、'云服务分部'、'营业收入'、'净利润')"+ required: true+ default: ""+ - name: entity_type+ type: "string"+ description:+ zh: "类型:'公司'、'分部'、'财务指标'、'会计科目'、'外部因素'"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要背景说明(例如 '消费电子业务板块'、'GAAP 收入确认口径')"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "主体(公司/分部/指标名称)"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标(指标/分部/因素名称)"+ required: true+ default: ""+ - name: relationship+ type: "string"+ description:+ zh: "关系类型:'拥有'、'同比变化'、'占比'、'贡献'、'影响'"+ required: true+ default: ""+ - name: value+ type: "string"+ description:+ zh: "数值(如 '3943亿美元'、'+7.8%'、'30%')"+ required: false+ default: ""+ - name: fiscal_period+ type: "string"+ description:+ zh: "财务期间(如 'FY2024'、'Q3 2024')"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的财务分析师,请从文本中提取财务实体及其跨时间的量化关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 将公司、业务分部和财务指标/会计科目识别为实体+ 6. 对每个报告数据,创建连接报告主体与指标的边,附带精确数值和财务期间+ 7. 将同比变化、衍生比率和分部贡献分别作为独立的边提取+ 8. 保留源文本中的精确金额和单位+ 9. 统一使用一致的财务期间标签(例如 'FY2024'、'Q3 2024')+ rules_for_nodes:+ zh: |+ 1. 每个节点对应一个独立实体+ 2. 实体名称与原文保持一致+ 3. 提取的节点名称要完整准确,因为边会引用这些名称+ 4. 公司:申报公司及其重要子公司+ 5. 分部:业务分部或区域(具体名称)+ 6. 财务指标:关键财务指标(营业收入、净利润、毛利率等)+ 7. 会计科目:主要会计科目+ 8. 外部因素:影响财务的外部因素+ rules_for_edges:+ zh: |+ 1. source 和 target 都必须是已知实体列表中的节点+ 2. 每个出现的财务数据都必须提取为一条边+ 3. 节点名称必须完全匹配+ 4. 关系类型:拥有、同比变化、占比、贡献、影响+ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "去年" → {observation_time} 的前一年+ - "上月" → {observation_time} 的前一个月+ - "本季度" → {observation_time} 所在季度+ - "FY2024" → 2024财年++ 2. 精确时间 → 保持原样+ 3. 时间缺失 → 留空,不要猜测++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationship}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "fiscal_period"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({entity_type})"+ edge_label: "{relationship} ({value})"diff --git a/hyperextract/templates/presets/finance/financial_forecast.yaml b/hyperextract/templates/presets/finance/financial_forecast.yamlnew file mode 100644index 0000000..0c5e302--- /dev/null+++ b/hyperextract/templates/presets/finance/financial_forecast.yaml@@ -0,0 +1,75 @@+name: "FinancialForecast"+autotype: list+tag: [finance]++language: zh++description:+ zh: "财务预测 - 从股票研究报告中提取预测财务数据"++item_schema:+ fields:+ - name: metric+ type: "string"+ description:+ zh: "被预测的财务指标(例如 '收入'、'每股收益'、'EBITDA'、'营业利润率'、'自由现金流')"+ required: true+ default: ""+ - name: period+ type: "string"+ description:+ zh: "预测期间(例如 'FY2025E'、'Q1 2025E'、'CY2026E')"+ required: true+ default: ""+ - name: estimate+ type: "string"+ description:+ zh: "预测值(例如 '$120.5B'、'$6.25'、'35.2%')"+ required: true+ default: ""+ - name: prior_estimate+ type: "string"+ description:+ zh: "如有修订,之前的预测值(例如 '$115.0B')"+ required: false+ default: ""+ - name: consensus+ type: "string"+ description:+ zh: "用于对比的市场一致性预期(例如 '$118.2B')"+ required: false+ default: ""+ - name: growth_rate+ type: "string"+ description:+ zh: "隐含增长率(例如 '同比+15%'、'持平')"+ required: false+ default: ""+ - name: assumptions+ type: "string"+ description:+ zh: "预测所依据的关键假设(例如 '假设销量增加 500 万台')"+ required: false+ default: ""+ - name: source_firm+ type: "string"+ description:+ zh: "提供该预测的研究机构"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的金融分析师,请从文本中提取所有财务预测和估算。+ rules:+ zh: |+ 1. 每个条目对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 提取每个预测指标及其对应的具体时间段+ 4. 在注明修订时,同时捕获当前和之前的预测值+ 5. 在进行对比时提取一致性预期+ 6. 捕获增长率和关键假设++display:+ label: "{metric} ({period}): {estimate}"diff --git a/hyperextract/templates/presets/finance/management_guidance_list.yaml b/hyperextract/templates/presets/finance/management_guidance_list.yamlnew file mode 100644index 0000000..5446e57--- /dev/null+++ b/hyperextract/templates/presets/finance/management_guidance_list.yaml@@ -0,0 +1,76 @@+name: "ManagementGuidanceList"+autotype: list+tag: [finance]++language: zh++description:+ zh: "管理层业绩指引列表 - 从财报电话会议中提取管理层未来业绩指引"++item_schema:+ fields:+ - name: guidance_topic+ type: "string"+ description:+ zh: "指引主题(例如'第四季度收入'、'2025 财年资本支出'、'毛利率展望'、'招聘计划')"+ required: true+ default: ""+ - name: guidance_type+ type: "string"+ description:+ zh: "类型:定量、定性、战略、运营"+ required: true+ default: ""+ - name: guidance_value+ type: "string"+ description:+ zh: "指引内容或预测值(例如'950-970 亿美元'、'将拓展 5 个新市场'、'预计下半年利润率改善')"+ required: true+ default: ""+ - name: prior_guidance+ type: "string"+ description:+ zh: "同一指标的前次指引(如有修订,例如'900-930 亿美元')"+ required: false+ default: ""+ - name: direction+ type: "string"+ description:+ zh: "相对前次指引或一致预期的方向:'上调'、'下调'、'维持'、'首次发布'"+ required: false+ default: ""+ - name: time_period+ type: "string"+ description:+ zh: "指引覆盖的时间段(例如'2024 年第四季度'、'2025 财年'、'未来 12 个月')"+ required: false+ default: ""+ - name: confidence_language+ type: "string"+ description:+ zh: "管理层的确信程度措辞(例如'我们预计'、'我们有信心'、'我们预期')"+ required: false+ default: ""+ - name: speaker+ type: "string"+ description:+ zh: "指引发布者(例如'CEO'、'CFO'、'COO')"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的分析师,请从财报电话会议记录中提取所有前瞻性声明和业绩指引。+ rules:+ zh: |+ 1. 每个条目对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 提取每一项指引条目(定量数据、战略规划、展望声明)+ 4. 注明指引相较前次是上调、下调还是维持不变+ 5. 捕捉每项指引覆盖的时间段+ 6. 保留管理层的确信程度措辞+ 7. 识别每项指引的发布者++display:+ label: "{guidance_topic} [{direction}]: {guidance_value}"diff --git a/hyperextract/templates/presets/finance/market_narrative_timeline.yaml b/hyperextract/templates/presets/finance/market_narrative_timeline.yamlnew file mode 100644index 0000000..0f258f8--- /dev/null+++ b/hyperextract/templates/presets/finance/market_narrative_timeline.yaml@@ -0,0 +1,115 @@+name: "MarketNarrativeTimeline"+autotype: temporal_graph+tag: [finance]++language: zh++description:+ zh: "市场叙事时间线 - 追踪市场叙事随时间的演变"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "叙事名称(如'通胀恐惧'、'软着陆希望')"+ required: true+ default: ""+ - name: narrative_type+ type: "string"+ description:+ zh: "叙事类型:'市场情绪'、'投资主题'、'政策预期'、'经济判断'"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "叙事描述"+ required: true+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "先前叙事名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "新兴叙事名称"+ required: true+ default: ""+ - name: transition_type+ type: "string"+ description:+ zh: "演变类型:被替代、演变为、触发了、主导了"+ required: true+ default: ""+ - name: timestamp+ type: "string"+ description:+ zh: "演变时间(如'2024-03'、'2024年Q2')"+ required: true+ default: ""+ - name: catalyst+ type: "string"+ description:+ zh: "触发演变的事件或数据点"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的策略师,请从财经评论中提取市场叙事以及它们随时间的演变。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的叙事,禁止将多个叙事合并为一个节点+ 2. 叙事名称与原文保持一致+ 3. 仅从已知叙事列表中提取边,不要创建新的叙事+ 4. 关系描述应与原文保持一致+ 5. 叙事是市场中的"故事"、主题、情绪+ 6. 叙事不是具体的公司、指数、政策本身+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的叙事,禁止将多个叙事合并为一个节点+ 2. 叙事名称与原文保持一致+ 3. 叙事是市场中的"故事"、主题、情绪+ 4. 叙事不是具体的公司、指数、政策本身+ 5. 叙事类型:市场情绪、投资主题、政策预期、经济判断+ rules_for_edges:+ zh: |+ 1. 边的 source 和 target 必须完全使用下方叙事列表中的名称,禁止创造新叙事+ 2. 仅从已知叙事列表中提取边,不要创建新的叙事+ 3. 关系描述应与原文保持一致+ 4. 演变类型:被替代、演变为、触发了、主导了+ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "去年" → {observation_time} 的前一年+ - "上月" → {observation_time} 的前一个月+ - "本季度" → {observation_time} 所在季度+ - "近期" → {observation_time} 最近 3 个月++ 2. 精确时间 → 保持原样+ 3. 时间缺失 → 留空++identifiers:+ node_id: "name"+ edge_id: "{source}|{transition_type}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "timestamp"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({narrative_type})"+ edge_label: "{transition_type} [{timestamp}]"diff --git a/hyperextract/templates/presets/finance/market_sentiment_model.yaml b/hyperextract/templates/presets/finance/market_sentiment_model.yamlnew file mode 100644index 0000000..e533325--- /dev/null+++ b/hyperextract/templates/presets/finance/market_sentiment_model.yaml@@ -0,0 +1,94 @@+name: "MarketSentimentModel"+autotype: model+tag: [finance]++language: zh++description:+ zh: "市场情绪模型 - 从财经新闻中提取情绪极性、提及实体和预期价格影响"++schema:+ fields:+ - name: headline+ type: "string"+ description:+ zh: "新闻文章/评论的标题/主题"+ required: true+ default: ""+ - name: source+ type: "string"+ description:+ zh: "出版物或来源(例如 '彭博社'、'路透社'、'CNBC')"+ required: false+ default: ""+ - name: publication_date+ type: "string"+ description:+ zh: "发布日期"+ required: false+ default: ""+ - name: overall_sentiment+ type: "string"+ description:+ zh: "整体情绪:"看涨"、"看跌"、"中性"、"混合""+ required: false+ default: ""+ - name: sentiment_confidence+ type: "string"+ description:+ zh: "情绪评估的置信度:"高"、"中"、"低""+ required: false+ default: ""+ - name: mentioned_tickers+ type: "array"+ description:+ zh: "提及的股票代码(例如 ['AAPL', 'MSFT', 'GOOGL'])"+ required: false+ default: ""+ - name: mentioned_sectors+ type: "array"+ description:+ zh: "涉及的行业板块(例如 ['科技', '金融', '能源'])"+ required: false+ default: ""+ - name: key_events+ type: "array"+ description:+ zh: "驱动情绪的关键事件(例如 ['美联储利率决议', 'NVDA 财报超预期'])"+ required: false+ default: ""+ - name: expected_impact+ type: "string"+ description:+ zh: "预期的价格/市场影响(例如 '科技股短期上行'、'板块轮动可能性大')"+ required: false+ default: ""+ - name: time_horizon+ type: "string"+ description:+ zh: "隐含时间范围:'盘中'、'短期'、'中期'、'长期'"+ required: false+ default: ""+ - name: contrarian_signals+ type: "array"+ description:+ zh: "任何逆向或不同意见的观点"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的金融情绪分析师,请从财经新闻文章或市场评论中提取情绪快照。+ rules:+ zh: |+ 1. 每个对象对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 判断整体情绪极性(看涨/看跌/中性/混合)+ 4. 识别所有提及的股票代码和行业板块+ 5. 提取驱动情绪的关键事件+ 6. 评估预期市场影响和时间范围+ 7. 记录任何逆向或不同意见的观点++display:+ label: "{headline}"diff --git a/hyperextract/templates/presets/finance/material_event_timeline.yaml b/hyperextract/templates/presets/finance/material_event_timeline.yamlnew file mode 100644index 0000000..08bf315--- /dev/null+++ b/hyperextract/templates/presets/finance/material_event_timeline.yaml@@ -0,0 +1,131 @@+name: "MaterialEventTimeline"+autotype: temporal_graph+tag: [finance]++language: zh++description:+ zh: "重大事件时间线 - 从 8-K 申报文件中按时间顺序提取重大事件"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(例如 公司名称、高管姓名、监管机构)"+ required: true+ default: ""+ - name: entity_type+ type: "string"+ description:+ zh: "类型:'公司'、'高管'、'监管机构'、'交易对手'、'子公司'、'审计师'"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "角色或背景(例如 '首席执行官'、'收购方'、'SEC')"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "行为实体名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "受影响实体名称"+ required: true+ default: ""+ - name: event_type+ type: "string"+ description:+ zh: "类型:'高管任命'、'高管离职'、'收购'、'资产剥离'、'财务重述'、'破产'、'退市'、'重大协议'、'股息宣派'、'股票拆分'、'监管行动'"+ required: true+ default: ""+ - name: start_timestamp+ type: "string"+ description:+ zh: "事件发生或公告的日期(例如 '2024-03-15'、'2024年3月15日')"+ required: false+ default: ""+ - name: end_timestamp+ type: "string"+ description:+ zh: "如适用的结束日期(例如 生效日期、交割日期)"+ required: false+ default: ""+ - name: description+ type: "string"+ description:+ zh: "重大事件的详细信息,包括财务条款、条件或监管背景"+ required: false+ default: ""+ - name: sec_item+ type: "string"+ description:+ zh: "8-K 条目编号(例如 'Item 5.02'、'Item 1.01'、'Item 2.01')"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的监管申报分析师,请从文本中提取参与重大事件的实体及其之间的时序关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别涉及的公司、高管、监管机构和交易对手+ 6. 提取每个重大事件及其具体日期+ 7. 在可获取时按 8-K 条目编号对事件进行分类+ 8. 捕获财务条款、条件和监管背景+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别公司、高管、监管机构、审计师和交易对手+ 4. 按类型对每个实体进行分类+ 5. 捕获角色描述+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 通过重大事件连接实体+ 4. 提取每个事件的具体日期+ 5. 按事件类型和 8-K 条目编号进行分类+ 6. 捕获财务条款和条件+ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "去年" → {observation_time} 的前一年+ - "上月" → {observation_time} 的前一个月+ - "本季度" → {observation_time} 所在季度+ - "近期" → {observation_time} 最近 3 个月++ 2. 精确时间 → 保持原样+ 3. 时间缺失 → 留空,不要猜测++identifiers:+ node_id: "name"+ edge_id: "{source}|{event_type}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "start_timestamp"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({entity_type})"+ edge_label: "{event_type} [{start_timestamp}]"diff --git a/hyperextract/templates/presets/finance/multi_source_sentiment_hypergraph.yaml b/hyperextract/templates/presets/finance/multi_source_sentiment_hypergraph.yamlnew file mode 100644index 0000000..618df62--- /dev/null+++ b/hyperextract/templates/presets/finance/multi_source_sentiment_hypergraph.yaml@@ -0,0 +1,121 @@+name: "MultiSourceSentimentHypergraph"+autotype: hypergraph+tag: [finance]++language: zh++description:+ zh: "多源情绪超图 - 整合多个来源的情绪信号"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "来源或实体的名称(例如:'彭博社文章'、'高盛分析师报告'、'AAPL'、'科技板块')"+ required: true+ default: ""+ - name: source_type+ type: "string"+ description:+ zh: "类型:'新闻文章'、'分析师报告'、'社交媒体'、'市场数据'、'公司公告'、'受影响实体'、'板块'、'指数'"+ required: true+ default: ""+ - name: sentiment_signal+ type: "string"+ description:+ zh: "该来源的个别情绪:'看涨'、'看跌'、'中性'"+ required: false+ default: ""+ - name: credibility+ type: "string"+ description:+ zh: "来源可信度评估:'一级'、'二级'、'未验证'"+ required: false+ default: ""++edge_schema:+ fields:+ - name: fusion_name+ type: "string"+ description:+ zh: "描述性名称(例如:'AAPL 来自 3 个来源的看涨共识')"+ required: true+ default: ""+ - name: participating_sources+ type: "array"+ description:+ zh: "参与此融合的所有来源和受影响实体的名称"+ required: true+ default: ""+ - name: aggregated_polarity+ type: "string"+ description:+ zh: "融合情绪:'强烈看涨'、'看涨'、'中性'、'看跌'、'强烈看跌'、'冲突'"+ required: true+ default: ""+ - name: agreement_level+ type: "string"+ description:+ zh: "来源一致性:'一致'、'多数'、'分裂'、'矛盾'"+ required: true+ default: ""+ - name: affected_entity+ type: "string"+ description:+ zh: "情绪适用的主要实体(股票代码或板块)"+ required: false+ default: ""+ - name: signal_strength+ type: "string"+ description:+ zh: "交易用的整体信号强度:'可操作'、'参考性'、'噪音'"+ required: false+ default: ""+ - name: conflicting_views+ type: "string"+ description:+ zh: "任何不同或冲突的情绪信号摘要"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的多源情绪融合分析师,请从不同来源提取情绪信号并创建聚合情绪视图。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别每个不同的情绪来源(新闻、分析师报告、社交媒体)+ 4. 提取每个来源的个别情绪信号+ 5. 创建连接来源到受影响实体的聚合情绪超边+ 6. 评估各来源之间的一致性+ 7. 记录冲突观点和信号强度+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别新闻文章、分析师报告和社交媒体帖子+ 4. 识别受影响实体(股票代码、板块、指数)+ 5. 捕捉每个来源的个别情绪+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 每条超边连接多个来源到一个受影响实体+ 4. 评估聚合情绪极性和一致性水平+ 5. 评估交易用途的信号强度+ 6. 记录任何冲突观点++identifiers:+ node_id: "name"+ edge_id: "fusion_name"+ edge_members: "participating_sources"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({source_type})"+ edge_label: "{fusion_name}"diff --git a/hyperextract/templates/presets/finance/proceeds_usage.yaml b/hyperextract/templates/presets/finance/proceeds_usage.yamlnew file mode 100644index 0000000..1393da0--- /dev/null+++ b/hyperextract/templates/presets/finance/proceeds_usage.yaml@@ -0,0 +1,63 @@+name: "ProceedsUsage"+autotype: list+tag: [finance]++language: zh++description:+ zh: "募集资金用途列表 - 从 IPO 招股说明书中提取募集资金分配计划"++item_schema:+ fields:+ - name: use_category+ type: "string"+ description:+ zh: "资金用途类别(例如'研发投入'、'偿还债务'、'营运资金'、'收购'、'资本支出'、'一般企业用途')"+ required: true+ default: ""+ - name: project_name+ type: "string"+ description:+ zh: "具体项目或计划名称(例如'弗吉尼亚新数据中心'、'平台 2.0 开发')"+ required: false+ default: ""+ - name: allocated_amount+ type: "string"+ description:+ zh: "分配金额(例如'1.5 亿美元'、'约占净募集资金的 30%')"+ required: false+ default: ""+ - name: percentage_of_proceeds+ type: "string"+ description:+ zh: "占总募集资金的百分比(例如'30%'、'约三分之一')"+ required: false+ default: ""+ - name: timeline+ type: "string"+ description:+ zh: "预计资金使用时间表(例如'12-18 个月'、'2025-2026 财年')"+ required: false+ default: ""+ - name: description+ type: "string"+ description:+ zh: "资金具体使用方式的详细说明"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的 IPO 分析师,请从招股说明书中提取所有募集资金用途分配信息。+ rules:+ zh: |+ 1. 每个条目对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 提取每一项资金用途类别和具体项目+ 4. 捕捉分配金额和百分比+ 5. 提取资金使用时间表(如有说明)+ 6. 保留资金使用方式的详细描述++display:+ label: "{use_category}: {allocated_amount}"diff --git a/hyperextract/templates/presets/finance/research_note_summary.yaml b/hyperextract/templates/presets/finance/research_note_summary.yamlnew file mode 100644index 0000000..b549b28--- /dev/null+++ b/hyperextract/templates/presets/finance/research_note_summary.yaml@@ -0,0 +1,118 @@+name: "ResearchNoteSummary"+autotype: model+tag: [finance]++language: zh++description:+ zh: "研究报告摘要 - 从股票研究报告中提取核心投资论点"++schema:+ fields:+ - name: company_name+ type: "string"+ description:+ zh: "被覆盖公司的名称"+ required: false+ default: ""+ - name: ticker+ type: "string"+ description:+ zh: "股票代码(例如 'AAPL'、'NVDA')"+ required: false+ default: ""+ - name: analyst_name+ type: "string"+ description:+ zh: "首席分析师的姓名"+ required: false+ default: ""+ - name: research_firm+ type: "string"+ description:+ zh: "研究机构名称(例如 '高盛'、'摩根士丹利')"+ required: false+ default: ""+ - name: report_date+ type: "string"+ description:+ zh: "报告发布日期"+ required: false+ default: ""+ - name: rating+ type: "string"+ description:+ zh: "分析师评级:'买入'、'增持'、'持有'、'中性'、'卖出'、'减持'"+ required: false+ default: ""+ - name: prior_rating+ type: "string"+ description:+ zh: "如有变更,之前的评级"+ required: false+ default: ""+ - name: target_price+ type: "string"+ description:+ zh: "当前目标价(例如 '$150.00')"+ required: false+ default: ""+ - name: prior_target_price+ type: "string"+ description:+ zh: "如有变更,之前的目标价"+ required: false+ default: ""+ - name: current_price+ type: "string"+ description:+ zh: "报告发布时的股价"+ required: false+ default: ""+ - name: investment_thesis+ type: "string"+ description:+ zh: "核心投资论点或评级的关键论据"+ required: false+ default: ""+ - name: key_catalysts+ type: "array"+ description:+ zh: "已识别的近期催化剂(例如 ['Q4 业绩超预期', '新产品发布', '监管审批'])"+ required: false+ default: ""+ - name: key_risks+ type: "array"+ description:+ zh: "分析师强调的主要风险"+ required: false+ default: ""+ - name: revenue_estimate+ type: "string"+ description:+ zh: "分析师对当前/下一财年的收入预测"+ required: false+ default: ""+ - name: eps_estimate+ type: "string"+ description:+ zh: "分析师对当前/下一财年的每股收益预测"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的股票研究分析师,请从研究报告中提取核心投资论点、评级、目标价和关键论据。+ rules:+ zh: |+ 1. 每个对象对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 提取分析师的评级及任何评级变更+ 4. 捕获目标价以及变更前的目标价(如有变更)+ 5. 简洁地总结核心投资论点+ 6. 列出分析师识别的关键催化剂和风险+ 7. 在提及时提取财务预测(收入、每股收益)++display:+ label: "{ticker} - {rating} (目标价: {target_price})"diff --git a/hyperextract/templates/presets/finance/risk_assessment.yaml b/hyperextract/templates/presets/finance/risk_assessment.yamlnew file mode 100644index 0000000..c50666f--- /dev/null+++ b/hyperextract/templates/presets/finance/risk_assessment.yaml@@ -0,0 +1,123 @@+name: "RiskAssessmentGraph"+autotype: graph+tag: [finance]++language: zh++description:+ zh: "风险评估图谱 - 从企业披露文件中提取风险因子及其财务影响传导路径"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "实体类别:'风险因素'、'财务指标'、'运营结果'"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "实体的详细描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体名称"+ required: true+ default: ""+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型:'导致'、'影响'、'提高'、'降低'、'改善'、'削弱' 等"+ required: true+ default: ""+ - name: transmission_mechanism+ type: "string"+ description:+ zh: "传导机制说明"+ required: true+ default: ""+ - name: likelihood+ type: "string"+ description:+ zh: "发生可能性:高/中/低"+ required: true+ default: ""+ - name: severity+ type: "string"+ description:+ zh: "影响严重程度:高/中/低,或量化影响"+ required: false+ default: ""+ - name: mitigation+ type: "string"+ description:+ zh: "缓解措施或应对策略"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的金融风险分析师,请从企业披露文件中提取风险因素、财务指标、运营结果等实体,以及它们之间的风险传导关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别风险因素:运营风险、市场风险、财务风险、合规风险、外部风险+ 6. 识别财务指标:营收、利润、毛利率、现金流等+ 7. 识别运营结果:产能利用率、交付周期、客户流失率等+ 8. 映射风险到财务影响的传导路径+ 9. 提取发生可能性和影响严重程度+ 10. 捕获管理层提及的缓解措施+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别风险因素:供应链中断、原材料价格波动、汇率变动等+ 4. 识别财务指标:营业收入、净利润、毛利率、现金流等+ 5. 识别运营结果:产能利用率、交付延迟、客户流失等+ 6. 为每个实体标注正确的类别+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 边的 source 和 target 必须完全使用下方实体列表中的名称,不能创造新名称+ 4. 源实体通常是风险因素,目标实体是受影响的财务指标或运营结果+ 5. 描述风险传导到目标的机制(如何影响)+ 6. 提取发生可能性(高/中/低)+ 7. 提取影响严重程度或量化影响+ 8. 捕获提及的缓解措施或应对策略++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/finance/risk_factor_list.yaml b/hyperextract/templates/presets/finance/risk_factor_list.yamlnew file mode 100644index 0000000..666eb3c--- /dev/null+++ b/hyperextract/templates/presets/finance/risk_factor_list.yaml@@ -0,0 +1,63 @@+name: "RiskFactorList"+autotype: list+tag: [finance]++language: zh++description:+ zh: "风险因素列表 - 从股票研究报告中提取下行风险"++item_schema:+ fields:+ - name: risk_name+ type: "string"+ description:+ zh: "风险的简洁名称(例如 '欧盟监管收紧'、'强势美元带来的汇率逆风')"+ required: true+ default: ""+ - name: risk_category+ type: "string"+ description:+ zh: "类别:'监管'、'竞争'、'宏观经济'、'运营'、'汇率/货币'、'地缘政治'、'技术'、'法律/诉讼'、'ESG'、'执行'"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "风险情景的详细描述"+ required: true+ default: ""+ - name: potential_impact+ type: "string"+ description:+ zh: "估计的财务影响(例如 '收入下行 3-5%'、'每股收益风险 $0.50')"+ required: false+ default: ""+ - name: probability+ type: "string"+ description:+ zh: "分析师的概率评估:'高'、'中等'、'低'"+ required: false+ default: ""+ - name: time_horizon+ type: "string"+ description:+ zh: "风险可能兑现的时间(例如 '近期'、'2025 年'、'12-18 个月')"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的风险分析师,请从文本中提取所有下行风险和风险因素。+ rules:+ zh: |+ 1. 每个条目对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 提取每一个不同的风险因素+ 4. 对每项风险进行适当分类+ 5. 在提供量化影响估算时予以捕获+ 6. 记录概率评估和时间范围++display:+ label: "[{risk_category}] {risk_name}"diff --git a/hyperextract/templates/presets/finance/segment_performance_list.yaml b/hyperextract/templates/presets/finance/segment_performance_list.yamlnew file mode 100644index 0000000..f005959--- /dev/null+++ b/hyperextract/templates/presets/finance/segment_performance_list.yaml@@ -0,0 +1,69 @@+name: "SegmentPerformanceList"+autotype: list+tag: [finance]++language: zh++description:+ zh: "业务板块业绩列表 - 按业务板块提取营收和关键指标"++item_schema:+ fields:+ - name: segment_name+ type: "string"+ description:+ zh: "业务板块或地理区域名称(例如 '美洲'、'云服务'、'iPhone')"+ required: true+ default: ""+ - name: segment_type+ type: "string"+ description:+ zh: "类型:'业务板块'、'地理区域'、'产品线'、'经营分部'"+ required: true+ default: ""+ - name: revenue+ type: "string"+ description:+ zh: "该期间的板块营收(例如 '482亿美元')"+ required: false+ default: ""+ - name: operating_income+ type: "string"+ description:+ zh: "板块营业利润或经营利润"+ required: false+ default: ""+ - name: revenue_growth+ type: "string"+ description:+ zh: "同比或环比营收增长率(例如 '+12%'、'-3% 同比')"+ required: false+ default: ""+ - name: key_metrics+ type: "array"+ description:+ zh: "板块特定的关键绩效指标(例如 ['订阅用户:2.3亿', 'ARPU:$14.99', '流失率:2.1%'])"+ required: false+ default: ""+ - name: commentary+ type: "string"+ description:+ zh: "管理层对板块业绩或展望的评论"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的财务分析师,请从 SEC 申报文件中提取每个业务板块或地理区域的业绩数据。+ rules:+ zh: |+ 1. 每个条目对应一个独立的实体,禁止合并+ 2. 实体名称与原文保持一致+ 3. 提取每个可识别板块的营收和营业利润+ 4. 捕获增长率和与前期的对比数据+ 5. 提取板块特定的关键绩效指标和度量+ 6. 保留管理层的板块评论++display:+ label: "{segment_name} ({segment_type}) | {revenue}"diff --git a/hyperextract/templates/presets/finance/shareholder_structure.yaml b/hyperextract/templates/presets/finance/shareholder_structure.yamlnew file mode 100644index 0000000..8eba2f8--- /dev/null+++ b/hyperextract/templates/presets/finance/shareholder_structure.yaml@@ -0,0 +1,113 @@+name: "ShareholderStructure"+autotype: graph+tag: [finance]++language: zh++description:+ zh: "股东结构图谱 - 从招股说明书或委托声明文件中提取股权结构"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(例如个人、基金、控股公司、信托)"+ required: true+ default: ""+ - name: entity_type+ type: "string"+ description:+ zh: "类型:个人、机构投资者、控股公司、风险投资、私募股权、信托、政府实体、发行公司"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "附加信息(例如'联合创始人兼 CEO'、'B 轮领投机构')"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "持有方/母公司实体名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "被持有方/子公司实体名称"+ required: true+ default: ""+ - name: relationship_type+ type: "string"+ description:+ zh: "类型:直接持股、间接持股、实益所有权、投票权控制、董事会席位、母子公司"+ required: true+ default: ""+ - name: ownership_percentage+ type: "string"+ description:+ zh: "持股比例(例如'15.3%'、'51%'、'控股权')"+ required: false+ default: ""+ - name: share_class+ type: "string"+ description:+ zh: "股份类别(例如'A 类普通股'、'B 类(10 倍投票权)'、'C 轮优先股')"+ required: false+ default: ""+ - name: voting_power+ type: "string"+ description:+ zh: "投票权百分比(若与持股比例不同,例如'65% 投票权')"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的公司治理分析师,请从招股说明书或委托声明文件中提取股权结构。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别所有重要股东(5% 以上实益所有人)+ 6. 提取持股比例和股份类别+ 7. 映射母子公司和控股公司结构+ 8. 注意双重股权结构和投票权差异+ 9. 捕捉锁定期和 IPO 后限制条款+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别个人、机构投资者、控股公司和信托+ 4. 识别发行公司本身+ 5. 按类型对每个实体进行分类+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 将持有方连接到其持有的资产+ 4. 提取持股比例和股份类别+ 5. 注意投票权差异+ 6. 捕捉锁定期++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationship_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({entity_type})"+ edge_label: "{relationship_type} {ownership_percentage}"diff --git a/hyperextract/templates/presets/finance/supply_chain.yaml b/hyperextract/templates/presets/finance/supply_chain.yamlnew file mode 100644index 0000000..6425da5--- /dev/null+++ b/hyperextract/templates/presets/finance/supply_chain.yaml@@ -0,0 +1,97 @@+name: "SupplyChainGraph"+autotype: graph+tag: [finance]++language: zh++description:+ zh: "供应链图谱 - 从 SEC 申报文件中提取供应链实体及其关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(公司或供应商)"+ required: true+ default: ""+ - name: entity_type+ type: "string"+ description:+ zh: "类型:客户、供应商、战略伙伴、分销商、本公司"+ required: true+ default: ""+ - name: details+ type: "string"+ description:+ zh: "地理管辖区、认证信息及合规说明"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "上游供应商或提供方"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "下游买方或需求方"+ required: true+ default: ""+ - name: relationship_type+ type: "string"+ description:+ zh: "类型:供应、采购、分销、战略合作"+ required: true+ default: ""+ - name: product_service+ type: "string"+ description:+ zh: "被供应或交易的内容,例如锂芯片、物流服务等"+ required: true+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的供应链分析师,请从文本中提取供应链实体及其关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别供应商、客户和伙伴+ 6. 提取交易类型及产品+ 7. 将依赖度、交易量及地缘政治风险汇总+ rules_for_nodes:+ zh: |+ 1. 每个节点对应一个独立实体+ 2. 实体名称与原文保持一致+ 3. 识别公司及合作伙伴+ 4. 分类角色(客户、供应商、战略伙伴、分销商)+ 5. 记录地区及认证至 details+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 通过产品/服务连接实体+ 4. 综合评估依赖度、交易量及风险(关税、单一来源)++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationship_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "one_stage"++display:+ node_label: "{name} ({entity_type})"+ edge_label: "{relationship_type}"diff --git a/hyperextract/templates/presets/food/dish_review_summary.yaml b/hyperextract/templates/presets/food/dish_review_summary.yamlnew file mode 100644index 0000000..6e7f31a--- /dev/null+++ b/hyperextract/templates/presets/food/dish_review_summary.yaml@@ -0,0 +1,66 @@+name: "DishReviewSummary"+autotype: list+tag: [food]++language: zh++description:+ zh: "食评摘要清单 - 按菜品提取核心评价点、推荐等级及价格感知"++item_schema:+ fields:+ - name: dish_name+ type: "string"+ description:+ zh: "菜品名称"+ required: true+ default: ""+ - name: recommendation_level+ type: "string"+ description:+ zh: "推荐指数,如⭐⭐⭐⭐⭐ 或 4.5/5"+ required: true+ default: ""+ - name: highlights+ type: "array"+ description:+ zh: "亮点列表"+ required: true+ default: ""+ - name: improvements+ type: "array"+ description:+ zh: "改进空间列表"+ required: true+ default: ""+ - name: price_perception+ type: "string"+ description:+ zh: "价格感知,如性价比高、略贵但值"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "详细描述"+ required: true+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的美食评论家,请从文本中提取每道菜品的核心评价信息,形成食评摘要清单。+ rules:+ zh: |+ 1. 提取文本中出现的每道菜品的评价信息+ 2. 为每个菜品提取推荐等级(如⭐⭐⭐⭐⭐)+ 3. 提取菜品亮点和可能的改进空间+ 4. 提取价格感知信息+ 5. 每个菜品作为独立条目提取+ 6. 保持菜品名称与原文一致+ 7. 推荐等级使用原文的表达方式+ 8. 推荐指数常用表达:⭐⭐⭐⭐⭐、4.5/5、强烈推荐+ 9. 价格感知常用表达:性价比极高、实惠、略贵但值++display:+ label: "{dish_name} - {recommendation_level}"diff --git a/hyperextract/templates/presets/food/ingredient_composition_hypergraph.yaml b/hyperextract/templates/presets/food/ingredient_composition_hypergraph.yamlnew file mode 100644index 0000000..a5d4697--- /dev/null+++ b/hyperextract/templates/presets/food/ingredient_composition_hypergraph.yaml@@ -0,0 +1,99 @@+name: "IngredientCompositionHypergraph"+autotype: hypergraph+tag: [food]++language: zh++description:+ zh: "食材配伍超图 - 建模菜品与其主料、辅料、调味品的复杂组合关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "食材名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "食材类别:主料/辅料/调味品"+ required: true+ default: ""++edge_schema:+ fields:+ - name: dish_name+ type: "string"+ description:+ zh: "菜品名称"+ required: true+ default: ""+ - name: cuisine+ type: "string"+ description:+ zh: "菜系"+ required: false+ default: ""+ - name: main_ingredients+ type: "array"+ description:+ zh: "主料列表(包含食材名称、角色、用量)"+ required: false+ default: ""+ - name: auxiliary_ingredients+ type: "array"+ description:+ zh: "辅料列表(包含食材名称、角色、用量)"+ required: false+ default: ""+ - name: seasonings+ type: "array"+ description:+ zh: "调味品列表(包含食材名称、角色、用量)"+ required: false+ default: ""+ - name: combo_description+ type: "string"+ description:+ zh: "配伍描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的烹饪大师,请从文本中提取菜品与食材的配伍关系,建模为超边结构。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 食材角色:主料(主要食材)、辅料(辅助食材)、调味品(调料)+ 4. 提取每个食材的用量信息+ 5. 提取配伍描述+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 食材类别:主料、辅料、调味品+ rules_for_edges:+ zh: |+ 1. 仅从已知食材列表中提取边,不要创建未列出的食材+ 2. 关系描述应与原文保持一致+ 3. 食材角色:主料、辅料、调味品++identifiers:+ node_id: "name"+ edge_id: "dish_name"+ edge_members:+ - "main_ingredients"+ - "auxiliary_ingredients"+ - "seasonings"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{dish_name}"diff --git a/hyperextract/templates/presets/food/recipe_collection.yaml b/hyperextract/templates/presets/food/recipe_collection.yamlnew file mode 100644index 0000000..a6fbed8--- /dev/null+++ b/hyperextract/templates/presets/food/recipe_collection.yaml@@ -0,0 +1,57 @@+name: "RecipeCollection"+autotype: set+tag: [food]++language: zh++description:+ zh: "菜谱名录 - 去重提取文本中出现的所有独立菜品实体及基本分类"++item_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "菜品名称,保持与原文一致"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "菜品分类:凉菜、热菜、主食、甜品、小吃、饮品等"+ required: true+ default: ""+ - name: price+ type: "string"+ description:+ zh: "价格,如 ¥68、18元"+ required: false+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的餐饮知识专家,请从文本中提取所有独立菜品实体,形成菜谱名录。+ rules:+ zh: |+ 1. 提取所有独立菜品:每个菜品只能对应一条记录,禁止重复+ 2. 为每个菜品指定分类:凉菜、热菜、主食、甜品、小吃、饮品等+ 3. 保持菜品名称与原文一致+ 4. 如有价格信息,一并提取+ 5. 去重:同一菜品只保留一条记录+ 6. 保持客观准确,不添加文本中没有的信息+ 7. 菜品名称大小写需与原文保持一致+ 8. 菜单中常见的分类:凉菜、热菜、主食、甜品、小吃、饮品+ 9. 同一菜品在不同分类下出现时,保留所有出现过的分类++identifiers:+ item_id: "name"++display:+ label: "{name} ({category})"diff --git a/hyperextract/templates/presets/food/sensory_evaluation_graph.yaml b/hyperextract/templates/presets/food/sensory_evaluation_graph.yamlnew file mode 100644index 0000000..be67eb3--- /dev/null+++ b/hyperextract/templates/presets/food/sensory_evaluation_graph.yaml@@ -0,0 +1,97 @@+name: "SensoryEvaluationGraph"+autotype: graph+tag: [food]++language: zh++description:+ zh: "感官评价图谱 - 提取菜品-口感/味道-食材/技法的评价逻辑"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "节点名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "节点类型:菜品/口感/味道/食材/技法"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源节点"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标节点"+ required: true+ default: ""+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型:具有特征/归因于"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "详细描述"+ required: true+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的美食评论家,请从文本中提取感官评价图谱,包括菜品、口感/味道、食材/技法之间的归因关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 关系类型:具有特征(描述菜品具有某种口感/味道)、归因于(解释某种口感/味道的来源)+ 6. 节点类型:菜品、口感、味道、食材、技法+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 节点类型:菜品、口感、味道、食材、技法+ 4. 口感描述词:脆爽、鲜嫩、Q弹、绵密、软糯等+ 5. 味道描述词:鲜香、麻辣、酸甜、醇厚、清爽等+ 6. 技法描述词:腌制、烹煮、火候、刀工等+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 每条边必须连接已提取的节点+ 3. 关系描述应与原文保持一致+ 4. 关系类型:具有特征(描述菜品具有某种口感/味道)、归因于(解释某种口感/味道的来源)++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/food/standard_recipe_card.yaml b/hyperextract/templates/presets/food/standard_recipe_card.yamlnew file mode 100644index 0000000..c541537--- /dev/null+++ b/hyperextract/templates/presets/food/standard_recipe_card.yaml@@ -0,0 +1,107 @@+name: "StandardRecipeCard"+autotype: model+tag: [food]++language: zh++description:+ zh: "单品标准食谱 - 针对单个菜品提取完整的配料表、步骤说明及关键TIPS"++schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "菜名"+ required: true+ default: ""+ - name: cuisine+ type: "string"+ description:+ zh: "菜系,如浙菜、川菜、粤菜等"+ required: false+ default: ""+ - name: category+ type: "string"+ description:+ zh: "分类,如热菜、凉菜、主食、甜品等"+ required: false+ default: ""+ - name: flavor+ type: "string"+ description:+ zh: "口味描述,如咸甜鲜香、麻辣等"+ required: false+ default: ""+ - name: difficulty+ type: "string"+ description:+ zh: "难度:简单/中等/困难"+ required: false+ default: ""+ - name: cooking_time+ type: "string"+ description:+ zh: "预估烹饪时间,如90分钟"+ required: false+ default: ""+ - name: servings+ type: "string"+ description:+ zh: "适合人数,如4-6人份"+ required: false+ default: ""+ - name: main_ingredients+ type: "array"+ description:+ zh: "主料列表"+ required: false+ default: ""+ - name: auxiliary_ingredients+ type: "array"+ description:+ zh: "辅料列表"+ required: false+ default: ""+ - name: seasonings+ type: "array"+ description:+ zh: "调味品列表"+ required: false+ default: ""+ - name: steps+ type: "array"+ description:+ zh: "烹饪步骤列表"+ required: false+ default: ""+ - name: tips+ type: "array"+ description:+ zh: "关键控制点TIPS"+ required: false+ default: ""+ - name: nutrition_info+ type: "string"+ description:+ zh: "营养信息"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的烹饪大师,请从文本中提取单个菜品的完整标准食谱信息。+ rules:+ zh: |+ 1. 识别文本的核心菜品主体+ 2. 提取菜名、菜系、分类、口味等基本信息+ 3. 提取完整的原料信息(分为主料、辅料、调味品)+ 4. 提取详细的烹饪步骤+ 5. 提取关键控制点TIPS+ 6. 原料分类:主料(主要食材)、辅料(辅助食材)、调味品(调料)+ 7. 烹饪步骤:按顺序提取,每步一个条目+ 8. TIPS:提取烹饪中的关键技巧和注意事项++display:+ label: "{name} ({category})"diff --git a/hyperextract/templates/presets/general/clause_list.yaml b/hyperextract/templates/presets/general/clause_list.yamlnew file mode 100644index 0000000..e7389d2--- /dev/null+++ b/hyperextract/templates/presets/general/clause_list.yaml@@ -0,0 +1,46 @@+name: "ClauseList"+autotype: list+tag: [general]++language: zh++description:+ zh: "规章条文清单 - 将规章制度拆解为逐条的原子化条文,方便快速索引"++item_schema:+ fields:+ - name: clauseId+ type: "string"+ description:+ zh: "条文编号,如第1条、第2.1款"+ - name: title+ type: "string"+ description:+ zh: "条目标题/主题"+ required: false+ - name: content+ type: "string"+ description:+ zh: "条文内容"+ - name: category+ type: "string"+ description:+ zh: "条文分类:总则、权利义务、程序、处罚、附则、其他"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的规章制度条文拆解专家,请将文本拆解为逐条的原子化条文。++ rules:+ zh: |+ 1. 将规章制度按其自然结构拆解为独立的条文+ 2. 为每条条文分配编号(如第1条、第2.1款等)+ 3. 提取条文的内容+ 4. 为条文添加适当的标题或主题(如有)+ 5. 为每条条文指定分类:总则、权利义务、程序、处罚、附则、其他+ 6. 保持条文内容与原文一致,不要遗漏任何条文++display:+ label: "clauseId"diff --git a/hyperextract/templates/presets/general/compliance_logic.yaml b/hyperextract/templates/presets/general/compliance_logic.yamlnew file mode 100644index 0000000..86dda36--- /dev/null+++ b/hyperextract/templates/presets/general/compliance_logic.yaml@@ -0,0 +1,91 @@+name: "ComplianceLogic"+autotype: hypergraph+tag: [general]++language: zh++description:+ zh: "合规行为超图 - 建模 '在何种条件下,何种主体,必须/禁止执行何种操作' 的复杂逻辑"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "要素名称,文本中出现的精确名称"+ - name: category+ type: "string"+ description:+ zh: "要素类型:主体、操作、条件、其他"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: ruleType+ type: "string"+ description:+ zh: "规则类型:必须、禁止、允许、其他"+ - name: participants+ type: "array"+ description:+ zh: "参与要素名称列表,必须使用已提取节点的 name"+ - name: action+ type: "string"+ description:+ zh: "要求执行或禁止的操作内容"+ - name: condition+ type: "string"+ description:+ zh: "适用条件/前置要求"+ required: false+ - name: consequence+ type: "string"+ description:+ zh: "违规后果/奖励措施"+ required: false+ - name: sourceClause+ type: "string"+ description:+ zh: "规则来源条款"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的合规评估员,请从文本中提取合规要素和规则。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已提取节点创建规则++ rules_for_nodes:+ zh: |+ - 主体:执行动作的实体(个人、部门、组织、角色等)+ - 操作:具体的行为动作(提交、审批、执行、禁止等)+ - 条件:规则适用的时间、地点、状态、数量等前提条件+ - 其他:不属于上述类别的要素(文书、文件、状态、结果等)++ rules_for_edges:+ zh: |+ - 必须:必须执行的动作+ - 禁止:禁止执行的动作+ - 允许:允许执行的动作+ - 其他:不属于上述类别的规则++identifiers:+ node_id: "name"+ edge_id: "{ruleType}_{action}_{participants}"+ edge_members: "participants"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "[{ruleType}] {action}"diff --git a/hyperextract/templates/presets/general/concept_hierarchy.yaml b/hyperextract/templates/presets/general/concept_hierarchy.yamlnew file mode 100644index 0000000..5c7cf8f--- /dev/null+++ b/hyperextract/templates/presets/general/concept_hierarchy.yaml@@ -0,0 +1,80 @@+name: "ConceptHierarchy"+autotype: graph+tag: [general]++language: zh++description:+ zh: "概念层级图 - 构建上下位关系或组成关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "概念名称"+ - name: category+ type: "string"+ description:+ zh: "概念类型:核心概念、子概念、属性、实例、其他"+ - name: description+ type: "string"+ description:+ zh: "概念简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "父概念/整体概念"+ - name: target+ type: "string"+ description:+ zh: "子概念/部分概念"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:上下位(Subclass-Of)、组成(Part-Of)、实例(Instance-Of)、其他(Other)"+ - name: details+ type: "string"+ description:+ zh: "关系详细说明"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的概念结构分析专家,请从文本中提取概念及其层级关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的概念,禁止将多个概念合并为一个节点+ 2. 概念名称与原文保持一致+ 3. 仅从提取的概念中创建边++ rules_for_nodes:+ zh: |+ - 提取所有概念+ - 为每个概念指定类型++ rules_for_edges:+ zh: |+ - 上下位(Subclass-Of):表示概念的继承关系+ - 组成(Part-Of):表示整体与部分的关系+ - 实例(Instance-Of):表示概念与实例的关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/general/cross_reference_net.yaml b/hyperextract/templates/presets/general/cross_reference_net.yamlnew file mode 100644index 0000000..56fe140--- /dev/null+++ b/hyperextract/templates/presets/general/cross_reference_net.yaml@@ -0,0 +1,81 @@+name: "CrossReferenceNet"+autotype: graph+tag: [general]++language: zh++description:+ zh: "交叉引用网络 - 映射概念之间的超链接或相互引用关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "概念/条目名称"+ - name: type+ type: "string"+ description:+ zh: "节点类型:条目、章节、概念、人物、地点、其他"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源条目/概念"+ - name: target+ type: "string"+ description:+ zh: "被引用条目/概念"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:Hyperlink(超链接)、Reference(引用)、SeeAlso(参见)、Related(相关)、Other(其他)"+ - name: context+ type: "string"+ description:+ zh: "引用上下文描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的知识网络分析专家,请从文本中提取概念/条目及其相互引用关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从提取的节点中创建边++ rules_for_nodes:+ zh: |+ - 提取所有被提及的概念或条目+ - 为每个节点指定类型++ rules_for_edges:+ zh: |+ - Hyperlink:超链接关系+ - Reference:引用关系+ - SeeAlso:参见关系+ - Related:相关关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({type})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/general/encyclopedia_item.yaml b/hyperextract/templates/presets/general/encyclopedia_item.yamlnew file mode 100644index 0000000..26cc180--- /dev/null+++ b/hyperextract/templates/presets/general/encyclopedia_item.yaml@@ -0,0 +1,68 @@+name: "EncyclopediaItem"+autotype: model+tag: [general]++language: zh++description:+ zh: "百科条目 - 针对单一主体提取结构化的属性信息(类似信息框 Infobox)"++schema:+ fields:+ - name: title+ type: "string"+ description:+ zh: "条目标题"+ - name: entityType+ type: "string"+ description:+ zh: "实体类型:人物、地点、组织、事件、概念、物品、其他"+ - name: alternativeNames+ type: "array"+ description:+ zh: "别名、俗称、外文名称"+ required: false+ - name: category+ type: "array"+ description:+ zh: "分类标签"+ required: false+ - name: summary+ type: "string"+ description:+ zh: "摘要/简介"+ required: false+ - name: attributes+ type: "array"+ description:+ zh: "关键属性列表,每个元素格式为'属性名: 属性值'"+ required: false+ - name: keyEvents+ type: "array"+ description:+ zh: "重要事件/里程碑"+ required: false+ - name: relatedConcepts+ type: "array"+ description:+ zh: "相关概念/条目"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的百科全书编辑,请从文本中提取单一主体的结构化属性信息,构建百科条目信息框。++ rules:+ zh: |+ 1. 识别文本的核心主体(人物、地点、组织、事件、概念等)+ 2. 为主体指定类型+ 3. 提取所有别名、俗称或外文名称+ 4. 提取分类标签+ 5. 撰写 100-200 字的摘要+ 6. 提取关键属性+ 7. 提取重要事件或里程碑+ 8. 提取相关概念或条目++display:+ label: "title"diff --git a/hyperextract/templates/presets/general/entity_registry.yaml b/hyperextract/templates/presets/general/entity_registry.yamlnew file mode 100644index 0000000..e4cd526--- /dev/null+++ b/hyperextract/templates/presets/general/entity_registry.yaml@@ -0,0 +1,44 @@+name: "EntityRegistry"+autotype: set+tag: [general]++language: zh++description:+ zh: "实体注册表 - 去重并汇总文本中出现的所有唯一实体"++item_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,保持与原文一致"+ - name: category+ type: "string"+ description:+ zh: "实体类型:人物、机构、地点、产品、概念、其他"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的实体识别专家,请从文本中提取所有唯一实体,形成实体注册表。++ rules:+ zh: |+ 1. 提取所有实体:人物、机构、地点、产品、概念等+ 2. 为每个实体指定类型+ 3. 保持实体名称与原文一致+ 4. 为每个实体添加简要描述+ 5. 去重:同一实体只保留一条记录++identifiers:+ item_id: "name"+++display:+ label: "name"diff --git a/hyperextract/templates/presets/general/keyword_list.yaml b/hyperextract/templates/presets/general/keyword_list.yamlnew file mode 100644index 0000000..80d5824--- /dev/null+++ b/hyperextract/templates/presets/general/keyword_list.yaml@@ -0,0 +1,38 @@+name: "KeywordList"+autotype: list+tag: [general]++language: zh++description:+ zh: "关键词列表 - 从文本中提取关键词并附带分类、出现频次信息"++item_schema:+ fields:+ - name: term+ type: "string"+ description:+ zh: "关键词"+ - name: category+ type: "string"+ description:+ zh: "分类:核心概念、术语、人名、机构名、其他"+ - name: description+ type: "string"+ description:+ zh: "关键词简要描述或上下文说明"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的关键词提取专家,请从文本中提取所有关键词并附带分类和描述信息。++ rules:+ zh: |+ 1. 提取文本中的所有关键词和核心短语+ 2. 为每个关键词指定分类+ 3. 为每个关键词添加简要描述++display:+ label: "term"diff --git a/hyperextract/templates/presets/general/knowledge_graph.yaml b/hyperextract/templates/presets/general/knowledge_graph.yamlnew file mode 100644index 0000000..7bd2994--- /dev/null+++ b/hyperextract/templates/presets/general/knowledge_graph.yaml@@ -0,0 +1,81 @@+name: "KnowledgeGraph"+autotype: graph+tag: [general]++language: zh++description:+ zh: "通用知识图谱 - 从任意文本中提取实体与关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,如人名、机构名、产品名"+ - name: category+ type: "string"+ description:+ zh: "实体类型:人物、机构、地点、产品、概念、其他"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体"+ - name: target+ type: "string"+ description:+ zh: "目标实体"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:属于、位于、合作、竞争、发明、创建、相关等"+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的知识图谱提取专家,请从文本中提取实体及其关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从提取的实体中创建边++ rules_for_nodes:+ zh: |+ - 提取所有实体+ - 为每个实体指定类型++ rules_for_edges:+ zh: |+ - 属于:表示归属关系+ - 位于:表示地理位置关系+ - 合作:表示合作关系+ - 竞争:表示竞争关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/general/life_event_timeline.yaml b/hyperextract/templates/presets/general/life_event_timeline.yamlnew file mode 100644index 0000000..fb58468--- /dev/null+++ b/hyperextract/templates/presets/general/life_event_timeline.yaml@@ -0,0 +1,103 @@+name: "LifeEventTimeline"+autotype: temporal_graph+tag: [general]++language: zh++description:+ zh: "生活事件时间线 - 提取带时间戳的事件,并按时间顺序排列"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ - name: type+ type: "string"+ description:+ zh: "实体类型:人物、地点、组织、物品、概念、其他"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "事件主体/相关实体"+ - name: target+ type: "string"+ description:+ zh: "事件对象/相关实体"+ - name: eventType+ type: "string"+ description:+ zh: "事件类型:出生、逝世、教育、工作、成就、交往、旅行、其他"+ - name: eventDate+ type: "string"+ description:+ zh: "事件日期,格式为年-月-日或年份"+ required: false+ - name: details+ type: "string"+ description:+ zh: "事件详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的传记年表专家,请从文本中提取人物、地点、组织等实体以及生活事件。++ rules:+ zh: |+ 1. 提取所有相关实体+ 2. 为每个实体指定类型+ 3. 仅从提取的实体中创建事件边++ rules_for_nodes:+ zh: |+ - 人物、地点、组织、物品、概念等实体++ rules_for_edges:+ zh: |+ - 事件类型:出生、逝世、教育、工作、成就、交往、旅行、其他+ - 时间信息为可选,仅在文本中明确提及时才提取++ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "去年" → {observation_time} 前一年+ - "今年" → {observation_time} 所属年份+ - "明年" → {observation_time} 后一年+ - "昨天/今天/明天" → {observation_time} 前/当/后一天+ - "十年前/五年后" → {observation_time} 前/后相应年数+ - "年初/年末" → 当年 1月1日/12月31日+ - "朝代" → 保留朝代名称++ 2. 明确日期:保持原格式+ - 年份(如 429年、2023年)→ 429、2023+ - 年-月-日 → 保持原格式++ 3. 缺失时间:留空++identifiers:+ node_id: "name"+ edge_id: "{source}|{eventType}|{details}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "eventDate"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({type})"+ edge_label: "{eventType}"diff --git a/hyperextract/templates/presets/general/operational_procedure.yaml b/hyperextract/templates/presets/general/operational_procedure.yamlnew file mode 100644index 0000000..cc84fb3--- /dev/null+++ b/hyperextract/templates/presets/general/operational_procedure.yaml@@ -0,0 +1,98 @@+name: "OperationalProcedure"+autotype: graph+tag: [general]++language: zh++description:+ zh: "执行程序流程图 - 提取规章中规定的申报、审批或操作的具体先后步骤"++node_schema:+ fields:+ - name: stepId+ type: "string"+ description:+ zh: "步骤编号,如步骤1、步骤2"+ - name: name+ type: "string"+ description:+ zh: "步骤名称"+ - name: description+ type: "string"+ description:+ zh: "步骤详细描述"+ - name: role+ type: "string"+ description:+ zh: "执行角色"+ required: false+ - name: inputRequired+ type: "string"+ description:+ zh: "所需输入/材料"+ required: false+ - name: outputResult+ type: "string"+ description:+ zh: "输出/结果"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源步骤编号"+ - name: target+ type: "string"+ description:+ zh: "目标步骤编号"+ - name: condition+ type: "string"+ description:+ zh: "转换条件"+ required: false+ - name: details+ type: "string"+ description:+ zh: "详细说明"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的流程分析专家,请从文本中提取执行程序的步骤和转换关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的步骤,禁止将多个步骤合并为一个节点+ 2. 步骤名称与原文保持一致+ 3. 仅从提取的步骤中创建转换边++ rules_for_nodes:+ zh: |+ - 提取所有流程步骤+ - 为每个步骤分配编号+ - 记录步骤名称和描述+ - 记录执行角色(如有)+ - 记录所需输入或材料(如有)+ - 记录输出或结果(如有)++ rules_for_edges:+ zh: |+ - 记录步骤之间的先后关系+ - 记录转换条件(如有)++identifiers:+ node_id: "stepId"+ edge_id: "{source}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{stepId}: {name}"+ edge_label: "condition"diff --git a/hyperextract/templates/presets/general/penalty_mapping.yaml b/hyperextract/templates/presets/general/penalty_mapping.yamlnew file mode 100644index 0000000..3e9aad1--- /dev/null+++ b/hyperextract/templates/presets/general/penalty_mapping.yaml@@ -0,0 +1,81 @@+name: "PenaltyMapping"+autotype: graph+tag: [general]++language: zh++description:+ zh: "违规处罚因果链 - 描述从'违规行为'到'处理程序'再到'最终结果'的演变路径"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "节点名称"+ - name: type+ type: "string"+ description:+ zh: "节点类型:违规行为、处理程序、处罚结果、其他"+ - name: description+ type: "string"+ description:+ zh: "详细描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源节点名称"+ - name: target+ type: "string"+ description:+ zh: "目标节点名称"+ - name: relation+ type: "string"+ description:+ zh: "关系类型:导致、触发、执行、产生、其他"+ - name: details+ type: "string"+ description:+ zh: "详细说明"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的处罚逻辑分析专家,请从文本中提取违规处罚的因果链。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从提取的节点中创建因果路径边++ rules_for_nodes:+ zh: |+ - 违规行为:违反规定的行为+ - 处理程序:处理违规的流程+ - 处罚结果:最终的处罚结果++ rules_for_edges:+ zh: |+ - 导致:表示因果关系+ - 触发:表示引发关系+ - 执行:表示执行关系+ - 产生:表示结果关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({type})"+ edge_label: "{relation}"diff --git a/hyperextract/templates/presets/general/penalty_registry.yaml b/hyperextract/templates/presets/general/penalty_registry.yamlnew file mode 100644index 0000000..b8dc4f7--- /dev/null+++ b/hyperextract/templates/presets/general/penalty_registry.yaml@@ -0,0 +1,53 @@+name: "PenaltyRegistry"+autotype: set+tag: [general]++language: zh++description:+ zh: "违规处罚对照表 - 去重汇总特定的违规行为及其对应的后果,形成清晰的处罚台账"++item_schema:+ fields:+ - name: violation+ type: "string"+ description:+ zh: "违规行为描述"+ - name: severity+ type: "string"+ description:+ zh: "严重程度:轻微、一般、严重、特别严重"+ - name: penalty+ type: "string"+ description:+ zh: "处罚措施"+ - name: applicableClause+ type: "string"+ description:+ zh: "适用条款"+ required: false+ - name: notes+ type: "string"+ description:+ zh: "备注说明"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的合规分析专家,请从文本中提取所有违规行为及其对应的处罚措施,形成违规处罚对照表。++ rules:+ zh: |+ 1. 提取所有违规行为及其对应的处罚措施+ 2. 为每条违规行为指定严重程度+ 3. 保持违规行为和处罚措施的准确性+ 4. 记录适用的条款(如有)+ 5. 添加备注说明(如有)+ 6. 去重:相同的违规行为和处罚措施组合只保留一条++identifiers:+ item_id: "violation"++display:+ label: "violation"diff --git a/hyperextract/templates/presets/general/personal_profile.yaml b/hyperextract/templates/presets/general/personal_profile.yamlnew file mode 100644index 0000000..6c30683--- /dev/null+++ b/hyperextract/templates/presets/general/personal_profile.yaml@@ -0,0 +1,89 @@+name: "PersonalProfile"+autotype: model+tag: [general]++language: zh++description:+ zh: "个人档案 - 聚合人物的静态属性(生卒年、学历、核心身份)"++schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "姓名"+ - name: gender+ type: "string"+ description:+ zh: "性别"+ required: false+ - name: birthDate+ type: "string"+ description:+ zh: "出生日期,格式为年-月-日或年份"+ required: false+ - name: deathDate+ type: "string"+ description:+ zh: "逝世日期,格式为年-月-日或年份"+ required: false+ - name: nationality+ type: "string"+ description:+ zh: "国籍"+ required: false+ - name: birthPlace+ type: "string"+ description:+ zh: "出生地"+ required: false+ - name: education+ type: "array"+ description:+ zh: "教育经历"+ required: false+ - name: occupations+ type: "array"+ description:+ zh: "职业/身份"+ required: false+ - name: coreIdentity+ type: "array"+ description:+ zh: "核心身份/标签"+ required: false+ - name: majorAchievements+ type: "array"+ description:+ zh: "主要成就"+ required: false+ - name: affiliations+ type: "array"+ description:+ zh: "所属组织/机构"+ required: false+ - name: summary+ type: "string"+ description:+ zh: "个人简介"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的人物档案编辑,请从文本中提取该人物的静态属性信息,构建个人档案。++ rules:+ zh: |+ 1. 提取姓名、性别、出生日期、逝世日期、国籍、出生地等基本信息+ 2. 提取教育经历+ 3. 提取职业或身份信息+ 4. 提取核心身份标签+ 5. 提取主要成就+ 6. 提取所属组织或机构+ 7. 撰写 100-200 字的个人简介+ 8. 若信息缺失时留空,不要编造++display:+ label: "name"diff --git a/hyperextract/templates/presets/general/regulation_profile.yaml b/hyperextract/templates/presets/general/regulation_profile.yamlnew file mode 100644index 0000000..4940569--- /dev/null+++ b/hyperextract/templates/presets/general/regulation_profile.yaml@@ -0,0 +1,86 @@+name: "RegulationProfile"+autotype: model+tag: [general]++language: zh++description:+ zh: "规章元数据快照 - 提取制度的名称、版本、适用范围、生效日期及核心宗旨"++schema:+ fields:+ - name: title+ type: "string"+ description:+ zh: "规章名称"+ - name: version+ type: "string"+ description:+ zh: "版本号"+ required: false+ - name: issuer+ type: "string"+ description:+ zh: "发布机构"+ required: false+ - name: issueDate+ type: "string"+ description:+ zh: "发布日期"+ required: false+ - name: effectiveDate+ type: "string"+ description:+ zh: "生效日期"+ required: false+ - name: expiryDate+ type: "string"+ description:+ zh: "失效日期"+ required: false+ - name: scope+ type: "array"+ description:+ zh: "适用范围"+ required: false+ - name: targetAudience+ type: "array"+ description:+ zh: "适用对象"+ required: false+ - name: corePurpose+ type: "string"+ description:+ zh: "核心宗旨/目的"+ required: false+ - name: keywords+ type: "array"+ description:+ zh: "关键词/标签"+ required: false+ - name: relatedRegulations+ type: "array"+ description:+ zh: "关联规章"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的规章制度分析专家,请从文本中提取该规章制度的元数据信息,构建规章元数据快照。++ rules:+ zh: |+ 1. 提取规章的完整名称+ 2. 提取版本号(如有)+ 3. 提取发布机构+ 4. 提取发布日期、生效日期、失效日期(如有)+ 5. 提取适用范围+ 6. 提取适用对象+ 7. 提取核心宗旨或目的+ 8. 提取关键词或标签+ 9. 提取关联的其他规章+ 10. 信息缺失时留空,不要编造++display:+ label: "title"diff --git a/hyperextract/templates/presets/general/social_network.yaml b/hyperextract/templates/presets/general/social_network.yamlnew file mode 100644index 0000000..54f712d--- /dev/null+++ b/hyperextract/templates/presets/general/social_network.yaml@@ -0,0 +1,90 @@+name: "SocialNetwork"+autotype: graph+tag: [general]++language: zh++description:+ zh: "社交网络图 - 专注于提取人际关系、互动与组织隶属"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "名称"+ - name: type+ type: "string"+ description:+ zh: "节点类型:人物、组织、机构、其他"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ - name: role+ type: "string"+ description:+ zh: "角色/身份"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源节点"+ - name: target+ type: "string"+ description:+ zh: "目标节点"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:亲属、朋友、同事、师生、上下级、合作、竞争、隶属、其他"+ - name: details+ type: "string"+ description:+ zh: "关系详细说明"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的社会关系分析专家,请从文本中提取人物、组织及其相互关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从提取的节点中创建边++ rules_for_nodes:+ zh: |+ - 提取所有人物、组织、机构等+ - 为每个节点指定类型和角色++ rules_for_edges:+ zh: |+ - 亲属:血缘或姻亲关系+ - 朋友:朋友关系+ - 同事:工作关系+ - 师生:教育关系+ - 上下级:层级关系+ - 合作:合作关系+ - 竞争:竞争关系+ - 隶属:组织隶属关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({role})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/history/chronological_event_chain.yaml b/hyperextract/templates/presets/history/chronological_event_chain.yamlnew file mode 100644index 0000000..aa17abc--- /dev/null+++ b/hyperextract/templates/presets/history/chronological_event_chain.yaml@@ -0,0 +1,93 @@+name: "ChronologicalEventChain"+autotype: temporal_graph+tag: [history]++language: zh++description:+ zh: "编年事件链 - 提取带精确时间戳的原子事件,严格还原历史时间线"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "事件名称"+ - name: category+ type: "string"+ description:+ zh: "事件类型:战争、政治、外交、军事"+ - name: description+ type: "string"+ description:+ zh: "事件简要描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "前置事件名称"+ - name: target+ type: "string"+ description:+ zh: "后续事件名称"+ - name: time+ type: "string"+ description:+ zh: "时间,格式为年份或朝代年份,如208年,建安十三年"+ - name: location+ type: "string"+ description:+ zh: "地点"+ - name: description+ type: "string"+ description:+ zh: "事件因果描述,说明两事件之间的逻辑关系"++extraction_guide:+ target:+ zh: |+ 你是一位专业的历史学专家,请从文本中提取历史事件以及它们之间的时间因果关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从提取的实体中创建边++ rules_for_nodes:+ zh: |+ - 事件类型:战争、政治、外交、军事等+ - 事件要包含简要描述++ rules_for_edges:+ zh: |+ - 记录事件之间的时间因果关系+ - 关系描述应与原文保持一致++ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "去年" → {observation_time} 的前一年+ - "上月" → {observation_time} 的前一个月++ 2. 精确时间 → 保持原样(如"建安十三年冬")+ 3. 时间缺失 → 留空,不要猜测++identifiers:+ node_id: "name"+ edge_id: "{source}|{time}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "time"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "name"+ edge_label: "time"diff --git a/hyperextract/templates/presets/history/epistolary_knowledge_graph.yaml b/hyperextract/templates/presets/history/epistolary_knowledge_graph.yamlnew file mode 100644index 0000000..c224da3--- /dev/null+++ b/hyperextract/templates/presets/history/epistolary_knowledge_graph.yaml@@ -0,0 +1,108 @@+name: "EpistolaryKnowledgeGraph"+autotype: temporal_graph+tag: [history]++language: zh++description:+ zh: "信札内容图谱 - 提取信件正文中提到的人物、事件及其相互关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "人物姓名"+ - name: identity+ type: "string"+ description:+ zh: "身份描述,如北宋文学家、东吴大都督"+ required: false+ - name: description+ type: "string"+ description:+ zh: "人物描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "发信人"+ - name: target+ type: "string"+ description:+ zh: "收信人"+ - name: time+ type: "string"+ description:+ zh: "时间"+ required: false+ - name: subject+ type: "string"+ description:+ zh: "信件主题或主要议题"+ - name: mentionedPersons+ type: "array"+ description:+ zh: "信中提及的人物"+ required: false+ - name: mentionedEvents+ type: "array"+ description:+ zh: "信中提及的事件"+ required: false+ - name: summary+ type: "string"+ description:+ zh: "信件内容摘要"++extraction_guide:+ target:+ zh: |+ 你是一位专业的历史学专家,请从文本中提取书信中的人物以及书信内容关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致++ rules_for_nodes:+ zh: |+ - 人物要包含身份描述++ rules_for_edges:+ zh: |+ - 信件主题:信件讨论的主要议题+ - 提及人物:必须仔细阅读信件正文,提取正文中明确提到的人物姓名+ - 提及事件:必须仔细阅读信件正文,提取正文中明确提到的事件+ - 内容摘要:信件的主要内容概括++ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "去年" → {observation_time} 的前一年+ - "上月" → {observation_time} 的前一个月+ - "本季度" → {observation_time} 所在季度+ - "近期" → {observation_time} 最近 3 个月++ 2. 精确时间 → 保持原样+ 3. 时间缺失 → 留空,不要猜测++identifiers:+ node_id: "name"+ edge_id: "{source}|{subject}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "time"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "name"+ edge_label: "subject"diff --git a/hyperextract/templates/presets/history/historical_context_graph.yaml b/hyperextract/templates/presets/history/historical_context_graph.yamlnew file mode 100644index 0000000..b6d5bca--- /dev/null+++ b/hyperextract/templates/presets/history/historical_context_graph.yaml@@ -0,0 +1,78 @@+name: "HistoricalContextGraph"+autotype: graph+tag: [history]++language: zh++description:+ zh: "历史背景关联图 - 提取事件背后的人物关系、地缘政治等静态关联"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ - name: category+ type: "string"+ description:+ zh: "类型:地理、政治、经济、军事、文化"+ - name: description+ type: "string"+ description:+ zh: "实体描述,包括位置、作用、意义等"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体"+ - name: target+ type: "string"+ description:+ zh: "目标实体"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:包含、影响、对抗、支撑"+ - name: description+ type: "string"+ description:+ zh: "关系描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的历史学专家,请从文本中提取历史背景相关的实体以及它们之间的关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从提取的实体中创建边++ rules_for_nodes:+ zh: |+ - 实体类型:地理、政治、经济、军事、文化++ rules_for_edges:+ zh: |+ - 包含:包含关系+ - 影响:影响关系+ - 对抗:对抗关系+ - 支撑:支撑关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/history/historical_knowledge_graph.yaml b/hyperextract/templates/presets/history/historical_knowledge_graph.yamlnew file mode 100644index 0000000..d90e570--- /dev/null+++ b/hyperextract/templates/presets/history/historical_knowledge_graph.yaml@@ -0,0 +1,83 @@+name: "HistoricalKnowledgeGraph"+autotype: graph+tag: [history]++language: zh++description:+ zh: "历史人物关系图 - 提取基础的人物关系(亲属、君臣、敌友)及事件因果"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "人物姓名"+ - name: title+ type: "string"+ description:+ zh: "身份或官职,如吴国大都督、刘备军师"+ - name: faction+ type: "string"+ description:+ zh: "所属阵营,如吴、蜀、魏"+ - name: description+ type: "string"+ description:+ zh: "人物简要描述,包括主要成就和特点"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源人物姓名"+ - name: target+ type: "string"+ description:+ zh: "目标人物姓名"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:亲属、君臣、敌友、联盟、对手"+ - name: description+ type: "string"+ description:+ zh: "关系描述,描述两人之间的具体互动或关系详情"++extraction_guide:+ target:+ zh: |+ 你是一位专业的历史学专家,请从文本中提取所有历史人物以及他们之间的关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致++ rules_for_nodes:+ zh: |+ - 历史人物要包含所属阵营信息++ rules_for_edges:+ zh: |+ - 亲属:血缘或姻亲关系+ - 君臣:君臣关系+ - 敌友:敌对或友好关系+ - 联盟:联盟关系+ - 对手:对手关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}({faction})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/history/memory_flashback_list.yaml b/hyperextract/templates/presets/history/memory_flashback_list.yamlnew file mode 100644index 0000000..edcc639--- /dev/null+++ b/hyperextract/templates/presets/history/memory_flashback_list.yaml@@ -0,0 +1,57 @@+name: "MemoryFlashbackList"+autotype: list+tag: [history]++language: zh++description:+ zh: "回忆片段清单 - 提取口述中提到的具体轶事、感悟或对特定历史时刻的侧面描写"++item_schema:+ fields:+ - name: content+ type: "string"+ description:+ zh: "回忆内容原文"+ - name: type+ type: "string"+ description:+ zh: "类型:轶事、感悟、历史时刻、人物描写"+ - name: time+ type: "string"+ description:+ zh: "相关时间"+ required: false+ - name: location+ type: "string"+ description:+ zh: "相关地点"+ required: false+ - name: emotion+ type: "string"+ description:+ zh: "情感色彩:感慨、怀念、愤慨、欣慰"+ required: false+ - name: description+ type: "string"+ description:+ zh: "补充描述"+ required: false++extraction_guide:+ target:+ zh: |+ 请从文本中提取口述历史或回忆录中的回忆片段。++ rules:+ zh: |+ 1. 每个条目对应一个独立的回忆片段+ 2. 内容应与原文保持一致++ rules_for_nodes:+ zh: |+ - 类型:轶事、感悟、历史时刻、人物描写+ - 情感色彩:感慨、怀念、愤慨、欣慰++display:+ label: "content"diff --git a/hyperextract/templates/presets/history/multi_participant_event_map.yaml b/hyperextract/templates/presets/history/multi_participant_event_map.yamlnew file mode 100644index 0000000..9e1a66f--- /dev/null+++ b/hyperextract/templates/presets/history/multi_participant_event_map.yaml@@ -0,0 +1,85 @@+name: "MultiParticipantEventMap"+autotype: hypergraph+tag: [history]++language: zh++description:+ zh: "多方事件超图 - 将历史事件建模为连接多个参与者的超边结构"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "参与者姓名或名称"+ - name: role+ type: "string"+ description:+ zh: "角色定位,如主将、谋士、使者、参战方"+ - name: faction+ type: "string"+ description:+ zh: "所属阵营"+ required: false+ - name: description+ type: "string"+ description:+ zh: "参与者描述,包括身份背景和在事件中的角色说明"+ required: false++edge_schema:+ fields:+ - name: eventName+ type: "string"+ description:+ zh: "事件名称,如赤壁之战、鸿门宴"+ - name: time+ type: "string"+ description:+ zh: "发生时间,如建安十三年冬"+ - name: location+ type: "string"+ description:+ zh: "发生地点"+ - name: description+ type: "string"+ description:+ zh: "事件概述,描述事件背景、经过和结果"+ - name: participants+ type: "array"+ description:+ zh: "参与者列表,与节点对应"++extraction_guide:+ target:+ zh: |+ 你是一位专业的历史学专家,请从文本中提取历史事件中的参与者以及他们组成的事件超边。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边必须连接2个或以上的参与者++ rules_for_nodes:+ zh: |+ - 参与者要标注角色定位+ - 参与者要标注所属阵营++ rules_for_edges:+ zh: |+ - 一个超边代表一个完整的历史事件+ - 需要包含事件的时间、地点、背景和结果++identifiers:+ node_id: "name"+ edge_id: "eventName"+ edge_members: "participants"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}({role})"+ edge_label: "eventName"diff --git a/hyperextract/templates/presets/history/narrative_relation_graph.yaml b/hyperextract/templates/presets/history/narrative_relation_graph.yamlnew file mode 100644index 0000000..5f0f7f7--- /dev/null+++ b/hyperextract/templates/presets/history/narrative_relation_graph.yaml@@ -0,0 +1,80 @@+name: "NarrativeRelationGraph"+autotype: graph+tag: [history]++language: zh++description:+ zh: "叙事关系图 - 提取口述者主观视角下的人物互动与评价关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "人物姓名"+ - name: description+ type: "string"+ description:+ zh: "人物描述"+ - name: perspective+ type: "string"+ description:+ zh: "视角人物对该人物的评价或印象"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源人物"+ - name: target+ type: "string"+ description:+ zh: "目标人物"+ - name: interaction+ type: "string"+ description:+ zh: "互动类型:评价、往来、合作、书信"+ - name: content+ type: "string"+ description:+ zh: "互动内容或评价具体描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的历史学专家,请从文本中提取口述历史或回忆录中的人物以及他们之间的互动与评价关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从提取的实体中创建边++ rules_for_nodes:+ zh: |+ - 人物要包含描述信息+ - 视角人物的评价或印象要记录++ rules_for_edges:+ zh: |+ - 评价:对人物的评价+ - 往来:往来互动+ - 合作:合作关系+ - 书信:书信往来++identifiers:+ node_id: "name"+ edge_id: "{source}|{interaction}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "name"+ edge_label: "{interaction}"diff --git a/hyperextract/templates/presets/history/personal_trajectory_hypergraph.yaml b/hyperextract/templates/presets/history/personal_trajectory_hypergraph.yamlnew file mode 100644index 0000000..190f14c--- /dev/null+++ b/hyperextract/templates/presets/history/personal_trajectory_hypergraph.yaml@@ -0,0 +1,79 @@+name: "PersonalTrajectoryHypergraph"+autotype: hypergraph+tag: [history]++language: zh++description:+ zh: "个人轨迹超图 - 以人生阶段为超边,关联时期、地点、同行人物、核心经历。"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "人物姓名"+ - name: description+ type: "string"+ description:+ zh: "人物描述"+ required: false++edge_schema:+ fields:+ - name: phase+ type: "string"+ description:+ zh: "人生阶段名称,如少年求学、仕途起步、流放岁月"+ - name: time+ type: "string"+ description:+ zh: "时期"+ - name: locations+ type: "str"+ description:+ zh: "地点"+ - name: companions+ type: "array"+ description:+ zh: "同行或交往人物"+ - name: experiences+ type: "array"+ description:+ zh: "核心经历列表"+ required: false+ - name: description+ type: "string"+ description:+ zh: "阶段描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的历史学专家,请从文本中提取人物的人生阶段轨迹。++ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边必须关联一个主要人物+ 4. 仅从已知人物列表中提取边,不要创建未列出的人物+ 5. 关系描述应与原文保持一致++ rules_for_edges:+ zh: |+ - 一个超边代表一个完整的人生阶段+ - 需要包含时间范围、地点、关键事件++identifiers:+ node_id: "name"+ edge_id: "{phase}|{time}|{locations}"+ edge_members: "companions"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "name"+ edge_label: "phaseName"diff --git a/hyperextract/templates/presets/history/political_struggle_hypergraph.yaml b/hyperextract/templates/presets/history/political_struggle_hypergraph.yamlnew file mode 100644index 0000000..b6d027f--- /dev/null+++ b/hyperextract/templates/presets/history/political_struggle_hypergraph.yaml@@ -0,0 +1,104 @@+name: "PoliticalStruggleHypergraph"+autotype: hypergraph+tag: [history]++language: zh++description:+ zh: "政治博弈超图 - 针对战役或政争,提取攻方、守方、策划者、变节者的复杂互动"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "人物姓名"+ - name: role+ type: "string"+ description:+ zh: "角色定位:攻方、守方、策划者、变节者、调解者"+ - name: faction+ type: "string"+ description:+ zh: "所属阵营"+ required: false+ - name: description+ type: "string"+ description:+ zh: "人物描述"++edge_schema:+ fields:+ - name: eventName+ type: "string"+ description:+ zh: "事件名称"+ - name: attackers+ type: "array"+ description:+ zh: "攻方列表"+ - name: defenders+ type: "array"+ description:+ zh: "守方列表"+ - name: planners+ type: "array"+ description:+ zh: "策划者列表"+ required: false+ - name: turncoats+ type: "array"+ description:+ zh: "变节者列表"+ required: false+ - name: time+ type: "string"+ description:+ zh: "时间"+ - name: location+ type: "string"+ description:+ zh: "地点"+ - name: outcome+ type: "string"+ description:+ zh: "结果描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的历史学专家,请从文本中提取政治博弈或战役中的人物以及他们组成的博弈事件超边。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边必须包含攻方和守方++ rules_for_nodes:+ zh: |+ - 角色定位:攻方、守方、策划者、变节者、调解者+ - 参与者要标注所属阵营++ rules_for_edges:+ zh: |+ - 攻方:主动发起进攻或挑战的一方+ - 守方:被动防守或应战的一方+ - 策划者:幕后策划或出谋划策的人+ - 变节者:中途倒戈或背叛的人++identifiers:+ node_id: "name"+ edge_id: "eventName"+ edge_members:+ - "attackers"+ - "defenders"+ - "planners"+ - "turncoats"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{role}]"+ edge_label: "eventName"diff --git a/hyperextract/templates/presets/industry/emergency_response_graph.yaml b/hyperextract/templates/presets/industry/emergency_response_graph.yamlnew file mode 100644index 0000000..71c47ab--- /dev/null+++ b/hyperextract/templates/presets/industry/emergency_response_graph.yaml@@ -0,0 +1,108 @@+name: "EmergencyResponseGraph"+autotype: graph+tag: [industry]++language: zh++description:+ zh: "应急预案图谱 - 提取事故场景、响应动作和部门,构建应急响应流程,识别应急响应的流程和责任分工"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(如:火灾、停电、报警、疏散人员、设备部等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类别:事故场景、响应动作、部门"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "对该实体的描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体名称(事故场景或响应动作)"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体名称(响应动作或部门)"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:触发、执行、负责"+ required: true+ default: ""+ - name: time_limit+ type: "string"+ description:+ zh: "响应时间要求(如:5分钟内、10分钟内)"+ required: false+ default: ""+ - name: success_criterion+ type: "string"+ description:+ zh: "成功标准(如:人员安全撤离、火势控制)"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业应急管理分析专家,请从文本中提取事故场景、响应动作和部门,构建应急响应流程。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别事故场景(如火灾、泄漏、停电、设备故障、人员受伤等)+ 6. 识别响应动作(如报警、疏散人员、关闭电源等)+ 7. 识别负责部门(如安保部、设备部、急救部、后勤部等)+ 8. 建立从事故场景到响应动作的流程关系+ 9. 记录时间要求和成功标准+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别事故场景名称(如火灾、泄漏、停电、设备故障)+ 4. 识别响应动作名称(如报警、疏散人员、关闭电源)+ 5. 识别负责部门名称(如安保部、设备部、急救部)+ 6. 为每个实体指定类别(事故场景/响应动作/部门)+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别从事故场景到响应动作的关联+ 4. 识别从响应动作到负责部门的关联+ 5. 记录响应时间要求+ 6. 记录成功标准++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/industry/equipment_topology_graph.yaml b/hyperextract/templates/presets/industry/equipment_topology_graph.yamlnew file mode 100644index 0000000..f3b3e25--- /dev/null+++ b/hyperextract/templates/presets/industry/equipment_topology_graph.yaml@@ -0,0 +1,119 @@+name: "EquipmentTopologyGraph"+autotype: graph+tag: [industry]++language: zh++description:+ zh: "设备拓扑图谱 - 提取工业设备的实体及其相互连接关系,包括物料流向、能量传递、控制信号等"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "设备或部件名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类别:主机、辅机、部件、仪表、阀门、管路、系统、电机、泵、风机、容器等"+ required: true+ default: ""+ - name: location+ type: "string"+ description:+ zh: "安装位置(如:生产车间一层、主厂房二层)"+ required: false+ default: ""+ - name: status+ type: "string"+ description:+ zh: "运行状态:运行、备用、检修、停运"+ required: false+ default: ""+ - name: specification+ type: "string"+ description:+ zh: "规格型号或技术参数"+ required: false+ default: ""+ - name: manufacturer+ type: "string"+ description:+ zh: "制造厂家"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "上游设备或源设备名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "下游设备或目标设备名称"+ required: true+ default: ""+ - name: connectionType+ type: "string"+ description:+ zh: "连接类型:物料输送、能量传递、控制信号、工艺流程、电气连接、仪表监测等"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "连接关系的详细描述(如:高温物料流向、循环水回路、闭环控制系统)"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业设备管理专家,请从文本中提取设备实体及其相互连接关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的设备,禁止将多个设备合并为一个节点+ 2. 设备名称与原文保持一致+ 3. 仅从已知设备列表中提取边,不要创建新的设备节点+ 4. 关系描述应与原文保持一致+ 5. 识别所有设备、部件和系统+ 6. 分类设备类型(主机/辅机/部件/仪表/阀门/管路/系统/电机/泵/风机/容器等)+ 7. 提取设备之间的连接关系,包括物料输送、能量传递、控制信号等+ 8. 记录安装位置和运行状态+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的设备,禁止将多个设备合并为一个节点+ 2. 设备名称与原文保持一致+ 3. 识别设备名称和部件名称+ 4. 分类设备类别(主机、辅机、部件、仪表、阀门、管路、系统、电机、泵、风机、容器等)+ 5. 记录安装位置和运行状态+ rules_for_edges:+ zh: |+ 1. 仅从已知设备列表中提取边,不要创建新的设备节点+ 2. 关系描述应与原文保持一致+ 3. 识别物料输送关系(上游→下游)+ 4. 识别能量传递关系(驱动设备→被驱动设备)+ 5. 识别控制信号关系(控制设备→被控设备)+ 6. 识别工艺流程关系(前一工序→后一工序)+ 7. 识别电气连接和仪表监测关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{connectionType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{connectionType}"diff --git a/hyperextract/templates/presets/industry/failure_case_graph.yaml b/hyperextract/templates/presets/industry/failure_case_graph.yamlnew file mode 100644index 0000000..07625b0--- /dev/null+++ b/hyperextract/templates/presets/industry/failure_case_graph.yaml@@ -0,0 +1,108 @@+name: "FailureCaseGraph"+autotype: graph+tag: [industry]++language: zh++description:+ zh: "故障案例图谱 - 提取故障现象、原因、措施和教训,识别从发现到处理的完整故障演进链条"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "现象/措施等实体的名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类别:现象、原因、措施、教训"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "对该实体内涵的进一步阐述和说明"+ required: false+ default: ""+ - name: equipment+ type: "string"+ description:+ zh: "涉及设备名称"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "上游环节名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "下游环节名称"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:导致、采取、产生、发现"+ required: true+ default: ""+ - name: time_sequence+ type: "string"+ description:+ zh: "时序关系:发现、分析、处理、总结"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业设备故障分析专家,请从文本中提取故障现象、原因、处理措施和经验教训。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别故障现象和异常表现+ 6. 分析故障原因和根本原因+ 7. 提取处理措施和解决方案+ 8. 总结经验教训和改进建议+ 9. 建立从发现到处理的完整链条+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别故障现象和异常表现+ 4. 识别故障原因和根本原因+ 5. 识别处理措施和解决方案+ 6. 识别经验教训和改进建议+ 7. 记录涉及的设备名称+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别从现象到原因的关联+ 4. 识别从原因到措施的关联+ 5. 识别从措施到教训的关联++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/industry/failure_knowledge_hypergraph.yaml b/hyperextract/templates/presets/industry/failure_knowledge_hypergraph.yamlnew file mode 100644index 0000000..e56b5b4--- /dev/null+++ b/hyperextract/templates/presets/industry/failure_knowledge_hypergraph.yaml@@ -0,0 +1,93 @@+name: "FailureKnowledgeHypergraph"+autotype: hypergraph+tag: [industry]++language: zh++description:+ zh: "故障知识超图 - 从故障案例中提取故障现象、根因、部件、解决方案的复杂关联关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(例如:振动异常、轴承损坏密封失效等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类型:故障现象、根因、部件、解决方案"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "描述(例如:表现为轴承温度升高、由于润滑不良导致)"+ required: false+ default: ""++edge_schema:+ fields:+ - name: nodes+ type: "array"+ description:+ zh: "参与故障推理的节点列表:[故障现象1, 故障现象2, ..., 根因, 部件, 解决方案1, 解决方案2, ...]"+ required: true+ default: ""+ - name: reasoning_type+ type: "string"+ description:+ zh: "推理类型:故障诊断、原因分析、解决方案"+ required: true+ default: ""+ - name: failure_description+ type: "string"+ description:+ zh: "故障详细描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位设备故障诊断专家,请从故障案例中提取故障知识实体和故障诊断推理作为超边。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 识别故障现象(振动异常、噪音、温度升高、泄漏、异响)+ 5. 识别故障根因(润滑不良、过载、磨损、老化、设计缺陷)+ 6. 识别故障部件(轴承、密封、电机、泵体、阀门)+ 7. 识别解决方案(更换备件、调整参数、清洁、紧固)+ 8. 建立从现象→根因→解决方案的完整推理链条+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别故障现象(振动异常、噪音、温度升高、泄漏、异响)+ 4. 识别故障根因(润滑不良、过载、磨损、老化、设计缺陷)+ 5. 识别故障部件(轴承、密封、电机、泵体、阀门)+ 6. 识别解决方案(更换备件、调整参数、清洁、紧固)+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别故障现象(振动异常、噪音、温度升高、泄漏、异响)+ 4. 识别从现象到根因的推理+ 5. 识别从根因到解决方案的推理+ 6. 边的 nodes 字段应包含所有参与该故障推理的实体++identifiers:+ node_id: "name"+ edge_id: "{reasoning_type}_{nodes}"+ edge_members: "nodes"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{reasoning_type}"diff --git a/hyperextract/templates/presets/industry/incident_causality_map.yaml b/hyperextract/templates/presets/industry/incident_causality_map.yamlnew file mode 100644index 0000000..ca60b09--- /dev/null+++ b/hyperextract/templates/presets/industry/incident_causality_map.yaml@@ -0,0 +1,102 @@+name: "IncidentCausalityMap"+autotype: hypergraph+tag: [industry]++language: zh++description:+ zh: "事故因果链超图 - 从事故调查报告中提取隐患、触发条件、违章行为、事故后果的因果关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(例如:违章操作、泄漏积累、点火源等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类型:隐患、触发条件、违章行为、事故后果"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "描述(例如:未佩戴安全带、管道腐蚀破裂)"+ required: false+ default: ""+ - name: severity+ type: "string"+ description:+ zh: "严重程度:轻微、一般、严重、重大"+ required: false+ default: ""++edge_schema:+ fields:+ - name: nodes+ type: "array"+ description:+ zh: "参与因果链条的节点列表:[隐患1, 隐患2, ..., 触发条件, 违章行为, 事故后果1, 事故后果2, ...]"+ required: true+ default: ""+ - name: causality_type+ type: "string"+ description:+ zh: "因果类型:隐患积累、触发导致、违章促成、后果扩展"+ required: true+ default: ""+ - name: causality_description+ type: "string"+ description:+ zh: "因果关系详细描述(例如:由于管道腐蚀导致泄漏,遇火源引发火灾)"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业安全事故调查专家,请从事故调查报告中提取实体和事故因果链条作为超边。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 识别隐患(设备老化、防护缺失、管理漏洞、安全培训不足)+ 5. 识别触发条件(点火源、静电、明火、高温)+ 6. 识别违章行为(违章操作、违章指挥、违反劳动纪律)+ 7. 识别事故后果(人员伤亡、设备损坏、环境污染、停产损失)+ 8. 建立完整的因果链条:隐患 → 触发条件 → 违章行为 → 事故后果+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别隐患(设备老化、防护缺失、管理漏洞、安全培训不足)+ 4. 识别触发条件(点火源、静电、明火、高温)+ 5. 识别违章行为(违章操作、违章指挥、违反劳动纪律)+ 6. 识别事故后果(人员伤亡、设备损坏、环境污染、停产损失)+ 7. 为实体指定严重程度+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别隐患积累过程+ 4. 识别触发条件的作用+ 5. 识别违章行为的促成作用+ 6. 识别事故后果的扩展+ 7. 建立完整的因果链条:隐患 → 触发条件 → 违章行为 → 事故后果+ 8. 边的 nodes 字段应包含所有参与该因果链条的实体++identifiers:+ node_id: "name"+ edge_id: "{causality_type}_{nodes}"+ edge_members: "nodes"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{causality_type}"diff --git a/hyperextract/templates/presets/industry/inspection_record_graph.yaml b/hyperextract/templates/presets/industry/inspection_record_graph.yamlnew file mode 100644index 0000000..9b162d7--- /dev/null+++ b/hyperextract/templates/presets/industry/inspection_record_graph.yaml@@ -0,0 +1,97 @@+name: "InspectionRecordGraph"+autotype: graph+tag: [industry]++language: zh++description:+ zh: "巡检记录图谱 - 提取设备和巡检项,构建巡检层级结构,识别设备与巡检项之间的从属关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(如:数控加工中心、机械臂系统、电机运行状态、轴承温度检查等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类别:设备、巡检项"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "对该实体的描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "父实体(整体/设备)名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "子实体(巡检项/部分)名称"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:属于、子类"+ required: true+ default: ""+ - name: details+ type: "string"+ description:+ zh: "关系详细说明"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业设备巡检分析专家,请从文本中提取设备和巡检项,构建巡检层级结构。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别大设备(如数控加工中心、机械臂系统、物料输送系统等)+ 6. 识别每个设备下的巡检项(如电机运行状态、轴承温度、冷却液位等)+ 7. 建立巡检项与设备之间的从属关系+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别设备名称(大类)+ 4. 识别巡检项名称(具体检查点)+ 5. 为每个实体指定类别(设备/巡检项)+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别巡检项与设备之间的从属关系+ 4. 例如:电机运行状态 属于 数控加工中心++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/industry/maintenace_operation_map.yaml b/hyperextract/templates/presets/industry/maintenace_operation_map.yamlnew file mode 100644index 0000000..e3a87bb--- /dev/null+++ b/hyperextract/templates/presets/industry/maintenace_operation_map.yaml@@ -0,0 +1,113 @@+name: "MaintenaceOperationMap"+autotype: hypergraph+tag: [industry]++language: zh++description:+ zh: "维修作业图 - 从维修作业指导书中提取操作人、工具、对象、耗时的复杂关联关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(例如:维修工李四、扳手、离心泵P-101、润滑油等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类型:人员、工具、设备、材料、备件、岗位"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "描述或规格(例如:高级维修工、16mm开口扳手、15kW离心泵)"+ required: false+ default: ""++edge_schema:+ fields:+ - name: nodes+ type: "array"+ description:+ zh: "参与作业的节点列表:[操作人员, 工具1, 工具2, 设备, 材料1, ...]"+ required: true+ default: ""+ - name: operation_name+ type: "string"+ description:+ zh: "作业名称或步骤(例如:更换轴承、清洗过滤器、添加润滑油)"+ required: true+ default: ""+ - name: duration+ type: "string"+ description:+ zh: "作业耗时(例如:30分钟、2小时、半天)"+ required: false+ default: ""+ - name: prerequisite+ type: "string"+ description:+ zh: "前置条件或注意事项(例如:需停机断电、需佩戴防护用品)"+ required: false+ default: ""+ - name: quality_standard+ type: "string"+ description:+ zh: "质量标准或验收要求(例如:运转正常无异响、螺栓紧固力矩达标)"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位设备维修管理专家,请从维修作业指导书中提取实体和维修作业中的复杂关联作为超边。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 识别维修人员(维修工、班组长、技术员)+ 5. 识别工具(扳手、螺丝刀、千斤顶、测量仪器)+ 6. 识别设备(离心泵、电机、阀门)+ 7. 识别材料(润滑油、密封胶、清洁剂)+ 8. 识别备件(轴承、密封圈、滤芯)+ 9. 识别维修作业步骤(更换轴承、清洗过滤器、添加润滑油)+ 10. 关联操作人员和工具+ 11. 关联设备和材料/备件+ 12. 提取作业耗时+ 13. 记录前置条件和质量标准+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别维修人员(维修工、班组长、技术员)+ 4. 识别工具(扳手、螺丝刀、千斤顶、测量仪器)+ 5. 识别设备(离心泵、电机、阀门)+ 6. 识别材料(润滑油、密封胶、清洁剂)+ 7. 识别备件(轴承、密封圈、滤芯)+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别维修作业步骤(更换轴承、清洗过滤器、添加润滑油)+ 4. 关联操作人员和工具+ 5. 关联设备和材料/备件+ 6. 提取作业耗时+ 7. 记录前置条件和质量标准+ 8. 边的 nodes 字段应包含所有参与该作业的实体++identifiers:+ node_id: "name"+ edge_id: "{operation_name}_{nodes}"+ edge_members: "nodes"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{operation_name}"diff --git a/hyperextract/templates/presets/industry/operating_mode_graph.yaml b/hyperextract/templates/presets/industry/operating_mode_graph.yamlnew file mode 100644index 0000000..027abbb--- /dev/null+++ b/hyperextract/templates/presets/industry/operating_mode_graph.yaml@@ -0,0 +1,113 @@+name: "OperatingModeGraph"+autotype: graph+tag: [industry]++language: zh++description:+ zh: "工况切换图谱 - 提取工况类型和切换条件,识别不同工况之间的切换条件和步骤"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(如:自动运行模式、手动调试模式、待机模式、紧急停止模式、按下启动按钮、按下停止按钮、发生故障等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类别:工况、条件。工况如自动运行、手动调试、待机等;条件如启动按钮、停止按钮、故障信号等"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "对该实体的描述"+ required: false+ default: ""+ - name: load_range+ type: "string"+ description:+ zh: "负荷范围(如:0-50%、50-80%、80-100%等),仅对工况类别有效"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体名称(工况或条件)"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体名称(工况或条件)"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:切换到、触发"+ required: true+ default: ""+ - name: transition_condition+ type: "string"+ description:+ zh: "切换条件(如:按下启动按钮、按下停止按钮、发生故障等)"+ required: false+ default: ""+ - name: transition_procedure+ type: "string"+ description:+ zh: "切换步骤"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业设备工况分析专家,请从文本中提取工况和条件实体,以及它们之间的关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别各种运行模式(工况),如自动运行、手动调试、待机、紧急停止等+ 6. 识别各种触发条件,如按下启动按钮、按下停止按钮、发生故障等+ 7. 识别每种工况的适用条件和负荷范围+ 8. 提取工况之间的切换关系(切换到)+ 9. 提取条件触发工况的关系(触发)+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别工况名称(如自动运行模式、手动调试模式、待机模式、紧急停止模式等)+ 4. 识别条件名称(如按下启动按钮、按下停止按钮、发生故障、恢复正常等)+ 5. 为每个实体指定类别(工况/条件)+ 6. 记录每种工况的负荷范围+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别工况之间的切换关系(源工况 切换到 目标工况)+ 4. 识别条件对工况的触发关系(条件 触发 目标工况)+ 5. 关系类型使用 切换到 或 触发++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/industry/operation_flow_graph.yaml b/hyperextract/templates/presets/industry/operation_flow_graph.yamlnew file mode 100644index 0000000..a2e9aea--- /dev/null+++ b/hyperextract/templates/presets/industry/operation_flow_graph.yaml@@ -0,0 +1,119 @@+name: "OperationFlowGraph"+autotype: graph+tag: [industry]++language: zh++description:+ zh: "操作流程图谱 - 提取操作步骤、设备状态和预期结果,识别操作流程中的步骤顺序和状态变化"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "操作步骤名称(如:开启辅助电源、启动液压系统、检查状态、关闭主电源等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类别:动作、设备状态。动作如开启、关闭、检查等;设备状态如运行中、待机、停止等"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "对该操作步骤的详细描述"+ required: false+ default: ""+ - name: expected_result+ type: "string"+ description:+ zh: "执行该步骤后的预期结果"+ required: false+ default: ""+ - name: target_equipment+ type: "string"+ description:+ zh: "涉及的目标设备名称"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "当前步骤名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "下一步骤名称"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:下一步、触发、导致"+ required: true+ default: ""+ - name: trigger_condition+ type: "string"+ description:+ zh: "触发下一步骤的条件"+ required: false+ default: ""+ - name: state_change+ type: "string"+ description:+ zh: "状态变化描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业操作流程分析专家,请从文本中提取操作步骤、设备状态和预期结果。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别各个操作步骤和执行顺序(如:开启辅助电源 → 启动液压系统 → 启动控制系统)+ 6. 识别设备状态变化(如:从待机状态切换到运行状态)+ 7. 记录每一步骤的详细操作内容、预期结果和涉及设备+ 8. 建立步骤之间的流转关系+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别操作步骤名称(如开启辅助电源、启动液压系统、检查状态、关闭主电源等)+ 4. 识别设备状态名称(如运行中、待机、停止、故障等)+ 5. 为每个实体指定类别(动作/设备状态)+ 6. 记录每一步骤的预期结果和涉及设备+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别步骤的执行顺序(当前步骤 → 下一步骤)+ 4. 提取触发下一步骤的条件+ 5. 记录设备状态的变化+ 6. 关系类型使用:下一步、触发、导致++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/industry/part_replacement_list.yaml b/hyperextract/templates/presets/industry/part_replacement_list.yamlnew file mode 100644index 0000000..c016fb0--- /dev/null+++ b/hyperextract/templates/presets/industry/part_replacement_list.yaml@@ -0,0 +1,70 @@+name: "PartReplacementList"+autotype: list+tag: [industry]++language: zh++description:+ zh: "备件消耗清单 - 从设备维护记录中提取零件型号、数量、更换原因"++item_schema:+ fields:+ - name: part_name+ type: "string"+ description:+ zh: "备件名称(例如:轴承、密封圈、滤芯、润滑油、刀片等)"+ required: true+ default: ""+ - name: part_number+ type: "string"+ description:+ zh: "备件型号或编号(例如:SKF-6205、GB/T1234-2010)"+ required: false+ default: ""+ - name: quantity+ type: "string"+ description:+ zh: "更换数量(例如:2件、5升、1套)"+ required: false+ default: ""+ - name: unit+ type: "string"+ description:+ zh: "计量单位(例如:件、个、套、升、公斤)"+ required: false+ default: ""+ - name: replacement_reason+ type: "string"+ description:+ zh: "更换原因(例如:磨损、老化、损坏、预防性更换)"+ required: false+ default: ""+ - name: equipment_name+ type: "string"+ description:+ zh: "所属设备名称(例如:离心泵P-101、空压机C-001)"+ required: false+ default: ""+ - name: maintenance_type+ type: "string"+ description:+ zh: "维护类型:例行保养、故障维修、计划检修、抢修"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位设备维护管理专家,请从备件更换记录中提取所有备件消耗条目。+ rules:+ zh: |+ 1. 每个条目对应一个独立的备件,禁止合并+ 2. 备件名称和型号与原文保持一致+ 3. 提取备件名称、型号、编号+ 4. 提取更换数量和计量单位+ 5. 提取更换原因(磨损、老化、损坏、预防性更换等)+ 6. 提取所属设备名称+ 7. 识别维护类型(例行保养、故障维修、计划检修、抢修)++display:+ label: "{part_name} x{quantity} ({replacement_reason})"diff --git a/hyperextract/templates/presets/industry/safety_control_graph.yaml b/hyperextract/templates/presets/industry/safety_control_graph.yamlnew file mode 100644index 0000000..0bfcffb--- /dev/null+++ b/hyperextract/templates/presets/industry/safety_control_graph.yaml@@ -0,0 +1,118 @@+name: "SafetyControlGraph"+autotype: graph+tag: [industry]++language: zh++description:+ zh: "安全管控图谱 - 提取危险源、风险点和管控措施,构建安全管控关系,识别安全风险与管控责任的对应关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(如:数控加工中心、烫伤风险、佩戴防护用品、安全主管等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类别:危险源、风险点、管控措施、责任人"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "对该实体的描述"+ required: false+ default: ""+ - name: risk_level+ type: "string"+ description:+ zh: "风险等级:重大风险、较大风险、一般风险,仅对风险点类别有效"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体名称(危险源或风险点或管控措施)"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体名称(风险点或管控措施或责任人)"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:导致、需要、管控、负责"+ required: true+ default: ""+ - name: hazard_factor+ type: "string"+ description:+ zh: "危险因素(如:高温部件、旋转部件、高压液体等)"+ required: false+ default: ""+ - name: possible_consequence+ type: "string"+ description:+ zh: "可能导致后果(如:烫伤、机械伤害、触电等)"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业安全管理分析专家,请从文本中提取危险源、风险点和管控措施,构建安全管控关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别危险源(如数控加工中心、工业机械臂、冷却系统、液压站、电气控制柜等)+ 6. 识别风险点(如烫伤风险、机械伤害风险、触电风险、摔伤风险等)+ 7. 识别管控措施(如佩戴防护用品、设置安全围栏、定期检修、通风换气等)+ 8. 识别责任人(如安全主管、设备负责人、班组长、电工等)+ 9. 为风险点指定风险等级(重大风险、较大风险、一般风险)+ 10. 建立从危险源→风险点→管控措施→责任人的完整管控链条+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别危险源名称(如数控加工中心、工业机械臂、冷却系统、液压站、电气控制柜等)+ 4. 识别风险点名称(如烫伤风险、机械伤害风险、触电风险、摔伤风险等)+ 5. 识别管控措施名称(如佩戴防护用品、设置安全围栏、定期检修、通风换气等)+ 6. 识别责任人名称(如安全主管、设备负责人、班组长、电工等)+ 7. 为每个实体指定类别(危险源/风险点/管控措施/责任人)+ 8. 为风险点指定风险等级(重大风险、较大风险、一般风险)+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别从危险源到风险点的关联(关系类型:导致)+ 4. 识别从风险点到管控措施的关联(关系类型:需要/管控)+ 5. 识别从管控措施到责任人的关联(关系类型:负责)+ 6. 记录危险因素和可能导致后果+ 7. 关系类型使用:导致、需要、管控、负责++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/industry/safety_timeline.yaml b/hyperextract/templates/presets/industry/safety_timeline.yamlnew file mode 100644index 0000000..01f592e--- /dev/null+++ b/hyperextract/templates/presets/industry/safety_timeline.yaml@@ -0,0 +1,122 @@+name: "SafetyTimeline"+autotype: temporal_graph+tag: [industry]++language: zh++description:+ zh: "事故时序图 - 从事故调查报告中提取时间线,还原事故发生前后的操作与响应序列"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ required: true+ default: ""+ - name: entity_type+ type: "string"+ description:+ zh: "类型:人员、设备、设施等"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体名称"+ required: true+ default: ""+ - name: action+ type: "string"+ description:+ zh: "操作动作"+ required: true+ default: ""+ - name: timestamp+ type: "string"+ description:+ zh: "动作发生时间"+ required: false+ default: ""+ - name: location+ type: "string"+ description:+ zh: "发生位置"+ required: false+ default: ""+ - name: status+ type: "string"+ description:+ zh: "状态描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业安全事故调查专家,请从事故调查报告中提取时间线,还原事故发生前后的操作与响应序列。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别事故相关人员(操作工、班组长、安全员、管理人员)+ 6. 识别相关设备(泵、电机、阀门、仪表)+ 7. 识别操作动作(启动、停止、巡检、维修、发现异常)+ 8. 识别环境状态(正常、异常、报警、危险)+ rules_for_nodes:+ zh: |+ 1. 每个节点对应一个独立实体+ 2. 实体名称与原文保持一致+ 3. 人员、设备、设施、岗位、位置等+ rules_for_edges:+ zh: |+ 1. source 和 target 都必须是已知实体列表中的节点+ 2. 每个操作动作都必须提取为一条边+ 3. 节点名称必须完全匹配+ 4. 操作类型:启动、停止、开启、关闭、巡检、检查、排查、维修、检修、保养、发现、识别、报告、操作、使用、触发+ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "事故前30分钟" → {observation_time} 前30分钟+ - "当天上午" → {observation_time} 当天上午+ - "随后" → 接续前一事件++ 2. 精确时间 → 保持原样+ 3. 时间缺失 → 留空,不要猜测++identifiers:+ node_id: "name"+ edge_id: "{source}|{action}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "timestamp"++parameters:+ extraction_mode: "two_stage"+ # observation_time 和 observation_location 由用户在运行时提供+ # 示例:TemplateFactory.create(config, llm, embedder, observation_time="2024-06-15")++display:+ node_label: "{name} ({entity_type})"+ edge_label: "{action} [{timestamp}]"diff --git a/hyperextract/templates/presets/industry/spec_parameter_table.yaml b/hyperextract/templates/presets/industry/spec_parameter_table.yamlnew file mode 100644index 0000000..2960b4f--- /dev/null+++ b/hyperextract/templates/presets/industry/spec_parameter_table.yaml@@ -0,0 +1,143 @@+name: "SpecParameterTable"+autotype: model+tag: [industry]++language: zh++description:+ zh: "核心规格表 - 从技术规格书中提取额定功率、材质、尺寸精度等关键技术指标"++schema:+ fields:+ - name: equipment_name+ type: "string"+ description:+ zh: "设备或产品名称(例如:数控加工中心、离心泵、变压器等)"+ required: true+ default: ""+ - name: model_number+ type: "string"+ description:+ zh: "型号或规格代号"+ required: false+ default: ""+ - name: manufacturer+ type: "string"+ description:+ zh: "制造商或供应商"+ required: false+ default: ""+ - name: rated_power+ type: "string"+ description:+ zh: "额定功率(例如:55kW、200kVA、15kW/20kW)"+ required: false+ default: ""+ - name: rated_voltage+ type: "string"+ description:+ zh: "额定电压(例如:380V、10kV、220V)"+ required: false+ default: ""+ - name: rated_current+ type: "string"+ description:+ zh: "额定电流(例如:100A、50Hz)"+ required: false+ default: ""+ - name: frequency+ type: "string"+ description:+ zh: "工作频率(例如:50Hz、60Hz)"+ required: false+ default: ""+ - name: material+ type: "string"+ description:+ zh: "主要材质或材料(例如:不锈钢304、铸铁、铝合金)"+ required: false+ default: ""+ - name: dimensions+ type: "string"+ description:+ zh: "外形尺寸或安装尺寸(例如:2000×1500×1800mm)"+ required: false+ default: ""+ - name: weight+ type: "string"+ description:+ zh: "重量或质量(例如:2500kg、5.8t)"+ required: false+ default: ""+ - name: accuracy+ type: "string"+ description:+ zh: "精度等级或精度指标(例如:±0.01mm、IT7级)"+ required: false+ default: ""+ - name: temperature_range+ type: "string"+ description:+ zh: "工作温度范围(例如:-20℃~50℃、0~80℃)"+ required: false+ default: ""+ - name: pressure_range+ type: "string"+ description:+ zh: "工作压力范围(例如:0~1.6MPa、PN16)"+ required: false+ default: ""+ - name: flow_rate+ type: "string"+ description:+ zh: "流量参数(例如:100m³/h、50L/min)"+ required: false+ default: ""+ - name: speed+ type: "string"+ description:+ zh: "转速或速度(例如:1450rpm、0.5~2m/s)"+ required: false+ default: ""+ - name: capacity+ type: "string"+ description:+ zh: "容量或处理能力(例如:500L、10m³/h)"+ required: false+ default: ""+ - name: protection_level+ type: "string"+ description:+ zh: "防护等级(例如:IP65、IP55)"+ required: false+ default: ""+ - name: insulation_class+ type: "string"+ description:+ zh: "绝缘等级(例如:F级、H级)"+ required: false+ default: ""+ - name: other_parameters+ type: "array"+ description:+ zh: "其他关键技术参数列表(如适用)"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业设备技术专家,请从技术规格书中提取所有关键技术参数。+ rules:+ zh: |+ 1. 每个对象对应一个独立的设备或产品,禁止合并+ 2. 参数值与原文保持一致+ 3. 提取设备名称、型号、制造商+ 4. 提取电气参数:额定功率、额定电压、额定电流、频率+ 5. 提取物理参数:材质、尺寸、重量、精度+ 6. 提取工况参数:温度范围、压力范围、流量、转速+ 7. 提取性能参数:容量、防护等级、绝缘等级+ 8. 保留原始单位,不要换算++display:+ label: "{equipment_name} ({model_number})"diff --git a/hyperextract/templates/presets/industry/system_compatibility_graph.yaml b/hyperextract/templates/presets/industry/system_compatibility_graph.yamlnew file mode 100644index 0000000..ca93685--- /dev/null+++ b/hyperextract/templates/presets/industry/system_compatibility_graph.yaml@@ -0,0 +1,96 @@+name: "SystemCompatibilityGraph"+autotype: hypergraph+tag: [industry]++language: zh++description:+ zh: "系统兼容性超图 - 从技术规格书中提取设备与环境、介质的对应关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(例如:离心泵P-101、不锈钢304、高温环境等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类型:设备、材质、介质、环境、连接方式"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "描述(例如:15kW离心泵、适用于清水、适用于常温)"+ required: false+ default: ""++edge_schema:+ fields:+ - name: nodes+ type: "array"+ description:+ zh: "参与兼容性关系的节点列表:[设备, 材质/介质/环境1, 材质/介质/环境2, ...]"+ required: true+ default: ""+ - name: compatibility_type+ type: "string"+ description:+ zh: "兼容性类型:材质兼容、介质适用、环境适用、连接匹配"+ required: true+ default: ""+ - name: compatibility_note+ type: "string"+ description:+ zh: "兼容性说明或限制条件(例如:需加装过滤器、建议使用O型圈)"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业设备选型专家,请从技术规格书中提取实体和设备与环境、介质的兼容性关系作为超边。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 识别设备(离心泵、压缩机、阀门、换热器)+ 5. 识别材质(不锈钢304、铸铁、铝合金、碳钢)+ 6. 识别介质(清水、污水、油品、酸碱溶液)+ 7. 识别环境(高温环境、低温环境、防爆区域、腐蚀性环境)+ 8. 识别连接方式(法兰连接、螺纹连接、焊接)+ 9. 建立设备与材质、介质、环境的兼容性关系+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别设备(离心泵、压缩机、阀门、换热器)+ 4. 识别材质(不锈钢304、铸铁、铝合金、碳钢)+ 5. 识别介质(清水、污水、油品、酸碱溶液)+ 6. 识别环境(高温环境、低温环境、防爆区域、腐蚀性环境)+ 7. 识别连接方式(法兰连接、螺纹连接、焊接)+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别设备与材质的兼容性(不锈钢泵适用于清水)+ 4. 识别设备与介质的适用性(化工泵适用于酸碱溶液)+ 5. 识别设备对环境的要求(防爆电机适用于防爆区域)+ 6. 识别连接方式的匹配+ 7. 边的 nodes 字段应包含所有参与该兼容性关系的实体++identifiers:+ node_id: "name"+ edge_id: "{compatibility_type}_{nodes}"+ edge_members: "nodes"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{compatibility_type}"diff --git a/hyperextract/templates/presets/industry/system_topology_graph.yaml b/hyperextract/templates/presets/industry/system_topology_graph.yamlnew file mode 100644index 0000000..10db873--- /dev/null+++ b/hyperextract/templates/presets/industry/system_topology_graph.yaml@@ -0,0 +1,102 @@+name: "SystemTopologyGraph"+autotype: graph+tag: [industry]++language: zh++description:+ zh: "系统拓扑图谱 - 提取工厂的厂区、系统、子系统、设备等层级结构"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称(如:A工厂、制造车间A、数控加工系统、冷却系统等)"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "类别:厂区、系统、子系统、设备"+ required: true+ default: ""+ - name: function+ type: "string"+ description:+ zh: "功能描述"+ required: false+ default: ""+ - name: capacity+ type: "string"+ description:+ zh: "容量或规模"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "上级实体名称(厂区或系统)"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "下级实体名称(系统或子系统或设备)"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:包含等"+ required: true+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位工业系统架构分析专家,请从文本中提取实体和它们之间的层级关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 识别厂区(如A工厂、B工厂)+ 6. 识别生产系统(如制造车间、加工车间)+ 7. 识别子系统(如数控加工系统、冷却系统)+ 8. 识别具体设备(如数控加工中心、机械臂、泵等)+ 9. 建立上下级的层级包含关系+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 识别厂区名称(如A工厂、B工厂)+ 4. 识别生产系统名称(如制造车间、加工车间)+ 5. 识别子系统名称(如数控加工系统、冷却系统)+ 6. 识别具体设备名称(如数控加工中心、机械臂、泵等)+ 7. 为每个实体指定类别(厂区/系统/子系统/设备)+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 识别厂区与系统之间的包含关系+ 4. 识别系统与子系统之间的包含关系+ 5. 识别子系统与设备之间的包含关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/legal/adjudication_logic.yaml b/hyperextract/templates/presets/legal/adjudication_logic.yamlnew file mode 100644index 0000000..84cebc0--- /dev/null+++ b/hyperextract/templates/presets/legal/adjudication_logic.yaml@@ -0,0 +1,101 @@+name: "AdjudicationLogic"+autotype: hypergraph+tag: [legal]++language: zh++description:+ zh: "裁判逻辑超图 - 建模法官的推理过程"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "要素名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "要素类型:事实认定、法律依据、裁判结论、主旨、证据、其他"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: logic_type+ type: "string"+ description:+ zh: "推理类型:事实认定、法律适用、因果认定、责任认定、金额计算、其他"+ required: true+ default: ""+ - name: participants+ type: "array"+ description:+ zh: "参与要素名称列表,必须使用已提取节点的 name"+ required: true+ default: ""+ - name: reasoning+ type: "string"+ description:+ zh: "推理过程描述,从事实到结论的逻辑推导"+ required: true+ default: ""+ - name: conclusion+ type: "string"+ description:+ zh: "推理结论"+ required: false+ default: ""+ - name: source_clause+ type: "string"+ description:+ zh: "裁判文书的章节位置"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的法律工作者,请从裁判文书中提取裁判要素和裁判逻辑。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的要素,禁止将多个要素合并为一个节点+ 2. 要素名称与原文保持一致+ 3. 仅从已提取节点中提取边,不要创建新名称+ 4. 超边必须包含 logic_type, participants, reasoning+ 5. participants 应包含涉及的事实认定、法律依据、裁判结论等要素+ 6. 要素类型:事实认定(法院认定的案件事实)、法律依据(适用的法律条文、司法解释等)、裁判结论(判决结果或裁定结果)、主旨(裁判的核心观点或要旨)、证据(用于证明事实的证据材料)、其他(不属于上述类别的要素)+ 7. 推理类型:事实认定(从证据推导出事实)、法律适用(将法律适用于事实)、因果认定(认定行为与结果之间的因果关系)、责任认定(认定责任主体和责任大小)、金额计算(计算赔偿金额或标的金额)、其他(不属于上述类别的推理)+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的要素,禁止将多个要素合并为一个节点+ 2. 要素名称与原文保持一致+ 3. 提取裁判文书中涉及的要素作为节点+ 4. 为每个要素指定类型+ 5. 为每个要素添加简要描述(1-2句话)+ rules_for_edges:+ zh: |+ 1. participants 必须严格使用已知裁判要素列表中的名称,不要创建新名称+ 2. 超边必须包含 logic_type, participants, reasoning+ 3. participants 应包含涉及的事实认定、法律依据、裁判结论等要素+ 4. reasoning 描述从事实到结论的逻辑推导过程++identifiers:+ node_id: "name"+ edge_id: "{logic_type}_{participants}"+ edge_members: "participants"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "[{logic_type}] {conclusion}"diff --git a/hyperextract/templates/presets/legal/beneficial_ownership_graph.yaml b/hyperextract/templates/presets/legal/beneficial_ownership_graph.yamlnew file mode 100644index 0000000..cc744e0--- /dev/null+++ b/hyperextract/templates/presets/legal/beneficial_ownership_graph.yaml@@ -0,0 +1,107 @@+name: "BeneficialOwnershipGraph"+autotype: graph+tag: [legal]++language: zh++description:+ zh: "受益所有权图谱 - 穿透多层股权结构,识别最终受益人和控制人"++node_schema:+ fields:+ - name: entity_name+ type: "string"+ description:+ zh: "实体名称,如公司名、人名"+ required: true+ default: ""+ - name: entity_type+ type: "string"+ description:+ zh: "实体类型:公司、自然人、基金、合伙企业、境外特殊目的公司"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述,如持股比例、职务"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体名称"+ required: true+ default: ""+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型:控股、参股、担任董事、执行事务合伙人、实际控制、配偶关系等"+ required: true+ default: ""+ - name: shareholding_ratio+ type: "string"+ description:+ zh: "持股比例或出资比例,如35%、1%、XX%"+ required: false+ default: ""+ - name: description+ type: "string"+ description:+ zh: "关系描述,如通过多层持股结构控制"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的反洗钱合规专员,请从文本中提取股权结构和受益所有权信息。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 实体类型:公司、自然人、基金、合伙企业、境外特殊目的公司+ 6. 包含股东、合伙人、高管、实际控制人等+ 7. 关系类型:控股(持有50%以上股份或出资额)、参股(持有一定比例股份但不构成控股)、担任董事(在公司担任董事职务)、执行事务合伙人(执行合伙事务)、实际控制(通过协议或其他安排实现实际控制)、配偶关系(夫妻关系)、其他关系(如父子、兄弟、姐妹等)+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 实体类型:公司、自然人、基金、合伙企业、境外特殊目的公司+ 4. 包含股东、合伙人、高管、实际控制人等+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 控股:持有50%以上股份或出资额+ 4. 参股:持有一定比例股份但不构成控股+ 5. 担任董事:在公司担任董事职务+ 6. 执行事务合伙人:执行合伙事务+ 7. 实际控制:通过协议或其他安排实现实际控制+ 8. 配偶关系:夫妻关系+ 9. 其他关系:如父子、兄弟、姐妹等++identifiers:+ node_id: "entity_name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{entity_name}({entity_type})"+ edge_label: "{relation_type} {shareholding_ratio}"diff --git a/hyperextract/templates/presets/legal/case_fact_timeline.yaml b/hyperextract/templates/presets/legal/case_fact_timeline.yamlnew file mode 100644index 0000000..7a900dd--- /dev/null+++ b/hyperextract/templates/presets/legal/case_fact_timeline.yaml@@ -0,0 +1,114 @@+name: "CaseFactTimeline"+autotype: temporal_graph+tag: [legal]++language: zh++description:+ zh: "案件事实时序图 - 展示法律关系的变化过程"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,如原告、被告、合同、金钱、股权等"+ required: true+ default: ""+ - name: entity_type+ type: "string"+ description:+ zh: "实体类型:当事人、合同/协议、金钱、股权、证物、其他"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体名称"+ required: true+ default: ""+ - name: event+ type: "string"+ description:+ zh: "法律行为或事件,如签订协议、支付投资款、分配红利、提起诉讼等"+ required: true+ default: ""+ - name: time_info+ type: "string"+ description:+ zh: "时间信息,统一格式为年-月-日(如2021-03-15)或年月(如2021-03)"+ required: false+ default: ""+ - name: description+ type: "string"+ description:+ zh: "事件详细描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的法律工作者,请从文本中提取案件相关的法律实体以及它们之间的法律行为。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 实体类型:当事人(原告、被告、第三人、法定代表人、委托诉讼代理人)、合同/协议(战略合作协议、补充协议、收益分配说明函等)、金钱(投资款、红利、违约金等)、股权(股份、股权等)+ 6. 法律行为:签订协议、支付投资款、完成登记、召开股东会、分配红利、发送函件、提起诉讼等+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 实体类型:当事人、合同/协议、金钱、股权、证物、其他+ 4. 当事人:原告、被告、第三人、法定代表人、委托诉讼代理人+ 5. 合同/协议:战略合作协议、补充协议、收益分配说明函等+ 6. 金钱:投资款、红利、违约金等+ 7. 股权:股份、股权等+ rules_for_edges:+ zh: |+ 1. 仅从已知法律实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 常见的法律行为:签订协议、支付投资款、完成登记、召开股东会、分配红利、发送函件、提起诉讼等+ 4. 每个边表示一个法律行为,连接相关实体+ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期)+ 2. 精确时间 → 转换为标准格式年-月-日+ 3. 时间缺失 → 留空++identifiers:+ node_id: "name"+ edge_id: "{source}|{event}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "time_info"++parameters:+ extraction_mode: "two_stage"+ # observation_time 和 observation_location 由用户在运行时提供+ # 示例:TemplateFactory.create(config, llm, embedder, observation_time="2024-06-15")++display:+ node_label: "{name}({entity_type})"+ edge_label: "{event} [{time_info}]"diff --git a/hyperextract/templates/presets/legal/case_law_citation_net.yaml b/hyperextract/templates/presets/legal/case_law_citation_net.yamlnew file mode 100644index 0000000..01a509a--- /dev/null+++ b/hyperextract/templates/presets/legal/case_law_citation_net.yaml@@ -0,0 +1,106 @@+name: "CaseLawCitationNet"+autotype: graph+tag: [legal]++language: zh++description:+ zh: "判例引用网络 - 映射案件之间的引用、先例区分或先例推翻关系"++node_schema:+ fields:+ - name: case_name+ type: "string"+ description:+ zh: "判例名称,如指导案例140号、(2020)最高法民终字第XX号"+ required: true+ default: ""+ - name: case_type+ type: "string"+ description:+ zh: "案件类型:指导案例、公报案例、普通案例、司法解释、法律条文"+ required: true+ default: ""+ - name: court+ type: "string"+ description:+ zh: "审理法院"+ required: false+ default: ""+ - name: description+ type: "string"+ description:+ zh: "案件简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源判例名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标判例名称"+ required: true+ default: ""+ - name: citation_type+ type: "string"+ description:+ zh: "引用类型:引用、依据、先例区分、先例推翻、参考、类案"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "引用关系描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的法学专家,请从文本中提取所有判例以及它们之间的引用或关联关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的判例,禁止将多个判例合并为一个节点+ 2. 判例名称与原文保持一致+ 3. 仅从已知判例列表中提取边,不要创建未列出的判例+ 4. 关系描述应与原文保持一致+ 5. 案件类型:指导案例、公报案例、普通案例、司法解释、法律条文+ 6. 常见表达:"根据《民法典》第X条"、"指导案例XX号"、"本案确立了..."+ 7. 关系类型:引用(后案引用前案作为裁判依据)、依据(后案以前案确立的规则为法律依据)、先例区分(后案认为前案与本案情形不同,不适用前案规则)、先例推翻(后案推翻前案确立的规则)、参考(后案参考前案的裁判思路)、类案(后案与前案属于同类案件)+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的判例,禁止将多个判例合并为一个节点+ 2. 判例名称与原文保持一致+ 3. 案件类型:指导案例、公报案例、普通案例、司法解释、法律条文+ 4. 常见表达:"根据《民法典》第X条"、"指导案例XX号"、"本案确立了..."+ rules_for_edges:+ zh: |+ 1. 仅从已知判例列表中提取边,不要创建未列出的判例+ 2. 关系描述应与原文保持一致+ 3. 引用:后案引用前案作为裁判依据+ 4. 依据:后案以前案确立的规则为法律依据+ 5. 先例区分:后案认为前案与本案情形不同,不适用前案规则+ 6. 先例推翻:后案推翻前案确立的规则+ 7. 参考:后案参考前案的裁判思路+ 8. 类案:后案与前案属于同类案件++identifiers:+ node_id: "case_name"+ edge_id: "{source}|{citation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{case_name}({case_type})"+ edge_label: "{citation_type}"diff --git a/hyperextract/templates/presets/legal/compliance_requirement_list.yaml b/hyperextract/templates/presets/legal/compliance_requirement_list.yamlnew file mode 100644index 0000000..514feda--- /dev/null+++ b/hyperextract/templates/presets/legal/compliance_requirement_list.yaml@@ -0,0 +1,71 @@+name: "ComplianceRequirementList"+autotype: list+tag: [legal]++language: zh++description:+ zh: "合规要求清单 - 从法规或政策文件中提取合规义务"++item_schema:+ fields:+ - name: requirement_type+ type: "string"+ description:+ zh: "要求类型:许可要求、报告要求、披露要求、禁止性规定、程序性要求、其他"+ required: true+ default: ""+ - name: requirement_title+ type: "string"+ description:+ zh: "要求标题或简要名称"+ required: true+ default: ""+ - name: content+ type: "string"+ description:+ zh: "要求的具体内容"+ required: true+ default: ""+ - name: responsible_entity+ type: "string"+ description:+ zh: "责任主体或适用对象"+ required: false+ default: ""+ - name: deadline+ type: "string"+ description:+ zh: "履行期限或截止日期"+ required: false+ default: ""+ - name: penalty+ type: "string"+ description:+ zh: "违规后果或处罚措施"+ required: false+ default: ""+ - name: source_clause+ type: "string"+ description:+ zh: "来源条款编号或章节"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的合规顾问,请从法规或政策文件中提取所有合规义务。+ rules:+ zh: |+ 1. 提取文本中所有合规要求或义务+ 2. 为每一项要求指定类型:许可要求、报告要求、披露要求、禁止性规定、程序性要求、其他+ 3. 记录要求的具体内容、责任主体、履行期限+ 4. 记录违规后果或处罚措施+ 5. 记录来源条款编号+ 6. 每项合规要求作为独立条目提取+ 7. 保持要求内容与原文一致+ 8. 不要遗漏任何合规要求++display:+ label: "[{requirement_type}] {requirement_title}"diff --git a/hyperextract/templates/presets/legal/contract_obligation_hypergraph.yaml b/hyperextract/templates/presets/legal/contract_obligation_hypergraph.yamlnew file mode 100644index 0000000..6e43be3--- /dev/null+++ b/hyperextract/templates/presets/legal/contract_obligation_hypergraph.yaml@@ -0,0 +1,107 @@+name: "ContractObligationHypergraph"+autotype: hypergraph+tag: [legal]++language: zh++description:+ zh: "合同义务超图 - 建模复杂的条件性义务"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "要素名称,文本中出现的精确名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "要素类型:主体、义务、触发条件、例外情形、违约责任、其他"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: obligation_type+ type: "string"+ description:+ zh: "义务类型:支付义务、交付义务、保密义务、竞业限制、售后服务、其他"+ required: true+ default: ""+ - name: participants+ type: "array"+ description:+ zh: "参与要素名称列表,必须使用已提取节点的 name"+ required: true+ default: ""+ - name: trigger_condition+ type: "string"+ description:+ zh: "触发条件,如合同签订后、验收合格后、违约发生时等"+ required: false+ default: ""+ - name: exception+ type: "string"+ description:+ zh: "例外情形,如不可抗力、对方违约在先等"+ required: false+ default: ""+ - name: liability+ type: "string"+ description:+ zh: "违约责任,如支付违约金、赔偿损失、解除合同等"+ required: false+ default: ""+ - name: source_clause+ type: "string"+ description:+ zh: "义务来源条款编号或名称"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的合同法律师,请从文本中提取合同要素和合同义务。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的要素,禁止将多个要素合并为一个节点+ 2. 要素名称与原文保持一致+ 3. 仅从已提取节点中提取边,不要创建新名称+ 4. 超边必须包含 obligation_type, participants+ 5. participants 应包含涉及的主体、义务及相关要素+ 6. 要素类型:主体(合同的当事人)、义务(具体需要执行的行为)、触发条件(义务生效或履行的前提条件)、例外情形(义务免除或减轻的情形)、违约责任(违反义务的后果)、其他(不属于上述类别的要素)+ 7. 义务类型:支付义务、交付义务、保密义务、竞业限制、售后服务、其他+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的要素,禁止将多个要素合并为一个节点+ 2. 要素名称与原文保持一致+ 3. 提取合同中涉及的要素作为节点+ 4. 为每个要素指定类型+ 5. 为每个要素添加简要描述(1-2句话)+ rules_for_edges:+ zh: |+ 1. participants 必须严格使用已知合同要素列表中的名称,不要创建新名称+ 2. 超边必须包含 obligation_type, participants+ 3. participants 应包含涉及的主体、义务及相关要素+ 4. 义务类型:支付义务、交付义务、保密义务、竞业限制、售后服务、其他++identifiers:+ node_id: "name"+ edge_id: "{obligation_type}_{participants}"+ edge_members: "participants"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{obligation_type}"diff --git a/hyperextract/templates/presets/legal/defined_term_registry.yaml b/hyperextract/templates/presets/legal/defined_term_registry.yamlnew file mode 100644index 0000000..6582027--- /dev/null+++ b/hyperextract/templates/presets/legal/defined_term_registry.yaml@@ -0,0 +1,50 @@+name: "DefinedTermRegistry"+autotype: set+tag: [legal]++language: zh++description:+ zh: "术语定义表 - 去重并汇总合同中定义的所有专有名词"++item_schema:+ fields:+ - name: term+ type: "string"+ description:+ zh: "术语名称,如机密信息、不可抗力、项目"+ required: true+ default: ""+ - name: definition+ type: "string"+ description:+ zh: "术语的定义说明"+ required: true+ default: ""+ - name: source_clause+ type: "string"+ description:+ zh: "定义来源的条款编号"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的合同法律师,请从文本中提取所有定义的术语,形成术语定义表。+ rules:+ zh: |+ 1. 识别合同中用引号或黑体定义的专有名词(如"机密信息"、"不可抗力")+ 2. 提取术语的定义说明+ 3. 记录定义出现的条款位置+ 4. 去重:同一术语只保留一条记录+ 5. 术语名称必须与原文保持一致(包括引号)+ 6. 仅提取真正被定义的术语,不要提取普通业务词汇+ 7. 保持客观准确,不添加文本中没有的信息+ 8. 术语类型:合同标的相关的术语(项目、软件产品、技术文档)、权利义务相关的术语(投资款、服务费、违约金)、风险相关的术语(不可抗力、机密信息)、程序相关的术语(验收标准、付款条件)++identifiers:+ item_id: "term"++display:+ label: "{term}"diff --git a/hyperextract/templates/presets/legal/legal_concept_ontology.yaml b/hyperextract/templates/presets/legal/legal_concept_ontology.yamlnew file mode 100644index 0000000..5c90e4f--- /dev/null+++ b/hyperextract/templates/presets/legal/legal_concept_ontology.yaml@@ -0,0 +1,99 @@+name: "LegalConceptOntology"+autotype: graph+tag: [legal]++language: zh++description:+ zh: "法律概念本体 - 提取法律术语的定义、上下位关系及法理阐释"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "法律概念名称,如过错、故意、过失、违法性"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "概念类型:原则、规则、学说、术语、法律依据"+ required: true+ default: ""+ - name: definition+ type: "string"+ description:+ zh: "概念的简要定义"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源概念名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标概念名称"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:上位概念、下位概念、相关联、对立、包含、依据"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "关系描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的法学专家,请从文本中提取所有法律概念以及它们之间的关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的概念,禁止将多个概念合并为一个节点+ 2. 概念名称与原文保持一致+ 3. 仅从已知概念列表中提取边,不要创建未列出的概念+ 4. 关系描述应与原文保持一致+ 5. 法律概念类型包括:原则、规则、学说、术语、法律依据+ 6. 关系类型:上位概念、下位概念、相关联、对立、包含、依据+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的概念,禁止将多个概念合并为一个节点+ 2. 概念名称与原文保持一致+ 3. 法律概念类型包括:原则、规则、学说、术语、法律依据+ 4. 常见的法律概念:过错、故意、过失、违法性、因果关系、举证责任等+ rules_for_edges:+ zh: |+ 1. 仅从已知法律概念列表中提取边,不要创建未列出的概念+ 2. 关系描述应与原文保持一致+ 3. 上位概念:概念之间的层级包含关系+ 4. 下位概念:概念之间的层级包含关系+ 5. 相关联:概念之间存在逻辑关联+ 6. 对立:概念之间存在对立关系+ 7. 包含:一个概念包含另一个概念+ 8. 依据:一个概念是另一个概念的依据++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/legal/liability_clause_list.yaml b/hyperextract/templates/presets/legal/liability_clause_list.yamlnew file mode 100644index 0000000..04fca90--- /dev/null+++ b/hyperextract/templates/presets/legal/liability_clause_list.yaml@@ -0,0 +1,59 @@+name: "LiabilityClauseList"+autotype: list+tag: [legal]++language: zh++description:+ zh: "责任条款清单 - 提取关于赔偿、责任限制、保证及免责声明的具体条款"++item_schema:+ fields:+ - name: clause_type+ type: "string"+ description:+ zh: "条款类型:赔偿条款、责任限制、保证条款、免责声明、违约金、连带责任、其他"+ required: true+ default: ""+ - name: clause_title+ type: "string"+ description:+ zh: "条款标题或简要名称"+ required: true+ default: ""+ - name: content+ type: "string"+ description:+ zh: "条款的具体内容"+ required: true+ default: ""+ - name: liability_amount+ type: "string"+ description:+ zh: "涉及的责任金额或计算方式,如合同总价的10%、人民币20万元等"+ required: false+ default: ""+ - name: source_clause+ type: "string"+ description:+ zh: "条款来源的章节编号"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的合同法律师,请从文本中提取所有关于责任、赔偿、保证的条款。+ rules:+ zh: |+ 1. 提取文本中所有关于责任分配的具体条款+ 2. 为每一条款指定类型:赔偿条款、责任限制、保证条款、免责声明、违约金、连带责任、其他+ 3. 记录条款的具体内容和涉及的责任金额+ 4. 记录条款来源的章节编号+ 5. 条款类型说明:赔偿条款(约定一方给另一方造成损失时的赔偿方式)、责任限制(限制某方承担责任的最高限额)、保证条款(一方对某事项的保证承诺)、免责声明(免除或限制某方责任的条款)、违约金(约定违约时支付的违约金)、连带责任(约定多方承担连带责任)、其他(不属于上述类别的责任条款)+ 6. 每项责任条款作为独立条目提取+ 7. 保持条款内容与原文一致+ 8. 不要遗漏任何责任相关条款++display:+ label: "[{clause_type}] {clause_title}"diff --git a/hyperextract/templates/presets/legal/litigation_participant_map.yaml b/hyperextract/templates/presets/legal/litigation_participant_map.yamlnew file mode 100644index 0000000..f93b240--- /dev/null+++ b/hyperextract/templates/presets/legal/litigation_participant_map.yaml@@ -0,0 +1,93 @@+name: "LitigationParticipantMap"+autotype: graph+tag: [legal]++language: zh++description:+ zh: "诉讼参与人图谱 - 提取原告、被告、第三人、代理律师及证人之间的关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "参与人姓名或名称"+ required: true+ default: ""+ - name: participant_type+ type: "string"+ description:+ zh: "参与人类型:原告、被告、第三人、委托诉讼代理人、法定代理人、证人、鉴定人、法官、合议庭成员"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "参与人角色描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源参与人姓名或名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标参与人姓名或名称"+ required: true+ default: ""+ - name: relation_type+ type: "string"+ description:+ zh: "关系类型:代理、代表、股东、董事、担保、上下级、同案当事人、敌对"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "关系描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的法律文书分析师,请从文本中提取诉讼参与人及其之间的关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的参与人,禁止将多个参与人合并为一个节点+ 2. 参与人名称与原文保持一致+ 3. 仅从已知参与人列表中提取边,不要创建未列出的参与人+ 4. 关系描述应与原文保持一致+ 5. 参与人类型:原告、被告、第三人、委托诉讼代理人、法定代理人、证人、鉴定人、法官、合议庭成员+ 6. 关系类型:代理、代表、股东、董事、担保、上下级、同案当事人、敌对+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的参与人,禁止将多个参与人合并为一个节点+ 2. 参与人名称与原文保持一致+ 3. 参与人类型:原告、被告、第三人、委托诉讼代理人、法定代理人、证人、鉴定人、法官、合议庭成员+ rules_for_edges:+ zh: |+ 1. 仅从已知参与人列表中提取边,不要创建未列出的参与人+ 2. 关系描述应与原文保持一致+ 3. 关系类型:代理、代表、股东、董事、担保、上下级、同案当事人、敌对++identifiers:+ node_id: "name"+ edge_id: "{source}|{relation_type}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({participant_type})"+ edge_label: "{relation_type}"diff --git a/hyperextract/templates/presets/literature/character_arc_timeline.yaml b/hyperextract/templates/presets/literature/character_arc_timeline.yamlnew file mode 100644index 0000000..46d0e2e--- /dev/null+++ b/hyperextract/templates/presets/literature/character_arc_timeline.yaml@@ -0,0 +1,87 @@+name: "CharacterArcTimeline"+autotype: graph+tag: [literature]++language: zh++description:+ zh: "叙事时序图 - 提取影视剧本中的异质节点(角色、场景、情绪、事件)及它们之间的关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "元素名称"+ - name: category+ type: "string"+ description:+ zh: "元素类型:角色、场景、情绪、事件"+ - name: description+ type: "string"+ description:+ zh: "简要描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源节点名称"+ - name: target+ type: "string"+ description:+ zh: "目标节点名称"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:出现、时间顺序、情绪、触发、位于"+ - name: time+ type: "string"+ description:+ zh: "时间点(如'第一集'、'第X场'),仅时间顺序关系需要"+ required: false+ - name: description+ type: "string"+ description:+ zh: "关系描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的影视剧本分析师,请从文本中提取叙事元素以及它们之间的关系,构建异质图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知叙事元素列表中提取边,不要创建未列出的节点++ rules_for_nodes:+ zh: |+ - 角色:从对白和动作中识别的主要人物+ - 场景:从场景头中提取的地点,如"碎玉轩"、"桐花台"、"万寿节宴会厅"+ - 情绪:角色的情感状态,如"悲伤"、"愤怒"、"坚定"、"迷茫"、"绝望"+ - 事件:关键情节,如"被陷害"、"果郡王之死"、"回宫复仇"++ rules_for_edges:+ zh: |+ - 出现:角色出现在某场景,格式:'角色 → 场景'+ - 时间顺序:两个场景的时间先后,格式:'前一场景 → 后一场景',需标注时间点+ - 情绪:角色在该场景的情绪,格式:'角色 → 情绪'+ - 触发:场景触发的事件,格式:'场景 → 事件'+ - 位于:角色位于某场景,格式:'角色 → 场景'++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/literature/complex_character_relation.yaml b/hyperextract/templates/presets/literature/complex_character_relation.yamlnew file mode 100644index 0000000..937fbd0--- /dev/null+++ b/hyperextract/templates/presets/literature/complex_character_relation.yaml@@ -0,0 +1,85 @@+name: "ComplexCharacterRelation"+autotype: hypergraph+tag: [literature]++language: zh++description:+ zh: "复杂人物关系网 - 超越两两关系,提取涉及多方的社会结构(如三角恋、结盟、家族派系)"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "人物姓名"+ - name: role+ type: "string"+ description:+ zh: "角色定位:主角、配角、反派、酱油"+ - name: faction+ type: "string"+ description:+ zh: "所属阵营或派系"+ required: false+ - name: description+ type: "string"+ description:+ zh: "人物描述"++edge_schema:+ fields:+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:三角恋、结盟、敌对、背叛、竞争、家族"+ - name: participants+ type: "array"+ description:+ zh: "参与方列表(3人或以上)"+ - name: description+ type: "string"+ description:+ zh: "关系描述"+ - name: sourceScene+ type: "string"+ description:+ zh: "来源情节"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的小说分析师,请从文本中提取人物以及它们之间的复杂关系超边。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边必须包含3个或以上参与者++ rules_for_nodes:+ zh: |+ - 角色定位:主角、配角、反派、酱油+ - 所属阵营:如"江左盟"、"太子党"、"誉王党"等++ rules_for_edges:+ zh: |+ - 三角恋:涉及三人的爱情关系+ - 结盟:多方形成的政治或军事联盟+ - 敌对:多方之间的对立关系+ - 背叛:一方背离原先的阵营或关系+ - 竞争:多方争夺同一目标+ - 家族:同一家族的成员关系++identifiers:+ node_id: "name"+ edge_id: "{relationType}|{participants}"+ edge_members: "participants"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{role}]"+ edge_label: "{relationType}: {description}"diff --git a/hyperextract/templates/presets/literature/critique_argument_hypergraph.yaml b/hyperextract/templates/presets/literature/critique_argument_hypergraph.yamlnew file mode 100644index 0000000..b538985--- /dev/null+++ b/hyperextract/templates/presets/literature/critique_argument_hypergraph.yaml@@ -0,0 +1,86 @@+name: "CritiqueArgumentHypergraph"+autotype: hypergraph+tag: [literature]++language: zh++description:+ zh: "评论论证超图 - 建模复杂的论证逻辑:{论据1, 论据2, 引用文本} -> 核心观点"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "元素名称"+ - name: category+ type: "string"+ description:+ zh: "元素类型:论据、引用、观点"+ - name: content+ type: "string"+ description:+ zh: "内容"+ - name: sourceText+ type: "string"+ description:+ zh: "原文引用(仅引用类型需要)"+ required: false++edge_schema:+ fields:+ - name: conclusion+ type: "string"+ description:+ zh: "核心观点"+ - name: evidences+ type: "array"+ description:+ zh: "论据列表"+ - name: citations+ type: "array"+ description:+ zh: "引用文本列表"+ required: false+ - name: description+ type: "string"+ description:+ zh: "论证描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的文学评论家,请从文本中提取论证元素以及它们组成的论证超边。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的元素,禁止将多个元素合并为一个节点+ 2. 元素名称与原文保持一致+ 3. 超边必须包含至少一个论据或引用+ 4. 超边必须包含核心观点++ rules_for_nodes:+ zh: |+ - 论据:支撑观点的证据或分析+ - 引用:原文中的引用文本+ - 观点:作者的核心论点++ rules_for_edges:+ zh: |+ - 论据支撑观点+ - 引用佐证论据++identifiers:+ node_id: "name"+ edge_id: "{conclusion}"+ edge_members:+ - "evidences"+ - "citations"+ - "conclusion"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "观点: {conclusion}"diff --git a/hyperextract/templates/presets/literature/motif_association_net.yaml b/hyperextract/templates/presets/literature/motif_association_net.yamlnew file mode 100644index 0000000..8cdb797--- /dev/null+++ b/hyperextract/templates/presets/literature/motif_association_net.yaml@@ -0,0 +1,75 @@+name: "MotifAssociationNet"+autotype: graph+tag: [literature]++language: zh++description:+ zh: "意象关联网络 - 提取文本中反复出现的符号、意象之间的关联"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "意象名称"+ - name: description+ type: "string"+ description:+ zh: "意象描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源意象"+ - name: target+ type: "string"+ description:+ zh: "目标意象"+ - name: associationType+ type: "string"+ description:+ zh: "关联类型:对比、递进、因果、象征、配套"+ - name: description+ type: "string"+ description:+ zh: "关联描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的文学评论家,请从文本中提取意象以及它们之间的关联关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的意象,禁止将多个意象合并为一个节点+ 2. 意象名称与原文保持一致+ 3. 仅从已知意象列表中提取边,不要创建未列出的意象++ rules_for_nodes:+ zh: |+ - 意象:反复出现的符号、象征物、自然元素等++ rules_for_edges:+ zh: |+ - 对比:两个意象形成对照或反衬+ - 递进:一个意象引出另一个意象+ - 因果:一个意象导致另一个意象出现+ - 象征:一个意象代表另一个含义+ - 配套:多个意象共同构成一个意象群++identifiers:+ node_id: "name"+ edge_id: "{source}|{associationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "name"+ edge_label: "{associationType}"diff --git a/hyperextract/templates/presets/literature/narrative_event_chain.yaml b/hyperextract/templates/presets/literature/narrative_event_chain.yamlnew file mode 100644index 0000000..fab458e--- /dev/null+++ b/hyperextract/templates/presets/literature/narrative_event_chain.yaml@@ -0,0 +1,81 @@+name: "NarrativeEventChain"+autotype: temporal_graph+tag: [literature]++language: zh++description:+ zh: "叙事事件链 - 按故事内部时间线提取关键情节转折点 (Plot Points)"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "事件名称"+ - name: description+ type: "string"+ description:+ zh: "事件描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "前置事件"+ - name: target+ type: "string"+ description:+ zh: "后续事件"+ - name: time+ type: "string"+ description:+ zh: "故事内部时间点,如'第X章'、'第X日'、'第X年'"+ - name: causeEffect+ type: "string"+ description:+ zh: "因果关系描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的小说分析师,请从文本中提取情节转折点以及它们之间的因果关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知情节列表中提取边,不要创建未列出的情节++ rules_for_nodes:+ zh: |+ - 情节转折点:改变故事走向的关键事件++ rules_for_edges:+ zh: |+ - 记录情节之间的因果关系++ rules_for_time:+ zh: |+ 当前观测时间:{observation_time}++ 1. 章节格式:如"第一章"、"第3章" → 保持原样+ 2. 日期格式:如"第一日"、"第X日" → 保持原样+ 3. 年份格式:如"第一年"、"XX年" → 保持原样+ 4. 相对时间:如"随后"、"之后" → 留空,不要猜测++identifiers:+ node_id: "name"+ edge_id: "{source}|{time}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "time"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "name"+ edge_label: "{time}: {causeEffect}"diff --git a/hyperextract/templates/presets/literature/narrative_structure_tree.yaml b/hyperextract/templates/presets/literature/narrative_structure_tree.yamlnew file mode 100644index 0000000..010ab42--- /dev/null+++ b/hyperextract/templates/presets/literature/narrative_structure_tree.yaml@@ -0,0 +1,82 @@+name: "NarrativeStructureTree"+autotype: graph+tag: [literature]++language: zh++description:+ zh: "叙事结构树 - 构建作品的结构层级(如主线、支线、插叙部分)"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "结构单元名称"+ - name: category+ type: "string"+ description:+ zh: "类型:主线、支线、插叙、前提、结局"+ - name: description+ type: "string"+ description:+ zh: "描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "上位结构"+ - name: target+ type: "string"+ description:+ zh: "下位结构"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:包含、从属、展开、转折"+ - name: description+ type: "string"+ description:+ zh: "描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的文学评论家,请从文本中提取叙事结构单元以及它们之间的层级关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的结构单元,禁止将多个单元合并为一个节点+ 2. 单元名称与原文保持一致+ 3. 仅从已知结构单元列表中提取边,不要创建未列出的单元++ rules_for_nodes:+ zh: |+ - 主线:推动故事核心发展的情节线+ - 支线:辅助主线或展现次要人物的情节线+ - 插叙:中断主线叙事的回忆或补充说明+ - 前提:故事发生的背景设定+ - 结局:故事的最终走向和结果++ rules_for_edges:+ zh: |+ - 包含:上位结构包含下位结构+ - 从属:下位结构从属于上位结构+ - 展开:上位结构展开为下位结构+ - 转折:从一线转到另一线++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/literature/scene_event_hypergraph.yaml b/hyperextract/templates/presets/literature/scene_event_hypergraph.yamlnew file mode 100644index 0000000..3b10629--- /dev/null+++ b/hyperextract/templates/presets/literature/scene_event_hypergraph.yaml@@ -0,0 +1,94 @@+name: "SceneEventHypergraph"+autotype: hypergraph+tag: [literature]++language: zh++description:+ zh: "场景事件超图 - 将一场戏建模为连接 {出场角色, 场景地点, 关键道具, 核心动作} 的超边"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "元素名称"+ - name: category+ type: "string"+ description:+ zh: "元素类型:角色、地点、道具、动作"+ - name: description+ type: "string"+ description:+ zh: "简要描述"++edge_schema:+ fields:+ - name: sceneName+ type: "string"+ description:+ zh: "场景名称,如'第一场:桐花台夜话'"+ - name: characters+ type: "array"+ description:+ zh: "出场角色列表"+ - name: location+ type: "string"+ description:+ zh: "场景地点"+ - name: props+ type: "array"+ description:+ zh: "关键道具列表"+ required: false+ - name: actions+ type: "array"+ description:+ zh: "核心动作列表"+ - name: timeOfDay+ type: "string"+ description:+ zh: "时间段:日/夜/晨/昏"++extraction_guide:+ target:+ zh: |+ 你是一位专业的影视剧本分析师,请从文本中提取场景元素以及它们组成的场景事件超边。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边必须包含至少一个角色和地点++ rules_for_nodes:+ zh: |+ - 角色:从【动作】或对白中识别的人物+ - 地点:从场景头中提取,如"碎玉轩"、"桐花台"+ - 道具:从动作描述中提取的关键物品,如"油纸伞"、"宫灯"+ - 动作:从动作描述中提取的核心行为,如"起舞"、"吟诵"++ rules_for_edges:+ zh: |+ - 出场角色:从剧本对白和动作中识别的参与人物+ - 场景地点:场景头中标注的地点+ - 关键道具:动作描述中出现的物品+ - 核心动作:角色完成的主要行为+ - 时间段:从场景头中提取,如"日"、"夜"、"晨"、"昏"++identifiers:+ node_id: "name"+ edge_id: "sceneName"+ edge_members:+ - "characters"+ - "location"+ - "props"+ - "actions"+ - "timeOfDay"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "sceneName"diff --git a/hyperextract/templates/presets/literature/story_entity_graph.yaml b/hyperextract/templates/presets/literature/story_entity_graph.yamlnew file mode 100644index 0000000..390659c--- /dev/null+++ b/hyperextract/templates/presets/literature/story_entity_graph.yaml@@ -0,0 +1,77 @@+name: "StoryEntityGraph"+autotype: graph+tag: [literature]++language: zh++description:+ zh: "故事实体图谱 - 专注于提取关键物品、地点及其归属或位置关系,与人物关系分离"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ - name: category+ type: "string"+ description:+ zh: "实体类型:物品、地点"+ - name: description+ type: "string"+ description:+ zh: "实体描述"++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "物品"+ - name: target+ type: "string"+ description:+ zh: "归属者或位置"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:归属、位于"+ - name: description+ type: "string"+ description:+ zh: "描述"++extraction_guide:+ target:+ zh: |+ 你是一位专业的小说分析师,请从文本中提取故事实体以及它们之间的关系。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体++ rules_for_nodes:+ zh: |+ - 物品:武器、书信、信物、药材等+ - 地点:城市、建筑、区域等++ rules_for_edges:+ zh: |+ - 归属:物品的所有者或使用者+ - 位于:物品的位置或地点的所在++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/medicine/adverse_reaction_stats.yaml b/hyperextract/templates/presets/medicine/adverse_reaction_stats.yamlnew file mode 100644index 0000000..a2b6655--- /dev/null+++ b/hyperextract/templates/presets/medicine/adverse_reaction_stats.yaml@@ -0,0 +1,47 @@+name: "AdverseReactionStats"+autotype: list+tag: [medicine]++language: zh++description:+ zh: "不良反应统计 - 提取各系统的不良反应表现及其发生率描述"++item_schema:+ fields:+ - name: system+ type: "string"+ description:+ zh: "系统名称,如胃肠道、全身、皮肤等"+ - name: reaction+ type: "string"+ description:+ zh: "不良反应表现"+ - name: incidence+ type: "string"+ description:+ zh: "发生率"+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的临床药师,请从文本中提取各系统的不良反应表现及其发生率描述,构建不良反应统计。++ rules:+ zh: |+ 1. 提取所有不良反应,包括系统名称、不良反应表现和发生率+ 2. 为每个不良反应添加详细描述(如果文本中提供)+ 3. 保持不良反应表现与原文一致++ rules_for_nodes:+ zh: |+ - 不良反应名称保持原文+ - 发生率表示法保持原文,如 5.2%、常见、罕见++display:+ label: "{system}: {reaction} ({incidence})"diff --git a/hyperextract/templates/presets/medicine/anatomy_hierarchy.yaml b/hyperextract/templates/presets/medicine/anatomy_hierarchy.yamlnew file mode 100644index 0000000..37725d8--- /dev/null+++ b/hyperextract/templates/presets/medicine/anatomy_hierarchy.yaml@@ -0,0 +1,80 @@+name: "AnatomyHierarchy"+autotype: graph+tag: [medicine]++language: zh++description:+ zh: "解剖层级树 - 构建解剖位置的包含和毗邻关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "解剖结构名称,如器官、组织、血管等"+ - name: category+ type: "string"+ description:+ zh: "解剖类型:器官、组织、血管、神经、骨骼等"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源解剖结构"+ - name: target+ type: "string"+ description:+ zh: "目标解剖结构"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:包含、毗邻、分支、供应等"+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的解剖学家,请从文本中提取解剖结构及其关系,构建解剖层级树。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体++ rules_for_nodes:+ zh: |+ - 解剖学术语保持原文,如解剖结构名称(心脏、肝脏、主动脉)++ rules_for_edges:+ zh: |+ - 包含:解剖结构之间的包含关系+ - 毗邻:解剖结构之间的相邻关系+ - 分支:血管或神经的分支关系+ - 供应:血管供应区域的关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/medicine/clinical_pathway.yaml b/hyperextract/templates/presets/medicine/clinical_pathway.yamlnew file mode 100644index 0000000..9e8aba4--- /dev/null+++ b/hyperextract/templates/presets/medicine/clinical_pathway.yaml@@ -0,0 +1,78 @@+name: "ClinicalPathway"+autotype: graph+tag: [medicine]++language: zh++description:+ zh: "临床路径图 - 提取 '如果症状A则检查B否则治疗C' 的决策树结构"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "节点名称,如症状、检查、治疗等"+ - name: category+ type: "string"+ description:+ zh: "节点类型:症状、检查、治疗、诊断、决策点等"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源节点"+ - name: target+ type: "string"+ description:+ zh: "目标节点"+ - name: condition+ type: "string"+ description:+ zh: "条件描述,如如果症状A则"+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的临床医生,请从文本中提取"如果症状A则检查B否则治疗C"的决策树结构,构建临床路径图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体++ rules_for_nodes:+ zh: |+ - 医学专业术语保持原文,如检查项目名称、药物名称+ - 临床术语保持原文,如心电图、血常规++ rules_for_edges:+ zh: |+ - 条件描述应清晰表达决策逻辑++identifiers:+ node_id: "name"+ edge_id: "{source}|{condition}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{condition}"diff --git a/hyperextract/templates/presets/medicine/complex_interaction_net.yaml b/hyperextract/templates/presets/medicine/complex_interaction_net.yamlnew file mode 100644index 0000000..db0c387--- /dev/null+++ b/hyperextract/templates/presets/medicine/complex_interaction_net.yaml@@ -0,0 +1,77 @@+name: "ComplexInteractionNet"+autotype: hypergraph+tag: [medicine]++language: zh++description:+ zh: "条件性相互作用网 - 建模 '药A+药B+特定体质 -> 不良反应' 的高阶依赖"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,如药物、体质、不良反应等"+ - name: category+ type: "string"+ description:+ zh: "实体类型:药物、体质、不良反应、其他等"+ - name: description+ type: "string"+ description:+ zh: "简要描述,如药物的功能、作用等"+ required: false++edge_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "超边名称,如药物相互作用"+ - name: nodes+ type: "array"+ description:+ zh: "参与超边的节点列表"+ - name: interactionType+ type: "string"+ description:+ zh: "相互作用类型:增强、减弱、不良反应等"+ - name: details+ type: "string"+ description:+ zh: "详细描述,如具体的相互作用机制"++extraction_guide:+ target:+ zh: |+ 你是一位专业的临床药师,请从文本中提取药物相互作用信息,构建条件性相互作用网。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体++ rules_for_nodes:+ zh: |+ - 药物名称保持原文,如二甲双胍、磺酰脲类+ - 不良反应名称保持原文++ rules_for_edges:+ zh: |+ - 增强:药物作用相互增强+ - 减弱:药物作用相互减弱+ - 不良反应:药物组合导致不良反应++identifiers:+ node_id: "name"+ edge_id: "name"+ edge_members: "nodes"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "name"diff --git a/hyperextract/templates/presets/medicine/contraindication_list.yaml b/hyperextract/templates/presets/medicine/contraindication_list.yamlnew file mode 100644index 0000000..5186319--- /dev/null+++ b/hyperextract/templates/presets/medicine/contraindication_list.yaml@@ -0,0 +1,44 @@+name: "ContraindicationList"+autotype: list+tag: [medicine]++language: zh++description:+ zh: "禁忌症清单 - 提取绝对禁忌(如孕妇、严重肾衰竭等)的明确列表"++item_schema:+ fields:+ - name: contraindication+ type: "string"+ description:+ zh: "禁忌症描述"+ - name: contraindicationType+ type: "string"+ description:+ zh: "禁忌症类型:绝对禁忌、相对禁忌等"+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的临床药师,请从文本中提取绝对禁忌(如孕妇、严重肾衰竭等)的明确列表,构建禁忌症清单。++ rules:+ zh: |+ 1. 提取所有禁忌症,包括绝对禁忌和相对禁忌+ 2. 为每个禁忌症指定类型:绝对禁忌、相对禁忌等+ 3. 为每个禁忌症添加详细描述(如果文本中提供)+ 4. 保持禁忌症描述与原文一致++ rules_for_nodes:+ zh: |+ - 禁忌症名称保持原文+ - 医学术语保持原文++display:+ label: "{contraindication} ({contraindicationType})"diff --git a/hyperextract/templates/presets/medicine/discharge_instruction.yaml b/hyperextract/templates/presets/medicine/discharge_instruction.yamlnew file mode 100644index 0000000..933ef74--- /dev/null+++ b/hyperextract/templates/presets/medicine/discharge_instruction.yaml@@ -0,0 +1,62 @@+name: "DischargeInstruction"+autotype: model+tag: [medicine]++language: zh++description:+ zh: "出院医嘱摘要 - 提取出院带药、复诊计划及康复建议的结构化信息"++schema:+ fields:+ - name: medications+ type: "array"+ description:+ zh: "出院带药列表,每个药物包含名称、剂量、用法、频次等信息"+ required: false+ - name: followUp+ type: "array"+ description:+ zh: "复诊计划列表,每个复诊包含时间、科室、检查项目等信息"+ required: false+ - name: rehabilitation+ type: "array"+ description:+ zh: "康复建议列表"+ required: false+ - name: diet+ type: "array"+ description:+ zh: "饮食建议列表"+ required: false+ - name: activity+ type: "array"+ description:+ zh: "活动建议列表"+ required: false+ - name: notes+ type: "array"+ description:+ zh: "其他注意事项列表"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的医生,请从文本中提取出院带药、复诊计划及康复建议的结构化信息,构建出院医嘱摘要。++ rules:+ zh: |+ 1. 提取所有出院带药信息,每个药物包含名称、剂量、用法、频次等信息+ 2. 提取所有复诊计划信息,每个复诊包含时间、科室、检查项目等信息+ 3. 提取所有康复建议、饮食建议、活动建议和其他注意事项+ 4. 保持信息与原文一致++ rules_for_nodes:+ zh: |+ - 药物名称保持原文,如阿司匹林、二甲双胍+ - 剂量单位保持原文,如 mg、ml+ - 医学缩写保持原文,如 qd(每日一次)、bid(每日两次)++display:+ label: "出院医嘱摘要"diff --git a/hyperextract/templates/presets/medicine/hospital_course_timeline.yaml b/hyperextract/templates/presets/medicine/hospital_course_timeline.yamlnew file mode 100644index 0000000..9b331c0--- /dev/null+++ b/hyperextract/templates/presets/medicine/hospital_course_timeline.yaml@@ -0,0 +1,97 @@+name: "HospitalCourseTimeline"+autotype: temporal_graph+tag: [medicine]++language: zh++description:+ zh: "住院病程时间轴 - 严格按时间顺序提取入院、检查、治疗、转归等节点"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "节点名称,如入院、检查、治疗、转归等"+ - name: category+ type: "string"+ description:+ zh: "节点类型:入院、检查、治疗、手术、转归、其他等"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源节点"+ - name: target+ type: "string"+ description:+ zh: "目标节点"+ - name: eventType+ type: "string"+ description:+ zh: "事件类型:入院、检查、治疗、手术、转归等"+ - name: eventDate+ type: "string"+ description:+ zh: "事件日期,格式为年-月-日"+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的医院管理人员,请从文本中严格按时间顺序提取入院、检查、治疗、转归等节点,构建住院病程时间轴。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体++ rules_for_nodes:+ zh: |+ - 医学术语保持原文++ rules_for_edges:+ zh: |+ - 记录事件之间的时间顺序关系++ rules_for_time:+ zh: |+ 当前观察日期:{observation_time}++ 1. 相对时间解析(基于观察日期):+ - "去年" → {observation_time} 的前一年+ - "上月" → {observation_time} 的前一个月+ - "本季度" → {observation_time} 所在季度+ - "近期" → {observation_time} 最近 3 个月+ - "入院当天" → 使用入院日期+ - "术后第一天" → 手术日期的后一天++ 2. 精确时间 → 保持原样+ 3. 时间缺失 → 留空,不要猜测++identifiers:+ node_id: "name"+ edge_id: "{source}|{eventType}|{target}"+ edge_members:+ source: "source"+ target: "target"+ time_field: "eventDate"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{eventType} ({eventDate})"diff --git a/hyperextract/templates/presets/medicine/level_of_evidence.yaml b/hyperextract/templates/presets/medicine/level_of_evidence.yamlnew file mode 100644index 0000000..e41b060--- /dev/null+++ b/hyperextract/templates/presets/medicine/level_of_evidence.yaml@@ -0,0 +1,58 @@+name: "LevelOfEvidence"+autotype: list+tag: [medicine]++language: zh++description:+ zh: "证据评级表 - 提取指南中的具体推荐意见及其对应的证据等级"++item_schema:+ fields:+ - name: topic+ type: "string"+ description:+ zh: "推荐主题,如血糖控制、血脂管理、阿司匹林使用等"+ - name: summary+ type: "string"+ description:+ zh: "推荐意见摘要,简短概括该推荐的核心内容,不超过10字"+ - name: recommendation+ type: "string"+ description:+ zh: "推荐意见"+ - name: evidenceLevel+ type: "string"+ description:+ zh: "证据等级,如A、B、C、1a、1b等"+ - name: recommendationLevel+ type: "string"+ description:+ zh: "推荐级别,如强推荐、弱推荐等"+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的循证医学专家,请从文本中提取指南中的具体推荐意见及其对应的证据等级,构建证据评级表。++ rules:+ zh: |+ 1. 提取所有推荐意见及其对应的证据等级+ 2. 为每个推荐意见指定推荐主题(topic)+ 3. 为每个推荐意见提取摘要(summary),不超过10字+ 4. 为每个推荐意见指定推荐级别+ 5. 为每个推荐意见添加详细描述(如果文本中提供)+ 6. 保持推荐意见与原文一致++ rules_for_nodes:+ zh: |+ - 证据等级保持原文,如 A、B、C、1a、1b+ - 医学术语保持原文++display:+ label: "{topic} [{evidenceLevel}]"diff --git a/hyperextract/templates/presets/medicine/medical_concept_net.yaml b/hyperextract/templates/presets/medicine/medical_concept_net.yamlnew file mode 100644index 0000000..dadb649--- /dev/null+++ b/hyperextract/templates/presets/medicine/medical_concept_net.yaml@@ -0,0 +1,84 @@+name: "MedicalConceptNet"+autotype: graph+tag: [medicine]++language: zh++description:+ zh: "医学概念网络 - 提取医学术语及其关联属性(如:属于、定义为)"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "概念名称,如医学术语、疾病名称、解剖部位等"+ - name: category+ type: "string"+ description:+ zh: "概念类型:疾病、解剖部位、生理过程、药物、症状、体征等"+ - name: definition+ type: "string"+ description:+ zh: "概念定义"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源概念"+ - name: target+ type: "string"+ description:+ zh: "目标概念"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:属于、定义为、包含、组成、位于、导致、治疗等"+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的医学术语专家,请从文本中提取医学术语及其关联属性,构建医学概念网络。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体++ rules_for_nodes:+ zh: |+ - 医学术语保持原文,如疾病名称、解剖部位名称+ - 专业缩写保持原文,如 ECG、CT、MRI++ rules_for_edges:+ zh: |+ - 属于:概念归属关系+ - 定义为:概念定义关系+ - 包含:包含关系+ - 组成:组成关系+ - 位于:位置关系+ - 导致:因果关系+ - 治疗:治疗关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/medicine/microscopic_feature_set.yaml b/hyperextract/templates/presets/medicine/microscopic_feature_set.yamlnew file mode 100644index 0000000..e160e77--- /dev/null+++ b/hyperextract/templates/presets/medicine/microscopic_feature_set.yaml@@ -0,0 +1,52 @@+name: "MicroscopicFeatureSet"+autotype: set+tag: [medicine]++language: zh++description:+ zh: "微观特征集 - 提取免疫组化指标(如 HER2+, Ki67)及基因突变状态"++item_schema:+ fields:+ - name: featureName+ type: "string"+ description:+ zh: "特征名称,如免疫组化指标、基因突变等"+ - name: featureType+ type: "string"+ description:+ zh: "特征类型:免疫组化、基因突变、其他等"+ - name: value+ type: "string"+ description:+ zh: "特征值,如阳性、阴性、百分比等"+ - name: description+ type: "string"+ description:+ zh: "特征描述"+ required: false++extraction_guide:+ target:+ zh: |+ 你是一位专业的病理学家,请从文本中提取免疫组化指标(如 HER2+, Ki67)及基因突变状态,构建微观特征集。++ rules:+ zh: |+ 1. 提取所有免疫组化指标和基因突变状态+ 2. 为每个特征指定类型:免疫组化、基因突变、其他等+ 3. 为每个特征添加特征值,如阳性、阴性、百分比等+ 4. 为每个特征添加简要描述(如果文本中提供)+ 5. 保持特征名称与原文一致++ rules_for_nodes:+ zh: |+ - 免疫组化指标保持原文,如 HER2、Ki67、ER、PR+ - 基因突变名称保持原文,如 BRCA1、KRAS、TP53++identifiers:+item_id: "featureName"++display:+ label: "{featureName} ({featureType})"diff --git a/hyperextract/templates/presets/medicine/pathology_hypergraph.yaml b/hyperextract/templates/presets/medicine/pathology_hypergraph.yamlnew file mode 100644index 0000000..154d101--- /dev/null+++ b/hyperextract/templates/presets/medicine/pathology_hypergraph.yaml@@ -0,0 +1,82 @@+name: "PathologyHypergraph"+autotype: hypergraph+tag: [medicine]++language: zh++description:+ zh: "多因素病理机制图 - 建模 '基因+环境+诱因 -> 疾病' 的复杂致病逻辑"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,如基因、环境因素、诱因、疾病等"+ - name: category+ type: "string"+ description:+ zh: "实体类型:基因、环境因素、诱因、疾病、病理过程、症状等"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: mechanism_name+ type: "string"+ description:+ zh: "机制名称,简短描述性名称"+ - name: participating_entities+ type: "array"+ description:+ zh: "参与此病理机制的所有实体名称列表"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:致病、诱发、促进、抑制等"+ - name: details+ type: "string"+ description:+ zh: "详细描述,如具体的致病机制"+ - name: outcome+ type: "string"+ description:+ zh: "该机制导致的结果或效应"++extraction_guide:+ target:+ zh: |+ 你是一位专业的病理学家,请从文本中提取与疾病病理机制相关的实体和它们之间的复杂关联关系,构建多因素病理机制图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体++ rules_for_nodes:+ zh: |+ - 医学专业术语保持原文,如基因名称(BRCA1、KRAS、TP53)、蛋白名称+ - 疾病名称保持原文,如慢性阻塞性肺疾病、肺癌++ rules_for_edges:+ zh: |+ - 致病:导致疾病发生+ - 诱发:诱发疾病发作+ - 促进:促进疾病进展+ - 抑制:抑制疾病发展++identifiers:+ node_id: "name"+ edge_id: "mechanism_name"+ edge_members: "participating_entities"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "[{relationType}] {mechanism_name}"diff --git a/hyperextract/templates/presets/medicine/pharmacology_graph.yaml b/hyperextract/templates/presets/medicine/pharmacology_graph.yamlnew file mode 100644index 0000000..0d3f50f--- /dev/null+++ b/hyperextract/templates/presets/medicine/pharmacology_graph.yaml@@ -0,0 +1,83 @@+name: "PharmacologyGraph"+autotype: graph+tag: [medicine]++language: zh++description:+ zh: "药理机制图 - 提取药物、受体、靶点及生理反应之间的相互作用路径"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,如药物、受体、靶点、生理反应等"+ - name: category+ type: "string"+ description:+ zh: "实体类型:药物、受体、靶点、生理反应、信号通路等"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体"+ - name: target+ type: "string"+ description:+ zh: "目标实体"+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:结合、激活、抑制、调节、诱导、拮抗等"+ - name: details+ type: "string"+ description:+ zh: "详细描述,如具体的作用机制"++extraction_guide:+ target:+ zh: |+ 你是一位专业的药理学家,请从文本中提取药物、受体、靶点及生理反应之间的相互作用路径,构建药理机制图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体++ rules_for_nodes:+ zh: |+ - 药物名称保持原文,如二甲双胍、阿司匹林+ - 受体名称保持原文,如胰岛素受体、肾上腺素受体+ - 信号通路名称保持原文,如AMPK通路、PI3K/Akt通路++ rules_for_edges:+ zh: |+ - 结合:药物与受体结合+ - 激活:激活受体或通路+ - 抑制:抑制受体或通路+ - 调节:调节生理反应+ - 诱导:诱导特定反应+ - 拮抗:拮抗作用++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/medicine/surgical_event_graph.yaml b/hyperextract/templates/presets/medicine/surgical_event_graph.yamlnew file mode 100644index 0000000..2c56f68--- /dev/null+++ b/hyperextract/templates/presets/medicine/surgical_event_graph.yaml@@ -0,0 +1,83 @@+name: "SurgicalEventGraph"+autotype: hypergraph+tag: [medicine]++language: zh++description:+ zh: "手术事件超图 - 将手术建模为连接 {医生, 部位, 术式, 器械} 共同参与的复杂事件"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,如医生、部位、术式、器械等"+ - name: category+ type: "string"+ description:+ zh: "实体类型:医生、部位、术式、器械、麻醉方式等"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "超边名称,如手术名称"+ - name: nodes+ type: "array"+ description:+ zh: "参与超边的节点列表"+ - name: date+ type: "string"+ description:+ zh: "手术日期"+ - name: duration+ type: "string"+ description:+ zh: "手术时长"+ required: false+ - name: details+ type: "string"+ description:+ zh: "详细描述,如手术过程"++extraction_guide:+ target:+ zh: |+ 你是一位专业的外科医生,请从文本中提取手术事件及其相关实体,构建手术事件超图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边连接2个或多个实体++ rules_for_nodes:+ zh: |+ - 医生:手术主刀医生及参与人员+ - 部位:手术部位+ - 术式:具体手术方式+ - 器械:使用的医疗器械++ rules_for_edges:+ zh: |+ - 一个超边代表一个完整的手术事件+ - 需要包含手术的时间、地点、参与人员等信息++identifiers:+ node_id: "name"+ edge_id: "name"+ edge_members: "nodes"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{name} ({date})"diff --git a/hyperextract/templates/presets/medicine/treatment_regimen_map.yaml b/hyperextract/templates/presets/medicine/treatment_regimen_map.yamlnew file mode 100644index 0000000..46d1226--- /dev/null+++ b/hyperextract/templates/presets/medicine/treatment_regimen_map.yaml@@ -0,0 +1,76 @@+name: "TreatmentRegimenMap"+autotype: hypergraph+tag: [medicine]++language: zh++description:+ zh: "综合治疗方案图 - 提取由 药物组合+理疗+生活干预 构成的多因素治疗方案"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,如药物、理疗方法、生活干预等"+ - name: category+ type: "string"+ description:+ zh: "实体类型:药物、理疗、生活干预、检查、手术等"+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false++edge_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "超边名称,如治疗方案、康复计划等"+ - name: nodes+ type: "array"+ description:+ zh: "参与超边的节点列表"+ - name: disease+ type: "string"+ description:+ zh: "针对的疾病"+ - name: details+ type: "string"+ description:+ zh: "详细描述,如具体的治疗方案内容"++extraction_guide:+ target:+ zh: |+ 你是一位专业的临床医生,请从文本中提取由"药物组合+理疗+生活干预"构成的多因素治疗方案,构建综合治疗方案图。++ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边必须包含多个节点++ rules_for_nodes:+ zh: |+ - 药物名称保持原文,如二甲双胍、阿司匹林+ - 治疗方式保持原文,如放疗、化疗、手术++ rules_for_edges:+ zh: |+ - 一个超边代表一个完整的治疗方案+ - 需要包含针对的疾病信息++identifiers:+ node_id: "name"+ edge_id: "name"+ edge_members: "nodes"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{name} - {disease}"diff --git a/hyperextract/templates/presets/medicine/tumor_staging_item.yaml b/hyperextract/templates/presets/medicine/tumor_staging_item.yamlnew file mode 100644index 0000000..2a87c2b--- /dev/null+++ b/hyperextract/templates/presets/medicine/tumor_staging_item.yaml@@ -0,0 +1,61 @@+name: "TumorStagingItem"+autotype: model+tag: [medicine]++language: zh++description:+ zh: "TNM分期表 - 提取肿瘤大小(T)、淋巴结(N)、转移(M)及分期结果"++schema:+ fields:+ - name: tStage+ type: "string"+ description:+ zh: "T分期,如T1、T2、T3、T4等"+ - name: nStage+ type: "string"+ description:+ zh: "N分期,如N0、N1、N2、N3等"+ - name: mStage+ type: "string"+ description:+ zh: "M分期,如M0、M1等"+ - name: pathologicalStage+ type: "string"+ description:+ zh: "病理分期,如I期、II期、III期、IV期等"+ - name: tDetails+ type: "string"+ description:+ zh: "T分期详细描述,如肿瘤大小"+ - name: nDetails+ type: "string"+ description:+ zh: "N分期详细描述,如淋巴结转移数量"+ - name: mDetails+ type: "string"+ description:+ zh: "M分期详细描述,如远处转移部位"++extraction_guide:+ target:+ zh: |+ 你是一位专业的病理学家,请从文本中提取肿瘤大小(T)、淋巴结(N)、转移(M)及分期结果,构建TNM分期表。++ rules:+ zh: |+ 1. 提取T分期、N分期、M分期和病理分期+ 2. 为每个分期添加详细描述:+ - T分期详细描述:肿瘤大小、浸润深度等+ - N分期详细描述:淋巴结转移数量、部位等+ - M分期详细描述:远处转移部位等+ 3. 保持信息与原文一致++ rules_for_nodes:+ zh: |+ - TNM分期表示法保持原文,如 T1、T2、N0、M0+ - 分期表示法保持原文,如 I期、II期、III期、IV期++display:+ label: "TNM分期: {tStage}{nStage}{mStage} ({pathologicalStage})"diff --git a/hyperextract/templates/presets/news/complex_relation_net.yaml b/hyperextract/templates/presets/news/complex_relation_net.yamlnew file mode 100644index 0000000..44be3c8--- /dev/null+++ b/hyperextract/templates/presets/news/complex_relation_net.yaml@@ -0,0 +1,89 @@+name: "ComplexRelationNet"+autotype: hypergraph+tag: [news]++language: zh++description:+ zh: "复杂关系网络 - 建模涉及多方(三人及以上)的社会关联"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "参与者名称"+ required: true+ default: ""+ - name: role+ type: "string"+ description:+ zh: "角色:企业、个人、机构"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "参与者描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:商业伙伴、政治盟友、家族成员、投资关系、担保关系"+ required: true+ default: ""+ - name: participants+ type: "array"+ description:+ zh: "参与者列表(3个及以上)"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "关系描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的新闻调查记者,请从调查报道文本中提取参与者以及它们之间的复杂关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 超边必须包含至少3个参与者+ 4. 仅从已知参与者列表中提取边,不要创建未列出的参与者+ 5. 描述应与原文保持一致+ 6. 参与者类型:企业、个人、机构+ 7. 关系类型:商业伙伴、政治盟友、家族成员、投资关系、担保关系+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 参与者类型:企业、个人、机构+ 4. 参与者描述要包含基本背景信息+ rules_for_edges:+ zh: |+ 1. 超边必须包含至少3个参与者+ 2. 仅从已知参与者列表中提取边,不要创建未列出的参与者+ 3. 描述应与原文保持一致+ 4. 关系类型:商业伙伴、政治盟友、家族成员、投资关系、担保关系+ 5. 描述多方之间的具体关联++identifiers:+ node_id: "name"+ edge_id: "{relationType}|{participants}"+ edge_members: "participants"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{role}]"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/news/impact_chain.yaml b/hyperextract/templates/presets/news/impact_chain.yamlnew file mode 100644index 0000000..0f840f6--- /dev/null+++ b/hyperextract/templates/presets/news/impact_chain.yaml@@ -0,0 +1,95 @@+name: "ImpactChain"+autotype: graph+tag: [news]++language: zh++description:+ zh: "影响推演链 - 提取 '政策/事件 -> 影响群体 -> 预期后果' 的因果预测链条"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "节点名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "节点类型:政策/事件、影响群体、预期后果"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "原因"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "结果"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:影响、导致、预期"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "影响描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的政策分析师,请从政策分析文本中提取影响链实体和它们之间的因果关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 节点类型:政策/事件(政策文件、重大事件)、影响群体(企业、消费者、经销商等)、预期后果(销量变化、价格调整、市场调整等)+ 6. 关系类型:影响、导致、预期+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 节点类型:政策/事件(政策文件、重大事件)、影响群体(企业、消费者、经销商等)、预期后果(销量变化、价格调整、市场调整等)+ 4. 描述要包含简要信息+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 关系类型:影响(政策对群体的影响)、导致(原因导致结果)、预期(对未来趋势的预测)+ 4. 描述原因到结果的逻辑链条++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/news/investigative_context_graph.yaml b/hyperextract/templates/presets/news/investigative_context_graph.yamlnew file mode 100644index 0000000..4c06288--- /dev/null+++ b/hyperextract/templates/presets/news/investigative_context_graph.yaml@@ -0,0 +1,93 @@+name: "InvestigativeContextGraph"+autotype: graph+tag: [news]++language: zh++description:+ zh: "调查背景图谱 - 从调查报道中提取人物、机构、资金、项目之间的关联"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "实体类型:人物、机构、资金、项目、地点"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:任职、持股、交易、关联、合作、担保、亲属"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "关系描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的新闻调查记者,请从调查报道文本中提取实体和它们之间的关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 实体类型:人物、机构、资金、项目、地点+ 6. 关系类型:任职、持股、交易、关联、合作、担保、亲属+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 实体类型:人物、机构、资金、项目、地点+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 关系类型:任职(担任职位)、持股(持有股份)、交易(商业交易)、关联(关联关系)、合作(合作关系)、担保(担保关系)、亲属(亲属关系)++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/news/key_event_sequence.yaml b/hyperextract/templates/presets/news/key_event_sequence.yamlnew file mode 100644index 0000000..0f09b3a--- /dev/null+++ b/hyperextract/templates/presets/news/key_event_sequence.yaml@@ -0,0 +1,103 @@+name: "KeyEventSequence"+autotype: graph+tag: [news]++language: zh++description:+ zh: "调查事件脉络 - 按时间顺序还原调查中揭露的关键事件节点,梳理前因后果"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "事件名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "事件类型:开工、销售、停工、诉讼、侦查、处罚、协调、公示"+ required: true+ default: ""+ - name: time+ type: "string"+ description:+ zh: "时间,格式为年-月-日(如 2023-09-15)"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "事件描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "前置事件名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "后续事件名称"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:紧接、导致、触发、升级、回应、协调、裁决、调查"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "因果描述,说明两事件之间的逻辑关系"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的新闻调查记者,请从调查报道文本中提取关键事件以及它们之间的关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的事件,禁止将多个事件合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知事件列表中提取边,不要创建未列出的事件+ 4. 关系描述应与原文保持一致+ 5. 事件类型:开工、销售、停工、诉讼、侦查、处罚、协调、公示+ 6. 时间格式:年-月-日(如 2023-09-15),精确到日+ 7. 关系类型:紧接、导致、触发、升级、回应、协调、裁决、调查+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的事件,禁止将多个事件合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 事件类型:开工、销售、停工、诉讼、侦查、处罚、协调、公示+ 4. 时间格式:年-月-日(如 2023-09-15),精确到日+ 5. 事件描述要包含简要信息+ rules_for_edges:+ zh: |+ 1. 仅从已知事件列表中提取边,不要创建未列出的事件+ 2. 关系描述应与原文保持一致+ 3. 关系类型:紧接(紧接着发生)、导致(直接原因)、触发(导火索/间接原因)、升级(事态扩大)、回应(对某事件的回应)、协调(多方协商处理)、裁决(法律/官方判定)、调查(正在调查阶段)+ 4. 描述两事件之间的具体逻辑关系++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({time})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/news/live_update_timeline.yaml b/hyperextract/templates/presets/news/live_update_timeline.yamlnew file mode 100644index 0000000..611ea64--- /dev/null+++ b/hyperextract/templates/presets/news/live_update_timeline.yaml@@ -0,0 +1,106 @@+name: "LiveUpdateTimeline"+autotype: graph+tag: [news]++language: zh++description:+ zh: "实时动态时间轴 - 针对正在发生的事件,提取分钟级更新"++node_schema:+ fields:+ - name: time+ type: "string"+ description:+ zh: "时间点,格式为HH:MM"+ required: true+ default: ""+ - name: event+ type: "string"+ description:+ zh: "事件内容"+ required: true+ default: ""+ - name: name+ type: "string"+ description:+ zh: "简短名称/摘要"+ required: true+ default: ""+ - name: speaker+ type: "string"+ description:+ zh: "发言人"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源时间点(格式为HH:MM)"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标时间点(格式为HH:MM)"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:开场、介绍、发布、发言、提问、回答、总结、结束"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "详细描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的新闻直播编辑,请从实时直播文本中提取时间更新点以及它们之间的关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的时间点,禁止将多个时间点合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知时间点列表中提取边,不要创建未列出的时间点+ 4. 关系描述应与原文保持一致+ 5. 时间格式:HH: "MM(24小时制)"+ 6. 事件内容要包含详细信息+ 7. 简短名称要简洁明了+ 8. 关系类型:开场、介绍、发布、发言、提问、回答、总结、结束+ 9. 发言人如无则为空白+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的时间点,禁止将多个时间点合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 时间格式:HH: "MM(24小时制)"+ 4. 事件内容要包含详细信息+ 5. 简短名称要简洁明了+ 6. 发言人如无则为空白+ rules_for_edges:+ zh: |+ 1. 仅从已知时间点列表中提取边,不要创建未列出的时间点+ 2. 关系描述应与原文保持一致+ 3. 关系类型:开场(会议开始)、介绍(介绍环节)、发布(正式发布)、发言(领导/发言人讲话)、提问(记者提问)、回答(回应问题)、总结(总结陈词)、结束(会议结束)+ 4. 描述两时间点之间的具体关系++identifiers:+ node_id: "time"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{time} {name}"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/news/news_entity_graph.yaml b/hyperextract/templates/presets/news/news_entity_graph.yamlnew file mode 100644index 0000000..54f4936--- /dev/null+++ b/hyperextract/templates/presets/news/news_entity_graph.yaml@@ -0,0 +1,93 @@+name: "NewsEntityGraph"+autotype: graph+tag: [news]++language: zh++description:+ zh: "新闻实体图谱 - 快速提取新闻中的核心主体及其动作或状态"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "实体类型:人物、机构、地点、产品、事件"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型,例如:发布、任命、收购等"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "动作详细描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的新闻编辑,请从新闻文本中提取实体和它们之间的动作或关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 实体类型:人物、机构、地点、产品、事件+ 6. 关系类型:例如:发布、任命、收购等+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 实体类型:人物、机构、地点、产品、事件+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 关系类型:例如:发布、任命、收购等++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/news/news_summary_model.yaml b/hyperextract/templates/presets/news/news_summary_model.yamlnew file mode 100644index 0000000..bc3ca55--- /dev/null+++ b/hyperextract/templates/presets/news/news_summary_model.yaml@@ -0,0 +1,82 @@+name: "NewsSummaryModel"+autotype: model+tag: [news]++language: zh++description:+ zh: "结构化摘要 - 标准化提取 5W1H 要素"++schema:+ fields:+ - name: who+ type: "string"+ description:+ zh: "核心人物/主体"+ required: true+ default: ""+ - name: what+ type: "string"+ description:+ zh: "发生了什么"+ required: true+ default: ""+ - name: when+ type: "string"+ description:+ zh: "时间"+ required: true+ default: ""+ - name: where+ type: "string"+ description:+ zh: "地点"+ required: true+ default: ""+ - name: why+ type: "string"+ description:+ zh: "原因"+ required: true+ default: ""+ - name: how+ type: "string"+ description:+ zh: "如何发生"+ required: true+ default: ""+ - name: casualties+ type: "string"+ description:+ zh: "伤亡情况"+ required: false+ default: ""+ - name: response+ type: "string"+ description:+ zh: "官方回应"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的新闻编辑,请从新闻文本中提取结构化的5W1H要素,构建新闻摘要。+ rules:+ zh: |+ 1. 识别核心人物/主体+ 2. 识别发生了什么+ 3. 识别时间+ 4. 识别地点+ 5. 识别原因+ 6. 识别如何发生+ 7. 识别伤亡情况,如无则为空白+ 8. 识别官方回应,如无则为空白+ 9. 只提取文本中明确提及的信息,不添加额外内容+ 10. 保持客观准确,符合新闻写作风格+ 11. 时间格式统一为年-月-日或具体时间点+ 12. 地点要具体到城市或区域+++display:+ label: "{when} {where}: {what}"diff --git a/hyperextract/templates/presets/news/viewpoint_structure.yaml b/hyperextract/templates/presets/news/viewpoint_structure.yamlnew file mode 100644index 0000000..4c3b1b2--- /dev/null+++ b/hyperextract/templates/presets/news/viewpoint_structure.yaml@@ -0,0 +1,101 @@+name: "ViewpointStructure"+autotype: hypergraph+tag: [news]++language: zh++description:+ zh: "观点逻辑结构 - 建模文章的论证逻辑,将观点、论据、背景引用聚合为观点结构"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "元素名称,简短唯一标识符,如'政策建议'、'数据支撑'、'专家观点'"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "元素类型:观点、论据、背景引用"+ required: true+ default: ""+ - name: content+ type: "string"+ description:+ zh: "完整内容,概括原文意思"+ required: true+ default: ""+ - name: source+ type: "string"+ description:+ zh: "来源,如无则为空白"+ required: false+ default: ""++edge_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "聚合名称,简短唯一标识,如'核心论点'、'论证结构'、'分析框架'"+ required: true+ default: ""+ - name: participantNames+ type: "array"+ description:+ zh: "参与此观点论证的所有元素名称列表,必须从已提取的节点中选择"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "论证描述,说明这些元素如何构成观点"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的政策分析师,请从文本中提取论证元素以及它们组成的观点聚合超边。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的元素,禁止将多个元素合并+ 2. 元素名称 (name) 必须是简短、唯一的标识符(不超过10个字)+ 3. 每个超边必须包含至少2个节点(观点 + 论据/背景引用)+ 4. 超边中的participantNames必须填写节点的元素名称+ 5. 观点:作者的核心论点+ 6. 论据:支撑观点的证据或分析+ 7. 背景引用:政策文件、统计数据、专家说法+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的元素,禁止将多个元素合并为一个节点+ 2. 元素名称 (name) 必须是简短、唯一的标识符,用于后续引用+ 3. 元素名称与原文保持一致,但要简洁(不超过10个字)+ 4. 内容 (content) 字段要完整概括原文意思+ 5. 观点:作者的核心论点、主张或结论+ 6. 论据:支撑观点的证据、数据或分析+ 7. 背景引用:政策文件、统计数据、专家说法等外部引用+ 8. 来源如无则为空白+ rules_for_edges:+ zh: |+ 1. 每个超边代表一个完整的观点论证结构+ 2. 超边必须包含至少2个节点(一个观点 + 至少一个论据或背景引用)+ 3. 只能从已知节点列表中选择,禁止创建未列出的节点+ 4. participantNames字段必须填写节点的名字+ 5. 将围绕同一核心观点的所有相关元素聚合到一个超边中+ 6. 一个观点可以参与多个超边(从不同角度论证)+ 7. 描述应说明这些元素如何共同支撑观点++identifiers:+ node_id: "name"+ edge_id: "name"+ edge_members: "participantNames"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}[{category}]"+ edge_label: "{name}"diff --git a/hyperextract/templates/presets/tcm/acupoint_location_map.yaml b/hyperextract/templates/presets/tcm/acupoint_location_map.yamlnew file mode 100644index 0000000..acbea2f--- /dev/null+++ b/hyperextract/templates/presets/tcm/acupoint_location_map.yaml@@ -0,0 +1,99 @@+name: "AcupointLocationMap"+autotype: graph+tag: [tcm]++language: zh++description:+ zh: "腧穴空间定位 - 基于人体解剖标志提取穴位的相对位置关系(如 '脐旁2寸')"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "穴位名称:如合谷、足三里、三阴交等"+ required: true+ default: ""+ - name: meridian+ type: "string"+ description:+ zh: "所属经脉"+ required: false+ default: ""+ - name: location+ type: "string"+ description:+ zh: "位置描述:如脐旁2寸、腕横纹上3寸等"+ required: false+ default: ""+ - name: indications+ type: "string"+ description:+ zh: "主治功能"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源穴位或解剖标志名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标穴位名称"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:位于"+ required: true+ default: ""+ - name: relativePosition+ type: "string"+ description:+ zh: "相对位置描述:如脐旁2寸、腕横纹上3寸等"+ required: true+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的针灸学专家,请从文本中提取穴位的相对位置关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 穴位:针灸特定位置,如合谷、足三里、三阴交+ 6. 解剖标志:人体解剖部位,如腕横纹、第2掌骨+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 穴位:针灸特定位置+ 4. 解剖标志:人体解剖部位+ rules_for_edges:+ zh: |+ 1. 仅从已知穴位列表中提取边,不要创建未列出的穴位+ 2. 关系描述应与原文保持一致++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}"+ edge_label: "{relationType}: {relativePosition}"diff --git a/hyperextract/templates/presets/tcm/compatibility_net.yaml b/hyperextract/templates/presets/tcm/compatibility_net.yamlnew file mode 100644index 0000000..326578a--- /dev/null+++ b/hyperextract/templates/presets/tcm/compatibility_net.yaml@@ -0,0 +1,85 @@+name: "CompatibilityNet"+autotype: graph+tag: [tcm]++language: zh++description:+ zh: "七情配伍网络 - 提取药物间的相须、相使、相畏、相杀、十八反十九畏关系"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "药物名称"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源药物"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标药物"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "配伍关系类型:相须、相使、相畏、相杀、相恶、相反、十八反、十九畏"+ required: true+ default: ""+ - name: effect+ type: "string"+ description:+ zh: "配伍效果描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的中药配伍专家,请从文本中提取药物间的配伍关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 配伍关系类型:相须、相使、相畏、相杀、相恶、相反、十八反、十九畏+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ rules_for_edges:+ zh: |+ 1. 仅从已知药物列表中提取边,不要创建未列出的药物+ 2. 关系描述应与原文保持一致+ 3. 配伍关系类型:相须、相使、相畏、相杀、相恶、相反、十八反、十九畏++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/tcm/formula_composition.yaml b/hyperextract/templates/presets/tcm/formula_composition.yamlnew file mode 100644index 0000000..5835cd6--- /dev/null+++ b/hyperextract/templates/presets/tcm/formula_composition.yaml@@ -0,0 +1,129 @@+name: "FormulaComposition"+autotype: hypergraph+tag: [tcm]++language: zh++description:+ zh: "君臣佐使结构图 - 将方剂建模为 {君药, 臣药, 佐药, 使药} 的层级化超边结构"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "药物名称"+ required: true+ default: ""+ - name: nature+ type: "string"+ description:+ zh: "性味,如:辛温、苦寒、甘平"+ required: false+ default: ""+ - name: meridian+ type: "string"+ description:+ zh: "归经,如:归肺经、归脾经、归心经"+ required: false+ default: ""+ - name: effect+ type: "string"+ description:+ zh: "功效,如:发汗解表、温通经脉、补气健脾"+ required: false+ default: ""++edge_schema:+ fields:+ - name: formulaName+ type: "string"+ description:+ zh: "方剂名称"+ required: true+ default: ""+ - name: source+ type: "string"+ description:+ zh: "方剂来源,如:伤寒论、金匮要略、方剂学教材"+ required: false+ default: ""+ - name: junHerbs+ type: "array"+ description:+ zh: "君药列表(包含药物名称、剂量、炮制方法)"+ required: false+ default: ""+ - name: chenHerbs+ type: "array"+ description:+ zh: "臣药列表(包含药物名称、剂量、炮制方法)"+ required: false+ default: ""+ - name: zuoHerbs+ type: "array"+ description:+ zh: "佐药列表(包含药物名称、剂量、炮制方法)"+ required: false+ default: ""+ - name: shiHerbs+ type: "array"+ description:+ zh: "使药列表(包含药物名称、剂量、炮制方法)"+ required: false+ default: ""+ - name: functions+ type: "array"+ description:+ zh: "方剂功能,如:解肌发表、调和营卫"+ required: false+ default: ""+ - name: indications+ type: "array"+ description:+ zh: "主治证候,如:外感风寒表虚证"+ required: false+ default: ""+ - name: decoctionMethod+ type: "string"+ description:+ zh: "煎服法,如:水煎服,日三服"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的方剂学专家,请从文本中提取方剂的君臣佐使结构。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 药物固有属性:性味、归经、功效(不随方剂变化)+ 4. 药物在方剂中的属性:剂量、炮制方法、角色(君/臣/佐/使)+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 药物固有属性:性味、归经、功效+ rules_for_edges:+ zh: |+ 1. 仅从已知药物列表中提取边,不要创建未列出的药物+ 2. 关系描述应与原文保持一致+ 3. 药物角色:君药、臣药、佐药、使药++identifiers:+ node_id: "name"+ edge_id: "formulaName"+ edge_members:+ - "junHerbs"+ - "chenHerbs"+ - "zuoHerbs"+ - "shiHerbs"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name}"+ edge_label: "{formulaName}"diff --git a/hyperextract/templates/presets/tcm/function_indication_map.yaml b/hyperextract/templates/presets/tcm/function_indication_map.yamlnew file mode 100644index 0000000..0ae54ec--- /dev/null+++ b/hyperextract/templates/presets/tcm/function_indication_map.yaml@@ -0,0 +1,96 @@+name: "FunctionIndicationMap"+autotype: graph+tag: [tcm]++language: zh++description:+ zh: "主治功效映射 - 关联 方剂 -> 功能(如清热解毒) -> 主治证候"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "实体类型:方剂、功能、主治证候"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源实体"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标实体"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:具有功能、主治"+ required: true+ default: ""+ - name: details+ type: "string"+ description:+ zh: "详细描述"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的方剂学专家,请从文本中提取方剂、功能和主治证候之间的关联关系。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 方剂:如桂枝汤、麻黄汤+ 6. 功能:如解肌发表、清热解毒+ 7. 主治证候:如太阳中风、外感风寒+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 方剂:如桂枝汤、麻黄汤+ 4. 功能:如解肌发表、清热解毒+ 5. 主治证候:如太阳中风、外感风寒+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 关系类型:具有功能、主治++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"diff --git a/hyperextract/templates/presets/tcm/herb_property_model.yaml b/hyperextract/templates/presets/tcm/herb_property_model.yamlnew file mode 100644index 0000000..4b0b902--- /dev/null+++ b/hyperextract/templates/presets/tcm/herb_property_model.yaml@@ -0,0 +1,98 @@+name: "HerbPropertyModel"+autotype: model+tag: [tcm]++language: zh++description:+ zh: "药物性味归经 - 提取单味药的四气五味、归经、毒性及推荐剂量"++schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "药物正名"+ required: true+ default: ""+ - name: alternativeNames+ type: "array"+ description:+ zh: "别名、俗称"+ required: false+ default: ""+ - name: properties+ type: "array"+ description:+ zh: "四气:寒、热、温、凉、平"+ required: false+ default: ""+ - name: flavors+ type: "array"+ description:+ zh: "五味:酸、苦、甘、辛、咸"+ required: false+ default: ""+ - name: meridians+ type: "array"+ description:+ zh: "归经:如肺经、肝经、脾经等"+ required: false+ default: ""+ - name: toxicity+ type: "string"+ description:+ zh: "毒性:无毒、小毒、有毒、大毒"+ required: false+ default: "无毒"+ - name: dosage+ type: "string"+ description:+ zh: "推荐剂量"+ required: false+ default: ""+ - name: collection+ type: "string"+ description:+ zh: "采集时间和方法"+ required: false+ default: ""+ - name: processing+ type: "string"+ description:+ zh: "炮制方法"+ required: false+ default: ""+ - name: indications+ type: "array"+ description:+ zh: "功效主治"+ required: false+ default: ""+ - name: contraindications+ type: "array"+ description:+ zh: "配伍禁忌"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的中药学家,请从文本中提取单味药的性味归经、毒性及推荐剂量等信息。+ rules:+ zh: |+ 1. 识别文本的核心药物主体+ 2. 提取药物的正名和所有别名、俗称+ 3. 提取药物的四气(寒、热、温、凉、平)+ 4. 提取药物的五味(酸、苦、甘、辛、咸)+ 5. 提取药物的归经(如肺经、肝经、脾经等)+ 6. 提取药物的毒性(无毒、小毒、有毒、大毒)+ 7. 提取药物的推荐剂量+ 8. 句式解析:文言文常采用省略主语、并列结构、连动句式,需先理解句式结构再提取信息+ 9. 术语对应:文言术语与现代术语需正确对应(如"主"指"主治","疗"指"治疗")+ 10. 连写拆分:文言中常连写多个属性(如"味甘微寒"→拆分为"味甘"、"微寒"),需分别归到对应字段+ 11. 古代剂量:文言中古代剂量单位(如两、钱、匕)可保留原文++display:+ label: "{name} ({properties},{flavors})"diff --git a/hyperextract/templates/presets/tcm/meridian_flow_graph.yaml b/hyperextract/templates/presets/tcm/meridian_flow_graph.yamlnew file mode 100644index 0000000..5b51d8d--- /dev/null+++ b/hyperextract/templates/presets/tcm/meridian_flow_graph.yaml@@ -0,0 +1,106 @@+name: "MeridianFlowGraph"+autotype: graph+tag: [tcm]++language: zh++description:+ zh: "经络流注图 - 提取十二经脉的循行路线及经气流注次序"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "经脉名称:如手太阴肺经、手阳明大肠经等"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "经脉类别:阴经、阳经"+ required: true+ default: ""+ - name: associatedOrgan+ type: "string"+ description:+ zh: "关联脏腑"+ required: false+ default: ""+ - name: circulationPath+ type: "string"+ description:+ zh: "循行路线"+ required: false+ default: ""++edge_schema:+ fields:+ - name: source+ type: "string"+ description:+ zh: "源经脉名称"+ required: true+ default: ""+ - name: target+ type: "string"+ description:+ zh: "目标经脉名称"+ required: true+ default: ""+ - name: relationType+ type: "string"+ description:+ zh: "关系类型:流注"+ required: true+ default: ""+ - name: flowOrder+ type: "int"+ description:+ zh: "流注次序"+ required: true+ default: "0"+ - name: connectionPoint+ type: "string"+ description:+ zh: "连接部位"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的经络学专家,请从文本中提取十二经脉的循行路线及经气流注次序。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 关系描述应与原文保持一致+ 5. 经脉:十二经脉,如手太阴肺经、手阳明大肠经+ 6. 经脉类别:阴经、阳经+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 经脉:十二经脉+ 4. 经脉类别:阴经、阳经+ rules_for_edges:+ zh: |+ 1. 仅从已知经脉列表中提取边,不要创建未列出的经脉+ 2. 关系描述应与原文保持一致+ 3. 关系类型:流注++identifiers:+ node_id: "name"+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: "source"+ target: "target"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "流注 #{flowOrder}"diff --git a/hyperextract/templates/presets/tcm/prescription_modification.yaml b/hyperextract/templates/presets/tcm/prescription_modification.yamlnew file mode 100644index 0000000..a530708--- /dev/null+++ b/hyperextract/templates/presets/tcm/prescription_modification.yaml@@ -0,0 +1,102 @@+name: "PrescriptionModification"+autotype: hypergraph+tag: [tcm]++language: zh++description:+ zh: "处方加减逻辑 - 提取基于特定证型或症状对基础方剂进行的药物加减(如"随证加减")"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "实体类型:基础方、药物、证型、症状"+ required: true+ default: ""++edge_schema:+ fields:+ - name: baseFormula+ type: "string"+ description:+ zh: "基础方剂名称"+ required: true+ default: ""+ - name: condition+ type: "string"+ description:+ zh: "加减条件(证型或症状)"+ required: true+ default: ""+ - name: modificationType+ type: "string"+ description:+ zh: "加减类型:加、减、替换"+ required: true+ default: ""+ - name: herbs+ type: "array"+ description:+ zh: "加减药物列表"+ required: true+ default: ""+ - name: reason+ type: "string"+ description:+ zh: "加减原因"+ required: false+ default: ""+ - name: dosage+ type: "string"+ description:+ zh: "调整后的剂量"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的中医方剂专家,请从文本中提取处方加减的实体和超边结构。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 基础方:方剂名称,如桂枝汤、麻黄汤、小柴胡汤+ 5. 药物:中药名称,如葛根、厚朴、杏仁、附子+ 6. 证型/症状:临床表现,如项背强几几、喘、腹满痛+ 7. 加减类型:加、减、替换+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 基础方:方剂名称,如桂枝汤、麻黄汤、小柴胡汤+ 4. 药物:中药名称,如葛根、厚朴、杏仁、附子+ 5. 证型/症状:临床表现,如项背强几几、喘、腹满痛+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 加减类型:加、减、替换(通过 modificationType 字段区分)++identifiers:+ node_id: "name"+ edge_id: "{baseFormula}|{condition}"+ edge_members:+ - "baseFormula"+ - "herbs"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{baseFormula} | {condition}"diff --git a/hyperextract/templates/presets/tcm/processing_method.yaml b/hyperextract/templates/presets/tcm/processing_method.yamlnew file mode 100644index 0000000..7c40d47--- /dev/null+++ b/hyperextract/templates/presets/tcm/processing_method.yaml@@ -0,0 +1,58 @@+name: "ProcessingMethod"+autotype: list+tag: [tcm]++language: zh++description:+ zh: "炮制方法列表 - 提取药物的不同炮制方法(如蜜炙、酒炒)及其对药效的影响"++item_schema:+ fields:+ - name: herbName+ type: "string"+ description:+ zh: "药物名称"+ required: true+ default: ""+ - name: methodName+ type: "string"+ description:+ zh: "炮制方法名称:如蜜炙、酒炒、醋制、盐制等"+ required: true+ default: ""+ - name: process+ type: "string"+ description:+ zh: "具体炮制工艺流程"+ required: true+ default: ""+ - name: effectChange+ type: "string"+ description:+ zh: "炮制对药效的影响"+ required: true+ default: ""+ - name: application+ type: "string"+ description:+ zh: "适用病症或方剂"+ required: true+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的中药炮制专家,请从文本中提取药物的不同炮制方法及其对药效的影响。+ rules:+ zh: |+ 1. 识别文本中提到的所有药物及其炮制方法+ 2. 提取每种炮制方法的名称+ 3. 提取每种炮制方法的具体工艺流程+ 4. 提取炮制对药效的影响+ 5. 常用炮制方法:蜜炙、酒炒、醋制、盐制、炒、煅等+ 6. 每种炮制方法作为独立条目提取+ 7. 保持炮制方法描述与原文一致++display:+ label: "{herbName} - {methodName}"diff --git a/hyperextract/templates/presets/tcm/pulse_tongue_record.yaml b/hyperextract/templates/presets/tcm/pulse_tongue_record.yamlnew file mode 100644index 0000000..0b0d033--- /dev/null+++ b/hyperextract/templates/presets/tcm/pulse_tongue_record.yaml@@ -0,0 +1,64 @@+name: "PulseTongueRecord"+autotype: list+tag: [tcm]++language: zh++description:+ zh: "舌脉特征提取 - 结构化提取舌象(质、苔)与脉象描述,用于统计分析"++item_schema:+ fields:+ - name: type+ type: "string"+ description:+ zh: "特征类型:舌象、脉象"+ required: true+ default: ""+ - name: subType+ type: "string"+ description:+ zh: "子类型:如舌质、舌苔、脉位、脉率、脉势等"+ required: true+ default: ""+ - name: feature+ type: "string"+ description:+ zh: "具体特征描述,如淡红、薄白、浮、沉、迟、数等"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "详细描述"+ required: false+ default: ""+ - name: clinicalSignificance+ type: "string"+ description:+ zh: "临床意义"+ required: false+ default: ""+ - name: source+ type: "string"+ description:+ zh: "来源,如医案名称、章节等"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的中医诊断专家,请从文本中提取舌象和脉象的特征信息。+ rules:+ zh: |+ 1. 提取所有舌象特征,包括舌质(颜色、形态)、舌苔(颜色、厚薄、干湿等)+ 2. 提取所有脉象特征,包括脉位(浮、沉)、脉率(迟、数)、脉势(有力、无力)等+ 3. 为每个特征指定类型和子类型+ 4. 保持特征描述与原文一致+ 5. 舌象描述解析:文言舌象常采用连写表述(如"舌淡红苔薄白"→拆分为舌质淡红、舌苔薄白)+ 6. 脉象术语理解:文言脉象术语需准确识别(如"浮紧脉"→浮脉、紧脉)+ 7. 复合特征拆分:文言中常将多个特征合并描述,需分别提取到对应字段++display:+ label: "{type} - {subType}"diff --git a/hyperextract/templates/presets/tcm/syndrome_reasoning_graph.yaml b/hyperextract/templates/presets/tcm/syndrome_reasoning_graph.yamlnew file mode 100644index 0000000..3133bad--- /dev/null+++ b/hyperextract/templates/presets/tcm/syndrome_reasoning_graph.yaml@@ -0,0 +1,98 @@+name: "SyndromeReasoningGraph"+autotype: hypergraph+tag: [tcm]++language: zh++description:+ zh: "辨证论治逻辑图 - 建模 {症状群} -> 证型 -> 治则 -> {处方} 的完整推理链条"++node_schema:+ fields:+ - name: name+ type: "string"+ description:+ zh: "实体名称,如症状、证型、治则、药物等"+ required: true+ default: ""+ - name: category+ type: "string"+ description:+ zh: "实体类型:症状、证型、治则、药物"+ required: true+ default: ""+ - name: description+ type: "string"+ description:+ zh: "简要描述"+ required: false+ default: ""++edge_schema:+ fields:+ - name: nodes+ type: "array"+ description:+ zh: "参与推理的节点列表:[症状1, 症状2, ..., 证型, 治则, 药物1, 药物2, ...]"+ required: true+ default: ""+ - name: reasoningType+ type: "string"+ description:+ zh: "推理类型:辨证论治、随证加减"+ required: true+ default: ""+ - name: reasoningProcess+ type: "string"+ description:+ zh: "推理过程描述"+ required: false+ default: ""+ - name: source+ type: "string"+ description:+ zh: "推理来源,如医案名称、章节等"+ required: false+ default: ""++extraction_guide:+ target:+ zh: |+ 你是一位专业的中医辨证论治专家,请从文本中提取中医实体和辨证论治推理逻辑作为超边。+ rules:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 仅从已知实体列表中提取边,不要创建未列出的实体+ 4. 症状:临床表现,如发热、汗出、恶风+ 5. 证型:疾病分类,如太阳中风、太阳伤寒+ 6. 治则:治疗原则,如解肌发表、调和营卫+ 7. 药物:中药名称,如桂枝、麻黄、杏仁+ 8. 推理类型:辨证论治、随证加减+ 9. 推理链条:症状群 → 证型 → 治则 → 处方+ rules_for_nodes:+ zh: |+ 1. 每个节点只能对应一个独立的实体,禁止将多个实体合并为一个节点+ 2. 实体名称与原文保持一致+ 3. 症状:临床表现,如发热、汗出、恶风+ 4. 证型:疾病分类,如太阳中风、太阳伤寒+ 5. 治则:治疗原则,如解肌发表、调和营卫+ 6. 药物:中药名称,如桂枝、麻黄、杏仁+ rules_for_edges:+ zh: |+ 1. 仅从已知实体列表中提取边,不要创建未列出的实体+ 2. 关系描述应与原文保持一致+ 3. 推理类型:辨证论治、随证加减+ 4. 推理链条:症状群 → 证型 → 治则 → 处方++identifiers:+ node_id: "name"+ edge_id: "{reasoningType}|{nodes}"+ edge_members: "nodes"++parameters:+ extraction_mode: "two_stage"++display:+ node_label: "{name} ({category})"+ edge_label: "{reasoningType}"diff --git a/hyperextract/templates/zh/medicine/__init__.py b/hyperextract/templates/zh/medicine/__init__.pydeleted file mode 100644index a8c2936..0000000--- a/hyperextract/templates/zh/medicine/__init__.py+++ /dev/null@@ -1,42 +0,0 @@-"""医学领域知识模板"""--from hyperextract.templates.zh.medicine.pathology_hypergraph import PathologyHypergraph-from hyperextract.templates.zh.medicine.medical_concept_net import MedicalConceptNet-from hyperextract.templates.zh.medicine.pharmacology_graph import PharmacologyGraph-from hyperextract.templates.zh.medicine.anatomy_hierarchy import AnatomyHierarchy-from hyperextract.templates.zh.medicine.symptom_differential import SymptomDifferential-from hyperextract.templates.zh.medicine.treatment_regimen_map import TreatmentRegimenMap-from hyperextract.templates.zh.medicine.clinical_pathway import ClinicalPathway-from hyperextract.templates.zh.medicine.level_of_evidence import LevelOfEvidence-from hyperextract.templates.zh.medicine.surgical_event_graph import SurgicalEventGraph-from hyperextract.templates.zh.medicine.hospital_course_timeline import HospitalCourseTimeline-from hyperextract.templates.zh.medicine.discharge_instruction import DischargeInstruction-from hyperextract.templates.zh.medicine.tumor_staging_item import TumorStagingItem-from hyperextract.templates.zh.medicine.microscopic_feature_set import MicroscopicFeatureSet-from hyperextract.templates.zh.medicine.complex_interaction_net import ComplexInteractionNet-from hyperextract.templates.zh.medicine.contraindication_list import ContraindicationList-from hyperextract.templates.zh.medicine.adverse_reaction_stats import AdverseReactionStats--__all__ = [- # 医学教科书与专著- "PathologyHypergraph",- "MedicalConceptNet",- "PharmacologyGraph",- "AnatomyHierarchy",- "SymptomDifferential",- # 临床诊疗指南- "TreatmentRegimenMap",- "ClinicalPathway",- "LevelOfEvidence",- # 出院小结- "SurgicalEventGraph",- "HospitalCourseTimeline",- "DischargeInstruction",- # 病理报告- "TumorStagingItem",- "MicroscopicFeatureSet",- # 药品说明书- "ComplexInteractionNet",- "ContraindicationList",- "AdverseReactionStats",-]\ No newline at end of filediff --git "a/hyperextract/templates/\347\237\245\350\257\206\346\250\241\346\235\277\350\256\276\350\256\241\346\214\207\345\215\227.md" "b/hyperextract/templates/\347\237\245\350\257\206\346\250\241\346\235\277\350\256\276\350\256\241\346\214\207\345\215\227.md"new file mode 100644index 0000000..831e251--- /dev/null+++ "b/hyperextract/templates/\347\237\245\350\257\206\346\250\241\346\235\277\350\256\276\350\256\241\346\214\207\345\215\227.md"@@ -0,0 +1,685 @@+# 知识模板设计指南++本文档为 Hyper-Extract 知识模板的 YAML 配置提供系统化的设计指导,帮助开发者创建高质量、可维护的模板配置。++---++## 目录++1. [概述](#1-概述)+2. [快速入门](#2-快速入门)+3. [配置字段详解](#3-配置字段详解)+4. [多语言配置指南](#4-多语言配置指南)+5. [AutoType 类型指南](#5-autotype-类型指南)+6. [最佳实践](#6-最佳实践)+7. [常见模式参考](#7-常见模式参考)++---++## 1. 概述++### 1.1 什么是知识模板++知识模板是 Hyper-Extract 系统中用于定义结构化信息提取规则的配置文件。通过声明式的 YAML 格式,开发者可以定义:++- **数据结构**:提取结果的 Schema 定义+- **提取逻辑**:LLM 应该从文本中提取什么+- **标识规则**:如何唯一识别实体和关系+- **展示方式**:结果如何呈现给用户++### 1.2 YAML 格式简介++YAML(YAML Ain't Markup Language)是一种人类可读的数据序列化格式,广泛用于配置文件。++**参考文档**:[YAML 官方文档](https://yaml.org/)++**基本特点**:+- 使用缩进表示层级关系+- 键值对使用 `key: value` 格式+- 数组使用 `-` 开头+- 多行文本使用 `|` 或 `>` 符号++### 1.3 模板系统架构++```+┌─────────────────────────────────────────────────────────────┐+│ YAML 配置文件 │+│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────────────┐ │+│ │ name │ │ autotype│ │ schema │ │ extraction_guide│ │+│ │ tag │ │ language│ │ ... │ │ identifiers │ │+│ │ ... │ │ │ │ │ │ display │ │+│ └─────────┘ └─────────┘ └─────────┘ └─────────────────┘ │+└─────────────────────────────────────────────────────────────┘+ │+ ▼+┌─────────────────────────────────────────────────────────────┐+│ TemplateFactory │+│ (将 YAML 配置转换为运行时模板) │+└─────────────────────────────────────────────────────────────┘+ │+ ▼+┌─────────────────────────────────────────────────────────────┐+│ 提取结果 (结构化数据) │+│ Model / List / Set / Graph │+└─────────────────────────────────────────────────────────────┘+```++### 1.4 语言配置说明++**重要**:YAML 配置中的 `language` 字段用于指定默认语言。当设置为单语言(如 `zh`)时,描述字段可以直接书写,无需额外的语言键。++```yaml+# language: zh 时(单语言)+# 描述字段直接书写,不需要额外的 zh: 键+name: EarningsCallSummary+language: zh++description: 财报电话会议摘要 - 从财报电话会议记录中提取关键财务指标++schema:+ fields:+ - name: company_name+ type: string+ description: 公司名称+```++**多语言情况**:当需要支持多语言时,才需要使用语言键格式:++```yaml+language: zh++description:+ zh: 中文描述+ en: English description+```++### 1.5 支持的 AutoType 类型++| 类型 | YAML 值 | 说明 |+|------|---------|------|+| AutoModel | `model` | 提取单个结构化对象 |+| AutoList | `list` | 提取对象列表 |+| AutoSet | `set` | 提取去重实体集合 |+| AutoGraph | `graph` | 简单二元关系图谱 |+| AutoHypergraph | `hypergraph` | 复杂多元关系图谱 |+| AutoTemporalGraph | `temporal_graph` | 时序图谱 |+| AutoSpatialGraph | `spatial_graph` | 空间图谱 |+| AutoSpatioTemporalGraph | `spatio_temporal_graph` | 时空图谱 |++---++## 2. 快速入门++### 2.1 最简配置 (AutoModel)++```yaml+# 最简单的 model 类型配置+name: MyTemplate+autotype: model+tag: [general]++language: zh++description: 模板简短描述++schema:+ fields:+ - name: field_name+ type: string+ description: 字段描述++extraction_guide:+ target: 你是一位专家,请从文本中提取信息。++ rules: |+ 1. 提取规则1+ 2. 提取规则2++identifiers: {}++parameters: {}++display:+ label: field_name+```++### 2.2 完整配置示例 (AutoGraph)++```yaml+name: MyKnowledgeGraph+autotype: graph+tag: [domain_name]++language: zh++description: 知识图谱描述++node_schema:+ fields:+ - name: name+ type: string+ description: 实体名称+ - name: category+ type: string+ description: 实体类别++edge_schema:+ fields:+ - name: source+ type: string+ description: 源实体+ - name: target+ type: string+ description: 目标实体+ - name: relationType+ type: string+ description: 关系类型++extraction_guide:+ target: 你是一位领域专家...++ rules: |+ 1. 规则1+ 2. 规则2++ rules_for_nodes: |+ 1. 节点提取规则++ rules_for_edges: |+ 1. 边提取规则++identifiers:+ node_id: name+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: source+ target: target++parameters:+ extraction_mode: two_stage++display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"+```++---++## 3. 配置字段详解++### 3.1 通用必需字段++以下字段是所有模板都必须配置的:++| 字段 | 说明 | 示例 |+|------|------|------|+| `name` | 模板类名,唯一标识 | `EarningsCallSummary` |+| `autotype` | 模板类型 | `model`, `graph`, `list` 等 |+| `tag` | 领域标签数组 | `[finance]`, `[medicine, tcm]` |+| `language` | 语言代码 | `zh` |+| `description` | 模板描述 | 简要说明模板用途 |++### 3.2 其他字段说明++以下字段的具体配置请参考各 AutoType 类型章节:++| 字段 | 说明 |+|------|------|+| `schema` / `item_schema` / `node_schema` / `edge_schema` | 数据结构定义 |+| `extraction_guide` | 提取指南 |+| `identifiers` | 标识配置 |+| `parameters` | 运行时参数 |+| `display` | 展示配置 |++---++## 4. 多语言配置指南++### 4.1 单语言格式++当 `language` 设置为单一语言(如 `zh`)时,描述字段直接书写:++```yaml+name: EarningsCallSummary+language: zh++description: 财报电话会议摘要 - 从财报电话会议记录中提取关键财务指标++schema:+ fields:+ - name: company_name+ type: string+ description: 公司名称+```++### 4.2 多语言格式++当需要支持多语言时,使用语言键格式:++```yaml+language: zh++description:+ zh: 中文描述+ en: English description++schema:+ fields:+ - name: company_name+ type: string+ description:+ zh: 公司名称+ en: Company name+```++---++## 5. AutoType 类型指南++### 5.1 AutoType 类型概览表++| 类型 | 值 | Schema | Identifiers | Extraction Guide | Display |+|------|------|--------|-------------|-------------------|---------|+| AutoModel | `model` | `schema` | - | target, rules | label |+| AutoList | `list` | `item_schema` | - | target, rules | label |+| AutoSet | `set` | `item_schema` | item_id | target, rules | label |+| AutoGraph | `graph` | node_schema + edge_schema | node_id, edge_id, edge_members | target, rules, rules_for_nodes, rules_for_edges | node_label + edge_label |+| AutoHypergraph | `hypergraph` | node_schema + edge_schema | node_id, edge_id, edge_members | target, rules, rules_for_nodes, rules_for_edges | node_label + edge_label |+| AutoTemporalGraph | `temporal_graph` | node_schema + edge_schema | + time_field | + rules_for_time | node_label + edge_label |+| AutoSpatialGraph | `spatial_graph` | node_schema + edge_schema | + location_field | + rules_for_location | node_label + edge_label |+| AutoSpatioTemporalGraph | `spatio_temporal_graph` | node_schema + edge_schema | + time_field + location_field | + rules_for_time + rules_for_location | node_label + edge_label |++### 5.2 AutoModel - 结构化模型++用于提取单个结构化对象,包含多个字段。++**schema 定义**:+```yaml+schema:+ fields:+ - name: company_name+ type: string+ description: 公司名称+ required: true+ default: ""+ - name: revenue+ type: string+ description: 营收金额+ required: false+ default: "N/A"+```++**extraction_guide 编写**:+```yaml+extraction_guide:+ target: 你是一位财务分析师,请从财报中提取关键信息。++ rules: |+ 1. 每个字段对应一个独立的信息项+ 2. 数据与原文保持一致+```++**display 配置**:+```yaml+display:+ label: "{company_name}"+```++**完整示例**:+```yaml+name: EarningsCallSummary+autotype: model+tag: [finance]++language: zh++description: 财报电话会议摘要++schema:+ fields:+ - name: company_name+ type: string+ description: 公司名称+ - name: revenue+ type: string+ description: 营收金额++extraction_guide:+ target: 你是一位财务分析师,请从财报中提取关键信息。++ rules: |+ 1. 每个字段对应一个独立的信息项++identifiers: {}++display:+ label: "{company_name}"+```++### 5.3 AutoList - 列表++用于提取对象列表,每个对象结构相同。++**item_schema 定义**:+```yaml+item_schema:+ fields:+ - name: term+ type: string+ description: 关键词+ - name: frequency+ type: int+ description: 出现频次+```++**display 配置**:+```yaml+display:+ label: term+```++**完整示例**:+```yaml+name: KeywordList+autotype: list++language: zh++description: 关键词列表++item_schema:+ fields:+ - name: term+ type: string+ description: 关键词++extraction_guide:+ target: 你是一位关键词提取专家++ rules: |+ 1. 提取文本中的所有关键词++identifiers: {}++display:+ label: term+```++### 5.4 AutoSet - 集合++用于提取去重实体集合。++**item_schema 定义**:同 AutoList++**identifiers 配置**:+```yaml+identifiers:+ item_id: name+```++**完整示例**:+```yaml+name: EntityRegistry+autotype: set++language: zh++description: 实体注册表++item_schema:+ fields:+ - name: name+ type: string+ description: 实体名称+ - name: category+ type: string+ description: 实体类型++extraction_guide:+ target: 你是一位实体识别专家++ rules: |+ 1. 提取所有实体并去重++identifiers:+ item_id: name++display:+ label: name+```++### 5.5 AutoGraph - 简单二元关系图谱++用于提取实体和它们之间的二元关系。++**node_schema 定义**:+```yaml+node_schema:+ fields:+ - name: name+ type: string+ description: 实体名称+ - name: category+ type: string+ description: 实体类别+```++**edge_schema 定义**:+```yaml+edge_schema:+ fields:+ - name: source+ type: string+ description: 源实体+ - name: target+ type: string+ description: 目标实体+ - name: relationType+ type: string+ description: 关系类型+```++**identifiers 配置**:+```yaml+identifiers:+ node_id: name+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: source+ target: target+```++**extraction_guide 编写**:+```yaml+extraction_guide:+ target: 你是一位知识图谱专家...++ rules: |+ 1. 每个节点对应一个独立实体++ rules_for_nodes: |+ 1. 实体名称与原文保持一致++ rules_for_edges: |+ 1. source 和 target 都必须是已知节点+```++**display 配置**:+```yaml+display:+ node_label: "{name} ({category})"+ edge_label: "{relationType}"+```++### 5.6 AutoHypergraph - 复杂多元关系图谱++用于建模多个实体之间的复杂关联关系。++**与 AutoGraph 的区别**:+- AutoGraph 是**二元关系**:每条边连接两个节点+- AutoHypergraph 是**多元关系**:一条边可以连接任意数量的节点++**edge_schema 定义**:+```yaml+edge_schema:+ fields:+ - name: mechanism_name+ type: string+ description: 机制名称+ - name: participating_entities+ type: array+ description: 参与的实体列表+ - name: relationType+ type: string+ description: 关系类型+ - name: outcome+ type: string+ description: 结果+```++**identifiers 配置**:+```yaml+identifiers:+ node_id: name+ edge_id: mechanism_name+ edge_members:+ source: participating_entities+ target: outcome+```++### 5.7 AutoTemporalGraph - 时序图谱++用于提取带有时间信息的实体关系。++**特有 identifiers 配置**:+```yaml+identifiers:+ node_id: name+ edge_id: "{source}|{relationType}|{target}"+ edge_members:+ source: source+ target: target+ time_field: fiscal_period+```++**特有 extraction_guide 编写**:+```yaml+extraction_guide:+ rules_for_time: |+ 当前观察日期:{observation_time}+ 1. "去年" → {observation_time} 的前一年+```++**特有 parameters 配置**:+```yaml+parameters:+ extraction_mode: two_stage+ observation_time: "2024-01-01"+```++### 5.8 AutoSpatialGraph - 空间图谱++用于提取带有位置信息的实体关系。++**特有 identifiers 配置**:+```yaml+identifiers:+ location_field: location+```++**特有 extraction_guide 编写**:+```yaml+extraction_guide:+ rules_for_location: |+ 当前观察位置:{observation_location}+ 1. "这里" → {observation_location}+```++**特有 parameters 配置**:+```yaml+parameters:+ observation_location: "北京"+```++### 5.9 AutoSpatioTemporalGraph - 时空图谱++综合 AutoTemporalGraph 和 AutoSpatialGraph 的所有配置。++**同时包含**:+- `time_field` + `rules_for_time` + `observation_time`+- `location_field` + `rules_for_location` + `observation_location`++---++## 6. 最佳实践++### 6.1 命名规范++- **name**: 使用 PascalCase,如 `EarningsCallSummary`+- **tag**: 使用小写,如 `[finance]`, `[medicine]`+- **字段名**: 使用 snake_case,如 `company_name`, `fiscal_period`+- **关系类型**: 使用中文,如 `拥有`、`影响`++### 6.2 description 撰写++- 简洁明了,一句话说明模板用途+- 说明输入文本来源+- 说明提取目标++**示例**:+```yaml+description: 财报电话会议摘要 - 从财报电话会议记录中提取关键财务指标+```++### 6.3 测试验证++创建模板后,建议:+1. 使用真实文本测试提取效果+2. 检查字段覆盖是否完整+3. 验证边节点关系是否正确+4. 确认时间/位置解析是否准确++---++## 7. 常见模式参考++| 模式 | AutoType | 示例文件 |+|------|----------|----------|+| 财报摘要 | AutoModel | `earnings_call_summary.yaml` |+| 财务时序图谱 | AutoTemporalGraph | `financial_data_temporal_graph.yaml` |+| 病理超图 | AutoHypergraph | `pathology_hypergraph.yaml` |+| 关键词列表 | AutoList | `keyword_list.yaml` |+| 实体注册表 | AutoSet | `entity_registry.yaml` |+| 经络流注图 | AutoGraph | `meridian_flow_graph.yaml` |++---++## 附录++### A. AutoType 快速选择++```+需要提取单个对象 → AutoModel+需要提取列表 → AutoList+需要去重集合 → AutoSet+需要二元关系 → AutoGraph+需要多元关系 → AutoHypergraph+需要时间信息 → AutoTemporalGraph+需要位置信息 → AutoSpatialGraph+需要时间和位置 → AutoSpatioTemporalGraph+```++### B. 目录结构参考++```+hyperextract/templates/+├── presets/+│ ├── finance/ # 财经领域+│ ├── medicine/ # 医疗领域+│ ├── tcm/ # 中医领域+│ ├── law/ # 法律领域+│ ├── general/ # 通用领域+│ └── ...+├── PYTHON转YAML配置指南.md # 迁移指南+└── 知识模板设计指南.md # 本指南+```diff --git a/hyperextract/types/base.py b/hyperextract/types/base.pyindex 05cb238..7fa5a9a 100644--- a/hyperextract/types/base.py+++ b/hyperextract/types/base.py@@ -196,7 +196,7 @@ class BaseAutoType(ABC, Generic[T]):def _set_data_state(self, data: T) -> None:"""HOOK: Overwrite data state with new data (SET).- Called by extract() or load() where the data provided IS the new state.+ Called by parse() or load() where the data provided IS the new state.Subclass Responsibilities:1. Replace self._data with new data (full reset)@@ -257,9 +257,9 @@ class BaseAutoType(ABC, Generic[T]):merged_data = self.merge_batch_data(extracted_data_list)return merged_data- def extract(self, text: str) -> "BaseAutoType[T]":+ def parse(self, text: str) -> "BaseAutoType[T]":"""- Extracts knowledge into a NEW instance without modifying the current one.+ Parses knowledge into a NEW instance without modifying the current one.Use this for previewing data or branching knowledge bases.@@ -267,12 +267,12 @@ class BaseAutoType(ABC, Generic[T]):text: Input text.Returns:- A new knowledge instance containing only the extracted data.+ A new knowledge instance containing only the parsed data."""- extracted_data = self._extract_data(text)+ parsed_data = self._extract_data(text)new_instance = self._create_empty_instance()- new_instance._set_data_state(extracted_data)+ new_instance._set_data_state(parsed_data)new_instance.metadata["created_at"] = datetime.now()new_instance.metadata["updated_at"] = datetime.now()diff --git a/hyperextract/types/list.py b/hyperextract/types/list.pyindex c54ed2e..ec2a6bd 100644--- a/hyperextract/types/list.py+++ b/hyperextract/types/list.py@@ -179,7 +179,7 @@ class AutoList(BaseAutoType[AutoListSchema[ItemSchema]], Generic[ItemSchema]):def _set_data_state(self, data: AutoListSchema) -> None:"""SET: Full reset. Replace with new data (e.g., load from disk).- Called by extract() or load() where data IS the new state.+ Called by parse() or load() where data IS the new state."""self._data = dataself.clear_index()diff --git a/hyperextract/types/model.py b/hyperextract/types/model.pyindex 6f5ca34..ca7bd1d 100644--- a/hyperextract/types/model.py+++ b/hyperextract/types/model.py@@ -176,7 +176,7 @@ class AutoModel(BaseAutoType[T]):def _set_data_state(self, data: T) -> None:"""SET: Full reset. Replace with new data (e.g., load from disk).- Called by extract() or load() where data IS the new state.+ Called by parse() or load() where data IS the new state."""self._data = dataself.clear_index()diff --git a/hyperextract/types/set.py b/hyperextract/types/set.pyindex 9ac496c..5ec80ff 100644--- a/hyperextract/types/set.py+++ b/hyperextract/types/set.py@@ -87,7 +87,7 @@ class AutoSet(BaseAutoType[AutoSetSchema[ItemSchema]], Generic[ItemSchema]):... key_extractor=lambda x: x.term,... merge_item_strategy="field_merge"... )- >>> keywords.extract("Python is great. Python is powerful.")+ >>> keywords.parse("Python is great. Python is powerful.")>>> len(keywords) # Only 1 item (deduplicated)1"""@@ -275,7 +275,7 @@ class AutoSet(BaseAutoType[AutoSetSchema[ItemSchema]], Generic[ItemSchema]):def _set_data_state(self, data: AutoSetSchema[ItemSchema]) -> None:"""SET: Full Reset. Wipe OMem and refill from data (e.g., load from disk).- Called by extract() or load() where data IS the new state.+ Called by parse() or load() where data IS the new state."""self._data_memory.clear()if data.items:diff --git a/hyperextract/utils/template_engine/__init__.py b/hyperextract/utils/template_engine/__init__.pynew file mode 100644index 0000000..09c0942--- /dev/null+++ b/hyperextract/utils/template_engine/__init__.py@@ -0,0 +1,55 @@+"""Template Engine - Automatically generate templates from YAML configuration.++This module provides functionality to dynamically generate HyperExtract templates from YAML configuration files.++Usage Examples:+ >>> from hyperextract.utils.template_engine import Gallery, TemplateFactory+ >>>+ >>> # Get template (auto-loaded presets and customs)+ >>> config = Gallery.get("KnowledgeGraph")+ >>> template = TemplateFactory.create(config, llm_client, embedder)+ >>>+ >>> # List all templates+ >>> print(Gallery.list_all())+ >>>+ >>> # Add custom template directory (auto-loaded)+ >>> Gallery.add_path("/path/to/my/templates")+"""++from .config_loader import (+ TemplateConfig,+ ConfigLoader,+ FieldDescription,+ SchemaField,+ ExtractionGuide,+ Identifiers,+ Parameters,+ Display,+)++from .schema_builder import SchemaBuilder++from .identifier_resolver import IdentifierResolver++from .prompt_builder import PromptBuilder++from .template_factory import TemplateFactory++from .template_gallery import Gallery+++__all__ = [+ "TemplateConfig",+ "ConfigLoader",+ "FieldDescription",+ "SchemaField",+ "ExtractionGuide",+ "Identifiers",+ "Parameters",+ "Display",+ "SchemaBuilder",+ "IdentifierResolver",+ "PromptBuilder",+ "TemplateFactory",+ "Gallery",+]diff --git a/hyperextract/utils/template_engine/config_loader.py b/hyperextract/utils/template_engine/config_loader.pynew file mode 100644index 0000000..bb4fc6c--- /dev/null+++ b/hyperextract/utils/template_engine/config_loader.py@@ -0,0 +1,245 @@+"""Config Loader - Loads and validates YAML configuration files.++Provides configuration schema definition, multilingual field parsing, and configuration validation.+"""++from typing import Any, Dict, List, Literal, Optional, Union+from pathlib import Path+from pydantic import BaseModel, Field, field_validator, ConfigDict+import yaml+++class FieldDescription(BaseModel):+ """Field description with multilingual support."""++ zh: Optional[str] = None+ en: Optional[str] = None++ def get(self, language: str = "zh") -> str:+ """Get description for specified language."""+ if isinstance(self, str):+ return self+ return getattr(self, language) or self.zh or ""+++class SchemaField(BaseModel):+ """Schema field definition."""++ name: str+ type: Literal["string", "int", "float", "bool", "array"]+ description: Optional[Union[str, Dict[str, str]]] = None+ required: bool = False+ default: Optional[Any] = None+ item_type: Optional[str] = None++ @field_validator("description", mode="before")+ @classmethod+ def parse_description(cls, v):+ """Parse description field, supports plain string or multilingual dict."""+ return v+++class BaseSchema(BaseModel):+ """Base schema configuration."""++ fields: List[SchemaField] = Field(default_factory=list)+++class ModelSchema(BaseSchema):+ """Model type schema."""+ pass+++class ItemSchema(BaseSchema):+ """List/Set type item schema."""+ pass+++class NodeSchema(BaseSchema):+ """Graph type node schema."""+ pass+++class EdgeSchema(BaseSchema):+ """Graph type edge schema."""+ pass+++class ExtractionGuideTarget(BaseModel):+ """Extraction target with role definition and content description."""++ zh: Optional[str] = None+ en: Optional[str] = None++ @classmethod+ def from_value(cls, value: Union[str, Dict[str, str], None]) -> Optional["ExtractionGuideTarget"]:+ """Create instance from string or dict."""+ if value is None:+ return None+ if isinstance(value, str):+ return cls(zh=value)+ if isinstance(value, dict):+ return cls(**value)+ return None++ def get(self, language: str = "zh") -> str:+ """Get content for specified language."""+ return getattr(self, language) or self.zh or ""+++class ExtractionGuide(BaseModel):+ """Extraction guide configuration."""++ target: Optional[Union[str, Dict[str, str]]] = None+ rules: Optional[Union[str, Dict[str, str]]] = None+ rules_for_nodes: Optional[Union[str, Dict[str, str]]] = None+ rules_for_edges: Optional[Union[str, Dict[str, str]]] = None+ rules_for_time: Optional[Union[str, Dict[str, str]]] = None+ rules_for_location: Optional[Union[str, Dict[str, str]]] = None++ def get_field(self, field_name: str, language: str = "zh") -> Optional[str]:+ """Get specified field content for specified language."""+ value = getattr(self, field_name, None)+ if value is None:+ return None+ if isinstance(value, str):+ return value+ if isinstance(value, dict):+ return value.get(language) or value.get("zh") or ""+ return None+++class Identifiers(BaseModel):+ """Identifier configuration."""++ item_id: Optional[str] = None+ node_id: Optional[str] = None+ edge_id: Optional[str] = None+ edge_members: Optional[Union[str, Dict[str, str]]] = None+ time_field: Optional[str] = None+ location_field: Optional[str] = None+++class Parameters(BaseModel):+ """Runtime parameters configuration."""++ merge_strategy: Optional[str] = None+ custom_merge_rule: Optional[Union[str, Dict[str, str]]] = None+ node_merge_strategy: Optional[str] = None+ node_custom_merge_rule: Optional[Union[str, Dict[str, str]]] = None+ edge_merge_strategy: Optional[str] = None+ edge_custom_merge_rule: Optional[Union[str, Dict[str, str]]] = None+ extraction_mode: Optional[str] = None+ observation_time: Optional[str] = None+ observation_location: Optional[str] = None+ chunk_size: int = 2048+ chunk_overlap: int = 256+ max_workers: int = 10+ verbose: bool = False+ search_fields: Optional[List[str]] = None+ node_search_fields: Optional[List[str]] = None+ edge_search_fields: Optional[List[str]] = None++ def get_merge_strategy(self) -> Optional[str]:+ """Get merge strategy."""+ return self.merge_strategy or self.node_merge_strategy++ def get_custom_merge_rule(self, language: str = "zh") -> Optional[str]:+ """Get custom merge rule."""+ rule = self.custom_merge_rule or self.node_custom_merge_rule+ if rule is None:+ return None+ if isinstance(rule, str):+ return rule+ if isinstance(rule, dict):+ return rule.get(language) or rule.get("zh") or ""+ return None+++class Display(BaseModel):+ """Display configuration."""++ label: Optional[str] = None+ node_label: Optional[str] = None+ edge_label: Optional[str] = None+++class TemplateConfig(BaseModel):+ """Template configuration top-level model."""++ name: str+ autotype: Literal[+ "model", "list", "set", "graph", "hypergraph",+ "temporal_graph", "spatial_graph", "spatio_temporal_graph"+ ]+ tag: Optional[List[str]] = None+ language: Optional[Union[str, List[str]]] = "zh"+ description: Optional[Union[str, Dict[str, str]]] = None+ model_schema: Optional[ModelSchema] = Field(None, alias="schema")+ item_schema: Optional[ItemSchema] = None+ node_schema: Optional[NodeSchema] = None+ edge_schema: Optional[EdgeSchema] = None+ extraction_guide: Optional[ExtractionGuide] = None+ identifiers: Optional[Identifiers] = None+ parameters: Optional[Parameters] = None+ display: Optional[Display] = None++ model_config = ConfigDict(populate_by_name=True)++ @field_validator("description", mode="before")+ @classmethod+ def parse_description(cls, v):+ """Parse description field."""+ return v++ def model_dump(self, **kwargs):+ """Override model_dump to handle alias."""+ data = super().model_dump(**kwargs)+ if "schema" in data and data["schema"] is None:+ data["schema"] = data.pop("model_schema", None)+ return data+++class ConfigLoader:+ """Config loader."""++ @staticmethod+ def load_yaml(file_path: Union[str, Path]) -> Dict[str, Any]:+ """Load YAML configuration file."""+ path = Path(file_path)+ if not path.exists():+ raise FileNotFoundError(f"Config file not found: {file_path}")++ with open(path, "r", encoding="utf-8") as f:+ return yaml.safe_load(f) or {}++ @staticmethod+ def load_config(file_path: Union[str, Path]) -> TemplateConfig:+ """Load and validate configuration."""+ data = ConfigLoader.load_yaml(file_path)+ return TemplateConfig(**data)++ @staticmethod+ def load_config_from_dict(data: Dict[str, Any]) -> TemplateConfig:+ """Load configuration from dict."""+ return TemplateConfig(**data)++ @staticmethod+ def get_text_value(value: Union[str, Dict[str, str], None], language: str = "zh") -> Optional[str]:+ """Get multilingual text value."""+ if value is None:+ return None+ if isinstance(value, str):+ return value+ if isinstance(value, dict):+ return value.get(language) or value.get("zh") or ""+ return None++ @staticmethod+ def validate_autotype(autotype: str) -> bool:+ """Validate if autotype is valid."""+ valid_types = {+ "model", "list", "set", "graph", "hypergraph",+ "temporal_graph", "spatial_graph", "spatio_temporal_graph"+ }+ return autotype in valid_typesdiff --git a/hyperextract/utils/template_engine/identifier_resolver.py b/hyperextract/utils/template_engine/identifier_resolver.pynew file mode 100644index 0000000..1d075f0--- /dev/null+++ b/hyperextract/utils/template_engine/identifier_resolver.py@@ -0,0 +1,125 @@+"""Identifier Resolver - Generates extraction functions for nodes and edges.++Converts identifier definitions in configuration to callable functions.+"""++from typing import Any, Callable, Dict, List, Optional, Tuple, Union+from pydantic import BaseModel+++class IdentifierResolver:+ """Identifier Resolver."""++ @staticmethod+ def resolve_item_id(field_name: str) -> Callable[[BaseModel], str]:+ """Generate item ID extractor for Set type."""+ def extractor(item: BaseModel) -> str:+ value = getattr(item, field_name, None)+ return str(value) if value is not None else ""+ return extractor++ @staticmethod+ def resolve_node_id(field_name: str) -> Callable[[BaseModel], str]:+ """Generate node ID extractor."""+ def extractor(node: BaseModel) -> str:+ value = getattr(node, field_name, None)+ return str(value) if value is not None else ""+ return extractor++ @staticmethod+ def resolve_edge_id(template: str) -> Callable[[BaseModel], str]:+ """Generate edge ID extractor (supports template string)."""+ def extractor(edge: BaseModel) -> str:+ try:+ return template.format(**edge.model_dump())+ except (KeyError, ValueError):+ parts = []+ for key in template.split("|"):+ key = key.strip().strip("{}")+ value = getattr(edge, key, None)+ parts.append(str(value) if value is not None else "")+ return "|".join(parts)+ return extractor++ @staticmethod+ def resolve_edge_members(+ edge_members: Union[str, Dict[str, str]]+ ) -> Callable[[BaseModel], Tuple[str, ...]]:+ """Generate edge member extractor (unified for binary edge/hyperedge)."""+ if isinstance(edge_members, str):+ def extractor(edge: BaseModel) -> Tuple[str, ...]:+ value = getattr(edge, edge_members, None)+ if value is None:+ return ()+ if isinstance(value, (list, tuple)):+ return tuple(str(v) for v in value)+ return (str(value),)+ return extractor+ elif isinstance(edge_members, dict):+ source_key = edge_members.get("source", "source")+ target_key = edge_members.get("target", "target")++ def extractor(edge: BaseModel) -> Tuple[str, str]:+ source = getattr(edge, source_key, None)+ target = getattr(edge, target_key, None)+ return (+ str(source) if source is not None else "",+ str(target) if target is not None else "",+ )+ return extractor+ else:+ raise ValueError(f"Invalid edge_members configuration: {edge_members}")++ @staticmethod+ def resolve_time(field_name: str) -> Callable[[BaseModel], str]:+ """Generate time extractor."""+ def extractor(item: BaseModel) -> str:+ value = getattr(item, field_name, None)+ return str(value) if value is not None else ""+ return extractor++ @staticmethod+ def resolve_location(field_name: str) -> Callable[[BaseModel], str]:+ """Generate location extractor."""+ def extractor(item: BaseModel) -> str:+ value = getattr(item, field_name, None)+ return str(value) if value is not None else ""+ return extractor++ @classmethod+ def resolve_all(cls, config) -> Dict[str, Callable]:+ """Resolve all identifier extractors based on configuration."""+ result = {}+ identifiers = config.identifiers or {}+ autotype = config.autotype++ # Handle Identifiers object or dict+ if hasattr(identifiers, 'model_dump'):+ identifiers_dict = identifiers.model_dump()+ elif isinstance(identifiers, dict):+ identifiers_dict = identifiers+ else:+ identifiers_dict = {}++ if autotype == "set" and identifiers_dict.get("item_id"):+ result["item_id_extractor"] = cls.resolve_item_id(identifiers_dict["item_id"])++ if autotype in ("graph", "hypergraph", "temporal_graph", "spatial_graph", "spatio_temporal_graph"):+ if identifiers_dict.get("node_id"):+ result["node_key_extractor"] = cls.resolve_node_id(identifiers_dict["node_id"])++ if identifiers_dict.get("edge_id"):+ result["edge_key_extractor"] = cls.resolve_edge_id(identifiers_dict["edge_id"])++ if identifiers_dict.get("edge_members"):+ result["nodes_in_edge_extractor"] = cls.resolve_edge_members(identifiers_dict["edge_members"])++ if autotype in ("temporal_graph", "spatio_temporal_graph"):+ if identifiers_dict.get("time_field"):+ result["time_in_edge_extractor"] = cls.resolve_time(identifiers_dict["time_field"])++ if autotype in ("spatial_graph", "spatio_temporal_graph"):+ if identifiers_dict.get("location_field"):+ result["location_in_edge_extractor"] = cls.resolve_location(identifiers_dict["location_field"])++ return resultdiff --git a/hyperextract/utils/template_engine/prompt_builder.py b/hyperextract/utils/template_engine/prompt_builder.pynew file mode 100644index 0000000..7b9961c--- /dev/null+++ b/hyperextract/utils/template_engine/prompt_builder.py@@ -0,0 +1,240 @@+"""Prompt Builder - Builds extraction prompts for various AutoType.++Supports extraction_guide target field, automatically adds titles to rules.+"""++from typing import Any, Callable, Dict, List, Optional, Tuple, Union+from .config_loader import ExtractionGuide+++LABEL_MAPPING = {+ "zh": {+ "source_text": "源文本",+ "known_entities": "已知实体",+ "extraction_rules": "提取规则",+ "node_extraction_rules": "节点提取规则",+ "edge_extraction_rules": "边提取规则",+ "time_rules": "时间规则",+ "location_rules": "位置规则",+ "role_and_task": "角色与任务",+ },+ "en": {+ "source_text": "Source Text",+ "known_entities": "Known Entities",+ "extraction_rules": "Extraction Rules",+ "node_extraction_rules": "Node Extraction Rules",+ "edge_extraction_rules": "Edge Extraction Rules",+ "time_rules": "Time Rules",+ "location_rules": "Location Rules",+ "role_and_task": "Role and Task",+ },+}+++class PromptBuilder:+ """Prompt Builder."""++ def __init__(self, language: str = "zh"):+ """Initialize Prompt Builder."""+ self.language = language+ self.labels = LABEL_MAPPING.get(language, LABEL_MAPPING["zh"])++ @staticmethod+ def _get_text(value: Optional[Union[str, Dict[str, str]]], language: str = "zh") -> Optional[str]:+ """Get multilingual text value."""+ if value is None:+ return None+ if isinstance(value, str):+ return value+ if isinstance(value, dict):+ return value.get(language) or value.get("zh") or ""+ return None++ def _add_title(self, text: str, title_key: str) -> str:+ """Add title to text."""+ title = self.labels.get(title_key, title_key)+ return f"### {title}\n{text}"++ def build_target(self, extraction_guide: ExtractionGuide) -> Optional[str]:+ """Build target field (role definition + extraction content description)."""+ target = extraction_guide.target+ if target is None:+ return None+ return self._get_text(target, self.language)++ def build_rules(self, extraction_guide: ExtractionGuide) -> Optional[str]:+ """Build rules field (with title)."""+ rules = self._get_text(extraction_guide.rules, self.language)+ if rules:+ return self._add_title(rules, "extraction_rules")+ return None++ def build_rules_for_nodes(self, extraction_guide: ExtractionGuide) -> Optional[str]:+ """Build rules_for_nodes field (with title)."""+ rules = self._get_text(extraction_guide.rules_for_nodes, self.language)+ if rules:+ return self._add_title(rules, "node_extraction_rules")+ return None++ def build_rules_for_edges(self, extraction_guide: ExtractionGuide) -> Optional[str]:+ """Build rules_for_edges field (with title)."""+ rules = self._get_text(extraction_guide.rules_for_edges, self.language)+ if rules:+ return self._add_title(rules, "edge_extraction_rules")+ return None++ def build_rules_for_time(self, extraction_guide: ExtractionGuide) -> Optional[str]:+ """Build rules_for_time field (with title)."""+ rules = self._get_text(extraction_guide.rules_for_time, self.language)+ if rules:+ return self._add_title(rules, "time_rules")+ return None++ def build_rules_for_location(self, extraction_guide: ExtractionGuide) -> Optional[str]:+ """Build rules_for_location field (with title)."""+ rules = self._get_text(extraction_guide.rules_for_location, self.language)+ if rules:+ return self._add_title(rules, "location_rules")+ return None++ def build_model_prompt(self, extraction_guide: ExtractionGuide) -> str:+ """Build Model/List/Set type Prompt."""+ parts = []++ target = self.build_target(extraction_guide)+ if target:+ parts.append(target)++ rules = self.build_rules(extraction_guide)+ if rules:+ parts.append(rules)++ source_label = self.labels.get("source_text", "源文本")+ parts.append(f"## {source_label}:\n{{source_text}}")++ return "\n\n".join(parts)++ def build_graph_main_prompt(self, extraction_guide: ExtractionGuide) -> str:+ """Build Graph type main Prompt (single-stage mode)."""+ parts = []++ target = self.build_target(extraction_guide)+ if target:+ parts.append(target)++ rules_for_nodes = self.build_rules_for_nodes(extraction_guide)+ if rules_for_nodes:+ parts.append(rules_for_nodes)++ rules_for_edges = self.build_rules_for_edges(extraction_guide)+ if rules_for_edges:+ parts.append(rules_for_edges)++ source_label = self.labels.get("source_text", "源文本")+ parts.append(f"## {source_label}:\n{{source_text}}")++ return "\n\n".join(parts)++ def build_graph_node_prompt(self, extraction_guide: ExtractionGuide) -> str:+ """Build Graph type node extraction Prompt (two-stage mode)."""+ parts = []++ target = self.build_target(extraction_guide)+ if target:+ parts.append(target)++ rules_for_nodes = self.build_rules_for_nodes(extraction_guide)+ if rules_for_nodes:+ parts.append(rules_for_nodes)++ source_label = self.labels.get("source_text", "源文本")+ parts.append(f"## {source_label}:\n{{source_text}}")++ return "\n\n".join(parts)++ def build_graph_edge_prompt(self, extraction_guide: ExtractionGuide) -> str:+ """Build Graph type edge extraction Prompt (two-stage mode)."""+ parts = []++ target = self.build_target(extraction_guide)+ if target:+ parts.append(target)++ rules_for_edges = self.build_rules_for_edges(extraction_guide)+ if rules_for_edges:+ parts.append(rules_for_edges)++ known_label = self.labels.get("known_entities", "已知实体")+ parts.append(f"## {known_label}:\n{{known_nodes}}")++ source_label = self.labels.get("source_text", "源文本")+ parts.append(f"## {source_label}:\n{{source_text}}")++ return "\n\n".join(parts)++ def build_temporal_graph_node_prompt(self, extraction_guide: ExtractionGuide) -> str:+ """Build TemporalGraph node extraction Prompt."""+ parts = []++ target = self.build_target(extraction_guide)+ if target:+ parts.append(target)++ rules_for_nodes = self.build_rules_for_nodes(extraction_guide)+ if rules_for_nodes:+ parts.append(rules_for_nodes)++ rules_for_time = self.build_rules_for_time(extraction_guide)+ if rules_for_time:+ parts.append(rules_for_time)++ source_label = self.labels.get("source_text", "源文本")+ parts.append(f"## {source_label}:\n{{source_text}}")++ return "\n\n".join(parts)++ def build_spatial_graph_node_prompt(self, extraction_guide: ExtractionGuide) -> str:+ """Build SpatialGraph node extraction Prompt."""+ parts = []++ target = self.build_target(extraction_guide)+ if target:+ parts.append(target)++ rules_for_nodes = self.build_rules_for_nodes(extraction_guide)+ if rules_for_nodes:+ parts.append(rules_for_nodes)++ rules_for_location = self.build_rules_for_location(extraction_guide)+ if rules_for_location:+ parts.append(rules_for_location)++ source_label = self.labels.get("source_text", "源文本")+ parts.append(f"## {source_label}:\n{{source_text}}")++ return "\n\n".join(parts)++ def build_spatio_temporal_graph_node_prompt(self, extraction_guide: ExtractionGuide) -> str:+ """Build SpatioTemporalGraph node extraction Prompt."""+ parts = []++ target = self.build_target(extraction_guide)+ if target:+ parts.append(target)++ rules_for_nodes = self.build_rules_for_nodes(extraction_guide)+ if rules_for_nodes:+ parts.append(rules_for_nodes)++ rules_for_time = self.build_rules_for_time(extraction_guide)+ if rules_for_time:+ parts.append(rules_for_time)++ rules_for_location = self.build_rules_for_location(extraction_guide)+ if rules_for_location:+ parts.append(rules_for_location)++ source_label = self.labels.get("source_text", "源文本")+ parts.append(f"## {source_label}:\n{{source_text}}")++ return "\n\n".join(parts)diff --git a/hyperextract/utils/template_engine/schema_builder.py b/hyperextract/utils/template_engine/schema_builder.pynew file mode 100644index 0000000..4df0ec7--- /dev/null+++ b/hyperextract/utils/template_engine/schema_builder.py@@ -0,0 +1,128 @@+"""Schema Builder - Dynamically generates Pydantic Schema.++Converts Schema definitions in configuration files to Pydantic models.+"""++from typing import Any, Dict, List, Optional, Type, Union, get_type_hints+from pydantic import BaseModel, Field, create_model+from pydantic.fields import FieldInfo++from .config_loader import (+ SchemaField,+ ModelSchema,+ ItemSchema,+ NodeSchema,+ EdgeSchema,+)+++TYPE_MAPPING = {+ "string": str,+ "int": int,+ "float": float,+ "bool": bool,+ "array": List,+}+++class SchemaBuilder:+ """Schema Builder."""++ @staticmethod+ def build_field_type(field: SchemaField) -> Type:+ """Build field type."""+ if field.type == "array":+ if field.item_type:+ item_type = TYPE_MAPPING.get(field.item_type, str)+ return List[item_type]+ return List+ return TYPE_MAPPING.get(field.type, str)++ @staticmethod+ def build_field_default(field: SchemaField) -> Any:+ """Build field default value."""+ if field.required:+ return ...+ if field.default is not None:+ return field.default+ if field.type == "array":+ return []+ return None++ @staticmethod+ def build_field_description(field: SchemaField) -> str:+ """Build field description."""+ if field.description is None:+ return ""+ if isinstance(field.description, str):+ return field.description+ if isinstance(field.description, dict):+ return field.description.get("zh") or field.description.get("en") or ""+ return str(field.description)++ @classmethod+ def build_model_schema(cls, schema: ModelSchema) -> Type[BaseModel]:+ """Build Model type Schema."""+ fields = {}+ for field in schema.fields:+ field_type = cls.build_field_type(field)+ default = cls.build_field_default(field)+ description = cls.build_field_description(field)+ fields[field.name] = (field_type, Field(default=default, description=description))++ return create_model("GeneratedModelSchema", **fields)++ @classmethod+ def build_item_schema(cls, schema: ItemSchema) -> Type[BaseModel]:+ """Build List/Set type Item Schema."""+ fields = {}+ for field in schema.fields:+ field_type = cls.build_field_type(field)+ default = cls.build_field_default(field)+ description = cls.build_field_description(field)+ fields[field.name] = (field_type, Field(default=default, description=description))++ return create_model("GeneratedItemSchema", **fields)++ @classmethod+ def build_node_schema(cls, schema: NodeSchema) -> Type[BaseModel]:+ """Build Graph type Node Schema."""+ fields = {}+ for field in schema.fields:+ field_type = cls.build_field_type(field)+ default = cls.build_field_default(field)+ description = cls.build_field_description(field)+ fields[field.name] = (field_type, Field(default=default, description=description))++ return create_model("GeneratedNodeSchema", **fields)++ @classmethod+ def build_edge_schema(cls, schema: EdgeSchema) -> Type[BaseModel]:+ """Build Graph type Edge Schema."""+ fields = {}+ for field in schema.fields:+ field_type = cls.build_field_type(field)+ default = cls.build_field_default(field)+ description = cls.build_field_description(field)+ fields[field.name] = (field_type, Field(default=default, description=description))++ return create_model("GeneratedEdgeSchema", **fields)++ @classmethod+ def build_schema(cls, config) -> Dict[str, Type[BaseModel]]:+ """Build corresponding Schema based on configuration."""+ result = {}++ if config.model_schema is not None:+ result["schema"] = cls.build_model_schema(config.model_schema)++ if config.item_schema is not None:+ result["item_schema"] = cls.build_item_schema(config.item_schema)++ if config.node_schema is not None:+ result["node_schema"] = cls.build_node_schema(config.node_schema)++ if config.edge_schema is not None:+ result["edge_schema"] = cls.build_edge_schema(config.edge_schema)++ return resultdiff --git a/hyperextract/utils/template_engine/template_factory.py b/hyperextract/utils/template_engine/template_factory.pynew file mode 100644index 0000000..e121daf--- /dev/null+++ b/hyperextract/utils/template_engine/template_factory.py@@ -0,0 +1,626 @@+"""Template Factory - Dynamically creates template instances from configuration.++Supports all 8 AutoType dynamic generation.+"""++from typing import Any, Callable, Dict, List, Optional, Type, Union+from pathlib import Path++from ontomem.merger import MergeStrategy, create_merger, BaseMerger+from langchain_core.language_models import BaseChatModel+from langchain_core.embeddings import Embeddings++from hyperextract.types import (+ AutoModel,+ AutoList,+ AutoSet,+ AutoGraph,+ AutoHypergraph,+ AutoTemporalGraph,+ AutoSpatialGraph,+ AutoSpatioTemporalGraph,+)++from .config_loader import TemplateConfig, Parameters+from .schema_builder import SchemaBuilder+from .identifier_resolver import IdentifierResolver+from .prompt_builder import PromptBuilder+++class TemplateFactory:++ @staticmethod+ def get_language(config: TemplateConfig) -> str:+ """Get language setting."""+ lang = config.language+ if isinstance(lang, list):+ return lang[0] if lang else "zh"+ return lang or "zh"++ @staticmethod+ def resolve_display_extractors(config: TemplateConfig, schema_dict: dict):+ """Generate label_extractor function based on display configuration."""+ display = config.display+ if not display:+ return {}++ result = {}+ autotype = config.autotype+ display_dict = display.model_dump() if hasattr(display, 'model_dump') else display++ if autotype in ("model", "list", "set"):+ label_field = display_dict.get("label")+ if label_field:+ result["label_extractor"] = lambda x: str(getattr(x, label_field, ""))++ elif autotype in ("graph", "hypergraph", "temporal_graph", "spatial_graph", "spatio_temporal_graph"):+ node_label_field = display_dict.get("node_label")+ if node_label_field:+ result["node_label_extractor"] = lambda x: str(getattr(x, node_label_field, ""))++ edge_label_field = display_dict.get("edge_label")+ if edge_label_field:+ result["edge_label_extractor"] = lambda x: str(getattr(x, edge_label_field, ""))++ return result++ @staticmethod+ def resolve_merge_strategy(+ strategy_name: Optional[str],+ custom_rule: Optional[str],+ key_extractor: Callable,+ llm_client: BaseChatModel,+ item_schema: Type,+ ) -> Union[MergeStrategy, BaseMerger]:+ """Resolve merge strategy."""+ if custom_rule:+ return MergeStrategy.LLM.BALANCED+ if strategy_name:+ strategy_name = strategy_name.lower()+ if '.' in strategy_name:+ parts = strategy_name.split('.')+ return getattr(getattr(MergeStrategy, parts[0].upper()), parts[1].upper())+ else:+ try:+ return MergeStrategy[strategy_name.upper()]+ except KeyError:+ return MergeStrategy.LLM.BALANCED+ return MergeStrategy.LLM.BALANCED++ @classmethod+ def create_model(cls, config: TemplateConfig, llm_client: BaseChatModel, embedder: Embeddings) -> AutoModel:+ """Create AutoModel template."""+ language = cls.get_language(config)++ schema_dict = SchemaBuilder.build_schema(config)+ schema_class = schema_dict.get("schema")++ if schema_class is None:+ raise ValueError(f"AutoModel requires schema definition: {config.name}")++ extraction_guide = config.extraction_guide+ prompt_builder = PromptBuilder(language)+ prompt = prompt_builder.build_model_prompt(extraction_guide)++ parameters = config.parameters or Parameters()+ merge_strategy = parameters.merge_strategy or "llm_balanced"+ custom_merge_rule = parameters.get_custom_merge_rule(language)++ return AutoModel(+ data_schema=schema_class,+ llm_client=llm_client,+ embedder=embedder,+ strategy_or_merger=cls.resolve_merge_strategy(+ merge_strategy,+ custom_merge_rule,+ lambda x: str(x),+ llm_client,+ schema_class,+ ),+ prompt=prompt,+ chunk_size=parameters.chunk_size,+ chunk_overlap=parameters.chunk_overlap,+ max_workers=parameters.max_workers,+ verbose=parameters.verbose,+ )++ @classmethod+ def create_list(cls, config: TemplateConfig, llm_client: BaseChatModel, embedder: Embeddings) -> AutoList:+ """Create AutoList template."""+ language = cls.get_language(config)++ schema_dict = SchemaBuilder.build_schema(config)+ item_schema_class = schema_dict.get("item_schema")++ if item_schema_class is None:+ raise ValueError(f"AutoList requires item_schema definition: {config.name}")++ extraction_guide = config.extraction_guide+ prompt_builder = PromptBuilder(language)+ prompt = prompt_builder.build_model_prompt(extraction_guide)++ parameters = config.parameters or Parameters()++ return AutoList(+ item_schema=item_schema_class,+ llm_client=llm_client,+ embedder=embedder,+ prompt=prompt,+ chunk_size=parameters.chunk_size,+ chunk_overlap=parameters.chunk_overlap,+ max_workers=parameters.max_workers,+ verbose=parameters.verbose,+ )++ @classmethod+ def create_set(cls, config: TemplateConfig, llm_client: BaseChatModel, embedder: Embeddings) -> AutoSet:+ """Create AutoSet template."""+ language = cls.get_language(config)++ schema_dict = SchemaBuilder.build_schema(config)+ item_schema_class = schema_dict.get("item_schema")++ if item_schema_class is None:+ raise ValueError(f"AutoSet requires item_schema definition: {config.name}")++ identifiers = IdentifierResolver.resolve_all(config)+ item_id_extractor = identifiers.get("item_id_extractor")++ if item_id_extractor is None:+ raise ValueError(f"AutoSet requires item_id configuration: {config.name}")++ extraction_guide = config.extraction_guide+ prompt_builder = PromptBuilder(language)+ prompt = prompt_builder.build_model_prompt(extraction_guide)++ parameters = config.parameters or Parameters()+ merge_strategy = parameters.merge_strategy or "llm_balanced"+ custom_merge_rule = parameters.get_custom_merge_rule(language)++ return AutoSet(+ item_schema=item_schema_class,+ item_key_extractor=item_id_extractor,+ llm_client=llm_client,+ embedder=embedder,+ strategy_or_merger=cls.resolve_merge_strategy(+ merge_strategy,+ custom_merge_rule,+ item_id_extractor,+ llm_client,+ item_schema_class,+ ),+ prompt=prompt,+ chunk_size=parameters.chunk_size,+ chunk_overlap=parameters.chunk_overlap,+ max_workers=parameters.max_workers,+ verbose=parameters.verbose,+ )++ @classmethod+ def create_graph(cls, config: TemplateConfig, llm_client: BaseChatModel, embedder: Embeddings) -> AutoGraph:+ """Create AutoGraph template."""+ language = cls.get_language(config)++ schema_dict = SchemaBuilder.build_schema(config)+ node_schema_class = schema_dict.get("node_schema")+ edge_schema_class = schema_dict.get("edge_schema")++ if node_schema_class is None or edge_schema_class is None:+ raise ValueError(f"AutoGraph requires node_schema and edge_schema definition: {config.name}")++ identifiers = IdentifierResolver.resolve_all(config)+ node_key_extractor = identifiers.get("node_key_extractor")+ edge_key_extractor = identifiers.get("edge_key_extractor")+ nodes_in_edge_extractor = identifiers.get("nodes_in_edge_extractor")++ if not all([node_key_extractor, edge_key_extractor, nodes_in_edge_extractor]):+ raise ValueError(f"AutoGraph requires complete identifiers configuration: {config.name}")++ extraction_guide = config.extraction_guide+ prompt_builder = PromptBuilder(language)++ extraction_mode = config.parameters.extraction_mode if config.parameters else "two_stage"++ if extraction_mode == "one_stage":+ prompt = prompt_builder.build_graph_main_prompt(extraction_guide)+ prompt_for_node_extraction = ""+ prompt_for_edge_extraction = ""+ else:+ prompt = ""+ prompt_for_node_extraction = prompt_builder.build_graph_node_prompt(extraction_guide)+ prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(extraction_guide)++ parameters = config.parameters or Parameters()++ node_merge_strategy = parameters.node_merge_strategy or "llm_balanced"+ node_custom_merge_rule = parameters.node_custom_merge_rule+ edge_merge_strategy = parameters.edge_merge_strategy or "llm_balanced"+ edge_custom_merge_rule = parameters.edge_custom_merge_rule++ return AutoGraph(+ node_schema=node_schema_class,+ edge_schema=edge_schema_class,+ node_key_extractor=node_key_extractor,+ edge_key_extractor=edge_key_extractor,+ nodes_in_edge_extractor=nodes_in_edge_extractor,+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ node_strategy_or_merger=cls.resolve_merge_strategy(+ node_merge_strategy,+ node_custom_merge_rule,+ node_key_extractor,+ llm_client,+ node_schema_class,+ ),+ edge_strategy_or_merger=cls.resolve_merge_strategy(+ edge_merge_strategy,+ edge_custom_merge_rule,+ edge_key_extractor,+ llm_client,+ edge_schema_class,+ ),+ prompt=prompt,+ prompt_for_node_extraction=prompt_for_node_extraction,+ prompt_for_edge_extraction=prompt_for_edge_extraction,+ chunk_size=parameters.chunk_size,+ chunk_overlap=parameters.chunk_overlap,+ max_workers=parameters.max_workers,+ verbose=parameters.verbose,+ node_fields_for_index=parameters.node_search_fields,+ edge_fields_for_index=parameters.edge_search_fields,+ )++ @classmethod+ def create_hypergraph(cls, config: TemplateConfig, llm_client: BaseChatModel, embedder: Embeddings) -> AutoHypergraph:+ """Create AutoHypergraph template."""+ return cls.create_graph(config, llm_client, embedder)++ @classmethod+ def create_temporal_graph(cls, config: TemplateConfig, llm_client: BaseChatModel, embedder: Embeddings) -> AutoTemporalGraph:+ """Create AutoTemporalGraph template."""+ language = cls.get_language(config)++ schema_dict = SchemaBuilder.build_schema(config)+ node_schema_class = schema_dict.get("node_schema")+ edge_schema_class = schema_dict.get("edge_schema")++ if node_schema_class is None or edge_schema_class is None:+ raise ValueError(f"AutoTemporalGraph requires node_schema and edge_schema definition: {config.name}")++ identifiers = IdentifierResolver.resolve_all(config)+ node_key_extractor = identifiers.get("node_key_extractor")+ edge_key_extractor = identifiers.get("edge_key_extractor")+ nodes_in_edge_extractor = identifiers.get("nodes_in_edge_extractor")+ time_in_edge_extractor = identifiers.get("time_in_edge_extractor")++ if not all([node_key_extractor, edge_key_extractor, nodes_in_edge_extractor]):+ raise ValueError(f"AutoTemporalGraph requires complete identifiers configuration: {config.name}")++ extraction_guide = config.extraction_guide+ prompt_builder = PromptBuilder(language)++ extraction_mode = config.parameters.extraction_mode if config.parameters else "two_stage"++ if extraction_mode == "one_stage":+ prompt = prompt_builder.build_graph_main_prompt(extraction_guide)+ prompt_for_node_extraction = ""+ prompt_for_edge_extraction = ""+ else:+ prompt = ""+ prompt_for_node_extraction = prompt_builder.build_temporal_graph_node_prompt(extraction_guide)+ prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(extraction_guide)++ parameters = config.parameters or Parameters()++ node_merge_strategy = parameters.node_merge_strategy or "llm_balanced"+ node_custom_merge_rule = parameters.node_custom_merge_rule+ edge_merge_strategy = parameters.edge_merge_strategy or "llm_balanced"+ edge_custom_merge_rule = parameters.edge_custom_merge_rule++ return AutoTemporalGraph(+ node_schema=node_schema_class,+ edge_schema=edge_schema_class,+ node_key_extractor=node_key_extractor,+ edge_key_extractor=edge_key_extractor,+ nodes_in_edge_extractor=nodes_in_edge_extractor,+ time_in_edge_extractor=time_in_edge_extractor,+ observation_time=parameters.observation_time,+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ node_strategy_or_merger=cls.resolve_merge_strategy(+ node_merge_strategy,+ node_custom_merge_rule,+ node_key_extractor,+ llm_client,+ node_schema_class,+ ),+ edge_strategy_or_merger=cls.resolve_merge_strategy(+ edge_merge_strategy,+ edge_custom_merge_rule,+ edge_key_extractor,+ llm_client,+ edge_schema_class,+ ),+ prompt=prompt,+ prompt_for_node_extraction=prompt_for_node_extraction,+ prompt_for_edge_extraction=prompt_for_edge_extraction,+ chunk_size=parameters.chunk_size,+ chunk_overlap=parameters.chunk_overlap,+ max_workers=parameters.max_workers,+ verbose=parameters.verbose,+ node_fields_for_index=parameters.node_search_fields,+ edge_fields_for_index=parameters.edge_search_fields,+ )++ @classmethod+ def create_spatial_graph(cls, config: TemplateConfig, llm_client: BaseChatModel, embedder: Embeddings) -> AutoSpatialGraph:+ """Create AutoSpatialGraph template."""+ language = cls.get_language(config)++ schema_dict = SchemaBuilder.build_schema(config)+ node_schema_class = schema_dict.get("node_schema")+ edge_schema_class = schema_dict.get("edge_schema")++ if node_schema_class is None or edge_schema_class is None:+ raise ValueError(f"AutoSpatialGraph requires node_schema and edge_schema definition: {config.name}")++ identifiers = IdentifierResolver.resolve_all(config)+ node_key_extractor = identifiers.get("node_key_extractor")+ edge_key_extractor = identifiers.get("edge_key_extractor")+ nodes_in_edge_extractor = identifiers.get("nodes_in_edge_extractor")+ location_extractor = identifiers.get("location_extractor")++ if not all([node_key_extractor, edge_key_extractor, nodes_in_edge_extractor]):+ raise ValueError(f"AutoSpatialGraph requires complete identifiers configuration: {config.name}")++ extraction_guide = config.extraction_guide+ prompt_builder = PromptBuilder(language)++ extraction_mode = config.parameters.extraction_mode if config.parameters else "two_stage"++ if extraction_mode == "one_stage":+ prompt = prompt_builder.build_graph_main_prompt(extraction_guide)+ prompt_for_node_extraction = ""+ prompt_for_edge_extraction = ""+ else:+ prompt = ""+ prompt_for_node_extraction = prompt_builder.build_spatial_graph_node_prompt(extraction_guide)+ prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(extraction_guide)++ parameters = config.parameters or Parameters()++ node_merge_strategy = parameters.node_merge_strategy or "llm_balanced"+ node_custom_merge_rule = parameters.node_custom_merge_rule+ edge_merge_strategy = parameters.edge_merge_strategy or "llm_balanced"+ edge_custom_merge_rule = parameters.edge_custom_merge_rule++ return AutoSpatialGraph(+ node_schema=node_schema_class,+ edge_schema=edge_schema_class,+ node_key_extractor=node_key_extractor,+ edge_key_extractor=edge_key_extractor,+ nodes_in_edge_extractor=nodes_in_edge_extractor,+ location_extractor=location_extractor,+ observation_location=parameters.observation_location,+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ node_strategy_or_merger=cls.resolve_merge_strategy(+ node_merge_strategy,+ node_custom_merge_rule,+ node_key_extractor,+ llm_client,+ node_schema_class,+ ),+ edge_strategy_or_merger=cls.resolve_merge_strategy(+ edge_merge_strategy,+ edge_custom_merge_rule,+ edge_key_extractor,+ llm_client,+ edge_schema_class,+ ),+ prompt=prompt,+ prompt_for_node_extraction=prompt_for_node_extraction,+ prompt_for_edge_extraction=prompt_for_edge_extraction,+ chunk_size=parameters.chunk_size,+ chunk_overlap=parameters.chunk_overlap,+ max_workers=parameters.max_workers,+ verbose=parameters.verbose,+ node_fields_for_index=parameters.node_search_fields,+ edge_fields_for_index=parameters.edge_search_fields,+ )++ @classmethod+ def create_spatio_temporal_graph(cls, config: TemplateConfig, llm_client: BaseChatModel, embedder: Embeddings) -> AutoSpatioTemporalGraph:+ """Create AutoSpatioTemporalGraph template."""+ language = cls.get_language(config)++ schema_dict = SchemaBuilder.build_schema(config)+ node_schema_class = schema_dict.get("node_schema")+ edge_schema_class = schema_dict.get("edge_schema")++ if node_schema_class is None or edge_schema_class is None:+ raise ValueError(f"AutoSpatioTemporalGraph requires node_schema and edge_schema definition: {config.name}")++ identifiers = IdentifierResolver.resolve_all(config)+ node_key_extractor = identifiers.get("node_key_extractor")+ edge_key_extractor = identifiers.get("edge_key_extractor")+ nodes_in_edge_extractor = identifiers.get("nodes_in_edge_extractor")+ time_extractor = identifiers.get("time_extractor")+ location_extractor = identifiers.get("location_extractor")++ if not all([node_key_extractor, edge_key_extractor, nodes_in_edge_extractor]):+ raise ValueError(f"AutoSpatioTemporalGraph requires complete identifiers configuration: {config.name}")++ extraction_guide = config.extraction_guide+ prompt_builder = PromptBuilder(language)++ extraction_mode = config.parameters.extraction_mode if config.parameters else "two_stage"++ if extraction_mode == "one_stage":+ prompt = prompt_builder.build_graph_main_prompt(extraction_guide)+ prompt_for_node_extraction = ""+ prompt_for_edge_extraction = ""+ else:+ prompt = ""+ prompt_for_node_extraction = prompt_builder.build_spatio_temporal_graph_node_prompt(extraction_guide)+ prompt_for_edge_extraction = prompt_builder.build_graph_edge_prompt(extraction_guide)++ parameters = config.parameters or Parameters()++ node_merge_strategy = parameters.node_merge_strategy or "llm_balanced"+ node_custom_merge_rule = parameters.node_custom_merge_rule+ edge_merge_strategy = parameters.edge_merge_strategy or "llm_balanced"+ edge_custom_merge_rule = parameters.edge_custom_merge_rule++ return AutoSpatioTemporalGraph(+ node_schema=node_schema_class,+ edge_schema=edge_schema_class,+ node_key_extractor=node_key_extractor,+ edge_key_extractor=edge_key_extractor,+ nodes_in_edge_extractor=nodes_in_edge_extractor,+ time_extractor=time_extractor,+ location_extractor=location_extractor,+ observation_time=parameters.observation_time,+ observation_location=parameters.observation_location,+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ node_strategy_or_merger=cls.resolve_merge_strategy(+ node_merge_strategy,+ node_custom_merge_rule,+ node_key_extractor,+ llm_client,+ node_schema_class,+ ),+ edge_strategy_or_merger=cls.resolve_merge_strategy(+ edge_merge_strategy,+ edge_custom_merge_rule,+ edge_key_extractor,+ llm_client,+ edge_schema_class,+ ),+ prompt=prompt,+ prompt_for_node_extraction=prompt_for_node_extraction,+ prompt_for_edge_extraction=prompt_for_edge_extraction,+ chunk_size=parameters.chunk_size,+ chunk_overlap=parameters.chunk_overlap,+ max_workers=parameters.max_workers,+ verbose=parameters.verbose,+ node_fields_for_index=parameters.node_search_fields,+ edge_fields_for_index=parameters.edge_search_fields,+ )++ @classmethod+ def create(+ cls,+ config: TemplateConfig,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ **kwargs+ ):+ """Create template instance based on configuration.++ Args:+ config: Template configuration+ llm_client: LLM client+ embedder: Embedding model+ **kwargs: Additional parameters to override config parameters+ e.g., observation_time="2024-06-15", observation_location="Beijing"++ Returns:+ TemplateWrapper: Wrapped template instance++ Examples:+ # Basic usage+ template = TemplateFactory.create(config, llm, embedder)++ # For spatio-temporal templates, pass observation_time etc.+ template = TemplateFactory.create(+ config,+ llm,+ embedder,+ observation_time="2024-06-15",+ observation_location="Beijing"+ )++ # Can also override other parameters+ template = TemplateFactory.create(+ config,+ llm,+ embedder,+ chunk_size=4096,+ max_workers=20+ )+ """+ # Merge parameters: user-provided kwargs have highest priority+ if kwargs:+ from .config_loader import Parameters+ base_params = config.parameters or Parameters()+ params_dict = base_params.model_dump()+ params_dict.update(kwargs)+ config.parameters = Parameters(**params_dict)++ autotype_map = {+ "model": cls.create_model,+ "list": cls.create_list,+ "set": cls.create_set,+ "graph": cls.create_graph,+ "hypergraph": cls.create_hypergraph,+ "temporal_graph": cls.create_temporal_graph,+ "spatial_graph": cls.create_spatial_graph,+ "spatio_temporal_graph": cls.create_spatio_temporal_graph,+ }++ creator = autotype_map.get(config.autotype)+ if creator is None:+ raise ValueError(f"Unsupported autotype: {config.autotype}")++ template = creator(config, llm_client, embedder)+ display_extractors = cls.resolve_display_extractors(config, {})++ return TemplateWrapper(template, display_extractors, config.autotype)+++def safe_getattr(obj, name, default):+ """Safely get attribute."""+ try:+ return getattr(obj, name)+ except AttributeError:+ return default+++class TemplateWrapper:+ """Template wrapper - automatically handles label_extractor parameters."""++ def __init__(self, template, display_extractors: dict, autotype: str = None):+ self._template = template+ self._display_extractors = display_extractors+ self._autotype = autotype++ self._node_label_extractor = display_extractors.get("node_label_extractor")+ self._edge_label_extractor = display_extractors.get("edge_label_extractor")+ self._label_extractor = display_extractors.get("label_extractor")++ def __getattr__(self, name):+ return getattr(self._template, name)++ def show(self, **kwargs):+ """Automatically pass label_extractor parameters."""+ if self._autotype in ("graph", "hypergraph", "temporal_graph", "spatial_graph", "spatio_temporal_graph"):+ if self._node_label_extractor and self._edge_label_extractor:+ kwargs.setdefault("node_label_extractor", self._node_label_extractor)+ kwargs.setdefault("edge_label_extractor", self._edge_label_extractor)+ else:+ if self._label_extractor:+ kwargs.setdefault("label_extractor", self._label_extractor)++ return self._template.show(**kwargs)++ def search(self, **kwargs):+ return self._template.search(**kwargs)++ def chat(self, **kwargs):+ return self._template.chat(**kwargs)diff --git a/hyperextract/utils/template_engine/template_gallery.py b/hyperextract/utils/template_engine/template_gallery.pynew file mode 100644index 0000000..2e6181a--- /dev/null+++ b/hyperextract/utils/template_engine/template_gallery.py@@ -0,0 +1,210 @@+"""Template Gallery - Manages discovery and loading of knowledge extraction templates.++Supports auto-loading presets and customs directories.+"""++import os+from pathlib import Path+from typing import Dict, List, Optional++from .config_loader import TemplateConfig, ConfigLoader+++class Gallery:+ """Template Gallery.++ Usage Examples:+ from hyperextract.utils.template_engine import Gallery++ # Get template (auto-loaded)+ config = Gallery.get("KnowledgeGraph")++ # List all templates+ print(Gallery.list_all())++ # Add custom template directory (auto-loaded)+ Gallery.add_path("/path/to/my/templates")++ # Add single YAML file+ Gallery.add("/path/to/my_template.yaml")+ """++ _instance: Optional["Gallery"] = None++ def __init__(self):+ self._configs: Dict[str, TemplateConfig] = {}+ self._configs_by_autotype: Dict[str, List[str]] = {}+ self._configs_by_tag: Dict[str, List[str]] = {}++ @classmethod+ def get(cls, name: str) -> Optional[TemplateConfig]:+ return cls._instance._configs.get(name) if cls._instance else None++ @classmethod+ def list_all(cls) -> List[str]:+ return list(cls._instance._configs.keys()) if cls._instance else []++ @classmethod+ def add_path(cls, path: str) -> None:+ if not cls._instance:+ return+ dir_path = Path(path)+ if not dir_path.exists() or not dir_path.is_dir():+ return+ for root, _, files in os.walk(dir_path):+ for file in files:+ if file.endswith((".yaml", ".yml")):+ cls._instance._load_config(Path(root) / file)++ @classmethod+ def add(cls, file_path: str) -> None:+ if not cls._instance:+ return+ path = Path(file_path)+ if path.exists() and path.is_file() and path.suffix in (".yaml", ".yml"):+ cls._instance._load_config(path)++ @classmethod+ def get_by_autotype(cls, autotype: str) -> List[TemplateConfig]:+ if not cls._instance:+ return []+ names = cls._instance._configs_by_autotype.get(autotype, [])+ return [cls._instance._configs[name] for name in names if name in cls._instance._configs]++ @classmethod+ def get_by_tag(cls, tag: str) -> List[TemplateConfig]:+ if not cls._instance:+ return []+ names = cls._instance._configs_by_tag.get(tag, [])+ return [cls._instance._configs[name] for name in names if name in cls._instance._configs]++ @classmethod+ def search(cls, query: str = None, autotype: str = None, tag: str = None, language: str = None) -> List[TemplateConfig]:+ """Search templates by query, autotype, tag, or language.++ Args:+ query: Search in template name/description+ autotype: Filter by autotype (e.g., "graph", "list")+ tag: Filter by tag+ language: Filter by language (e.g., "zh", "en")++ Returns:+ List of matching TemplateConfig+ """+ if not cls._instance:+ return []++ results = []++ for config in cls._instance._configs.values():+ if query:+ query_lower = query.lower()+ name_match = config.name.lower()+ desc_match = getattr(config, 'description', None)+ desc_value = desc_match.zh if hasattr(desc_match, 'zh') else desc_match+ if query_lower not in name_match and (desc_value and query_lower not in str(desc_value).lower()):+ continue++ if autotype and config.autotype != autotype:+ continue++ if tag and (not config.tag or tag not in config.tag):+ continue++ if language:+ config_lang = config.language+ if isinstance(config_lang, list):+ if language not in config_lang:+ continue+ elif config_lang != language:+ continue++ results.append(config)++ return results++ @classmethod+ def list_languages(cls) -> List[str]:+ """List all available languages."""+ if not cls._instance:+ return []+ languages = set()+ for config in cls._instance._configs.values():+ lang = config.language+ if isinstance(lang, list):+ languages.update(lang)+ elif lang:+ languages.add(lang)+ return sorted(languages)++ @classmethod+ def list_autotypes(cls) -> List[str]:+ """List all available autotypes."""+ if not cls._instance:+ return []+ return list(cls._instance._configs_by_autotype.keys())++ @classmethod+ def list_tags(cls) -> List[str]:+ """List all available tags."""+ if not cls._instance:+ return []+ return list(cls._instance._configs_by_tag.keys())++ @classmethod+ def list_domains(cls) -> List[tuple]:+ """List all available domains with template count.++ Returns:+ List of (domain_name, template_count) tuples+ """+ base_dir = Path(__file__).parent.parent.parent / "templates" / "presets"+ domains = []+ if base_dir.exists():+ for item in base_dir.iterdir():+ if item.is_dir() and not item.name.startswith('_'):+ count = len(list(item.glob("*.yaml")))+ domains.append((item.name, count))+ return domains++ def _load_config(self, file_path: Path) -> None:+ try:+ config = ConfigLoader.load_config(file_path)+ self._register(config)+ except Exception as e:+ print(f"Failed to load config {file_path}: {e}")++ def _register(self, config: TemplateConfig) -> None:+ self._configs[config.name] = config++ if config.autotype not in self._configs_by_autotype:+ self._configs_by_autotype[config.autotype] = []+ if config.name not in self._configs_by_autotype[config.autotype]:+ self._configs_by_autotype[config.autotype].append(config.name)++ if config.tag:+ for tag in config.tag:+ if tag not in self._configs_by_tag:+ self._configs_by_tag[tag] = []+ if config.name not in self._configs_by_tag[tag]:+ self._configs_by_tag[tag].append(config.name)+++def _init_gallery() -> Gallery:+ gallery = Gallery()+ Gallery._instance = gallery++ base_dir = Path(__file__).parent.parent.parent / "templates"+ presets_dir = base_dir / "presets"+ customs_dir = base_dir / "customs"++ if presets_dir.exists():+ Gallery.add_path(str(presets_dir))++ if customs_dir.exists():+ Gallery.add_path(str(customs_dir))++ return gallery+++Gallery._instance = _init_gallery()diff --git a/tests/types/test_graph.py b/tests/types/test_graph.pyindex 19ed957..63aa5f3 100644--- a/tests/types/test_graph.py+++ b/tests/types/test_graph.py@@ -135,7 +135,7 @@ class TestAutoGraphExtraction:embedder=embedder,)- kg2 = kg1.extract("""CEO Sarah leads Engineering where Bob manages Backend Systems.+ kg2 = kg1.parse("""CEO Sarah leads Engineering where Bob manages Backend Systems.Bob oversees both Database Architecture (led by Alice) and API Development (led by Tom).Alice collaborates with Tom on performance optimization.""")diff --git a/tests/types/test_hypergraph.py b/tests/types/test_hypergraph.pyindex a71cd90..bc8e795 100644--- a/tests/types/test_hypergraph.py+++ b/tests/types/test_hypergraph.py@@ -142,7 +142,7 @@ class TestAutoHypergraphExtraction:embedder=embedder,)- hg2 = hg1.extract("""Annual planning conference brings together CEO, CFO, CTO,+ hg2 = hg1.parse("""Annual planning conference brings together CEO, CFO, CTO,VP Marketing, and VP Sales to discuss Q2 revenue targets and product roadmap priorities.""")assert hg1 is not hg2diff --git a/tests/types/test_model.py b/tests/types/test_model.pyindex 6786bca..9246b16 100644--- a/tests/types/test_model.py+++ b/tests/types/test_model.py@@ -66,7 +66,7 @@ class TestAutoModelExtraction:def test_extract_creates_new_instance(self, llm_client, embedder):"""Test that extract() returns a new instance."""model1 = AutoModel(Person, llm_client, embedder)- model2 = model1.extract("""Dr. James Wilson, 47 years old, served as Chief Technology Officer+ model2 = model1.parse("""Dr. James Wilson, 47 years old, served as Chief Technology Officerat Innovate Systems for 12 years before joining CloudFirst as VP of Engineering.""")# Should be different instancesdiff --git a/tests/types/test_spatial_graph.py b/tests/types/test_spatial_graph.pyindex 8b60736..752b619 100644--- a/tests/types/test_spatial_graph.py+++ b/tests/types/test_spatial_graph.py@@ -167,7 +167,7 @@ class TestAutoSpatialGraphExtraction:embedder=embedder,)- kg2 = kg1.extract("""Company headquarters in San Francisco connects to regional centers:+ kg2 = kg1.parse("""Company headquarters in San Francisco connects to regional centers:New York for East Coast operations, Chicago for Midwest, and Denver for Mountain region.Each regional center manages local office branches.""")diff --git a/tests/types/test_spatio_temporal_graph.py b/tests/types/test_spatio_temporal_graph.pyindex 204506c..641db8e 100644--- a/tests/types/test_spatio_temporal_graph.py+++ b/tests/types/test_spatio_temporal_graph.py@@ -164,7 +164,7 @@ class TestAutoSpatioTemporalGraphExtraction:embedder=embedder,)- kg2 = kg1.extract("""Tech conference tour 2024: January workshop in San Francisco,+ kg2 = kg1.parse("""Tech conference tour 2024: January workshop in San Francisco,March seminar in New York, June training in London, September workshop in Tokyo.Each event has 200+ attendees sharing innovations and networking.""")diff --git a/tests/types/test_temporal_graph.py b/tests/types/test_temporal_graph.pyindex 81d556c..7e1bc93 100644--- a/tests/types/test_temporal_graph.py+++ b/tests/types/test_temporal_graph.py@@ -172,7 +172,7 @@ class TestAutoTemporalGraphExtraction:embedder=embedder,)- kg2 = kg1.extract("""ProjectX timeline: Q1 2023 requirements gathering with stakeholders,+ kg2 = kg1.parse("""ProjectX timeline: Q1 2023 requirements gathering with stakeholders,Q2 2023 architecture design phase, Q3 2023 development sprint cycles,Q4 2023 beta testing and Q1 2024 production launch.""")