Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
feat(industry): 新增工业领域知识图谱模板及测试样例
rizrock81eb874383a1
diff --git a/examples/template_industry_demo.py b/examples/template_industry_demo.pynew file mode 100644index 0000000..9e2892b--- /dev/null+++ b/examples/template_industry_demo.py@@ -0,0 +1,134 @@+"""+Industry 知识模板测试演示++这个文件用于测试 hyperextract 中 industry 领域的所有知识模板。+只需要选择模板,程序会自动匹配对应的输入文件。++使用方法:+1. 选择知识模板(修改 TEMPLATE 变量)+2. 运行文件:python examples/template_industry_demo.py+"""++import os+import sys++# Add project root to path+sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))++from pathlib import Path+from dotenv import load_dotenv++# 导入所有 industry 知识模板+from hyperextract.templates.zh.industry import (+ EquipmentTopologyGraph,+ FailureCaseGraph,+ OperationFlowGraph,+ InspectionRecordGraph,+ EmergencyResponseGraph,+ SafetyControlGraph,+ SystemTopologyGraph,+ OperatingModeGraph,+)++# 导入必要的 LLM 客户端+from langchain_openai import ChatOpenAI, OpenAIEmbeddings+++# ==========================================+# 配置:模板与输入文件自动映射+# ==========================================++# 测试文件根目录+TEST_SAMPLES_ROOT = Path(__file__).parent.parent / "tests" / "fixtures" / "test_samples" / "zh" / "industry"++# 模板到输入文件的映射关系+TEMPLATE_TO_INPUT = {+ EquipmentTopologyGraph: TEST_SAMPLES_ROOT / "equipment_topology.md",+ FailureCaseGraph: TEST_SAMPLES_ROOT / "failure_case.md",+ OperationFlowGraph: TEST_SAMPLES_ROOT / "operation_flow.md",+ InspectionRecordGraph: TEST_SAMPLES_ROOT / "inspection_record.md",+ EmergencyResponseGraph: TEST_SAMPLES_ROOT / "emergency_response.md",+ SafetyControlGraph: TEST_SAMPLES_ROOT / "safety_control.md",+ SystemTopologyGraph: TEST_SAMPLES_ROOT / "system_topology.md",+ OperatingModeGraph: TEST_SAMPLES_ROOT / "operating_mode.md",+}++# ==========================================+# 选择知识模板(只需要修改这一行)+# ==========================================++TEMPLATE = SystemTopologyGraph # 工况切换图谱++# 自动获取对应的输入文件+INPUT_FILE = TEMPLATE_TO_INPUT[TEMPLATE]+++def main():+ """+ 主函数:执行知识提取和展示流程+ """+ print("=" * 60)+ print("Industry 知识模板测试演示")+ print("=" * 60)++ # 加载环境变量+ load_dotenv()++ # 验证输入文件是否存在+ if not INPUT_FILE.exists():+ print(f"❌ 错误:找不到文件 {INPUT_FILE}")+ return++ print(f"\n📄 输入文件: {INPUT_FILE.name}")+ print(f"🎯 使用模板: {TEMPLATE.__name__}")++ # 初始化 LLM 客户端+ 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}")+ print("💡 请确保您已经正确设置了 OPENAI_API_KEY 环境变量")+ return++ # 读取输入文件内容+ print("\n📖 读取文件内容...")+ with open(INPUT_FILE, "r", encoding="utf-8") as f:+ content = f.read()+ print(f"✅ 读取成功,共 {len(content)} 字符")++ # 初始化模板并进行知识提取+ print("\n🧠 开始知识提取...")+ try:+ # 初始化模板+ template = TEMPLATE(+ llm_client=llm,+ embedder=embedder,+ verbose=True,+ )++ # 喂入文本+ 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/hyperextract/templates/en/industry/__init__.py b/hyperextract/templates/en/industry/__init__.pyindex e69de29..9e35ccf 100644--- a/hyperextract/templates/en/industry/__init__.py+++ b/hyperextract/templates/en/industry/__init__.py@@ -0,0 +1,25 @@+"""+Industry domain templates for extracting structured knowledge from industrial equipment documents.++Includes equipment topology, risk transmission, failure case, maintenance procedures and other graph templates.+"""++from .equipment_topology_graph import EquipmentTopologyGraph+from .failure_case_graph import FailureCaseGraph+from .operation_flow_graph import OperationFlowGraph+from .inspection_record_graph import InspectionRecordGraph+from .emergency_response_graph import EmergencyResponseGraph+from .safety_control_graph import SafetyControlGraph+from .system_topology_graph import SystemTopologyGraph+from .operating_mode_graph import OperatingModeGraph++__all__ = [+ "EquipmentTopologyGraph",+ "FailureCaseGraph",+ "OperationFlowGraph",+ "InspectionRecordGraph",+ "EmergencyResponseGraph",+ "SafetyControlGraph",+ "SystemTopologyGraph",+ "OperatingModeGraph",+]diff --git a/hyperextract/templates/en/industry/emergency_response_graph.py b/hyperextract/templates/en/industry/emergency_response_graph.pynew file mode 100644index 0000000..7388829--- /dev/null+++ b/hyperextract/templates/en/industry/emergency_response_graph.py@@ -0,0 +1,180 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema Definition+# ==============================================================================+++class EmergencyEntity(BaseModel):+ """+ Emergency plan entity, including accident scenarios, response actions, departments, etc.+ """++ name: str = Field(description="Entity name (e.g., fire, power outage, alarm, evacuate personnel, equipment department).")+ category: str = Field(+ description='Category: accident scenario, response action, department.'+ )+ description: Optional[str] = Field(+ None,+ description="Description of this entity.",+ )+++class ResponseFlow(BaseModel):+ """+ Emergency response flow relationship.+ """++ source: str = Field(description="Source entity name (accident scenario or response action).")+ target: str = Field(description="Target entity name (response action or department).")+ relation_type: str = Field(+ description='Relation type: triggers, executes, responsible for. Use "triggers" for accident triggering response, "executes" for executing response action, "responsible for" for department responsibility.'+ )+ time_limit: Optional[str] = Field(+ None,+ description="Response time requirement (e.g., within 5 minutes, within 10 minutes).",+ )+ success_criterion: Optional[str] = Field(+ None,+ description="Success criterion (e.g., personnel safely evacuated, fire controlled).",+ )+++# ==============================================================================+# 2. Prompts+# ==============================================================================++_PROMPT = (+ "You are an industrial emergency management analysis expert. Extract accident scenarios, response actions, and departments from emergency plan documents to build emergency response flows.\n\n"+ "Rules:\n"+ "- Identify accident scenarios (e.g., fire, leakage, power outage, equipment failure).\n"+ "- Identify response actions (e.g., alarm, evacuate personnel, shut off power).\n"+ "- Identify responsible departments (e.g., security department, equipment department, first aid department).\n"+ "- Establish flow relationships from accident scenarios to response actions.\n"+ "- Record time requirements and success criteria.\n"+)++_NODE_PROMPT = (+ "You are an industrial emergency management analysis expert. Extract all entities (nodes) from emergency plan documents.\n\n"+ "Extraction Rules:\n"+ "- Identify accident scenario names.\n"+ "- Identify response action names.\n"+ "- Identify responsible department names.\n"+ "- Assign category for each entity (accident scenario/response action/department).\n"+ "- Do not establish relationships between entities.\n"+)++_EDGE_PROMPT = (+ "You are an industrial emergency management analysis expert. Based on the entity list, extract emergency response flow relationships (edges).\n\n"+ "Extraction Rules:\n"+ "- Identify association from accident scenario to response action.\n"+ "- Identify association from response action to responsible department.\n"+ "- Record response time requirements.\n"+ "- Record success criteria.\n"+ "- Only establish relationships within the provided entity list.\n"+)++# ==============================================================================+# 3. Template Class+# ==============================================================================+++class EmergencyResponseGraph(AutoGraph[EmergencyEntity, ResponseFlow]):+ """+ Applicable Documents: Emergency plans, emergency response plans, safety procedures.++ This template extracts accident scenarios, response actions, and departments from emergency plans to build emergency response flows.+ It uses category to distinguish heterogeneous nodes and identifies emergency response flows and responsibility division.++ Example:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> emergency = EmergencyResponseGraph(llm_client=llm, embedder=embedder)+ >>> doc = "When a fire occurs, immediately alarm and activate emergency plan. Security department is responsible for evacuating personnel, equipment department is responsible for shutting off power..."+ >>> emergency.feed_text(doc)+ >>> emergency.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ Initialize Emergency Response Graph template.++ Args:+ llm_client (BaseChatModel): LLM for entity and relationship extraction.+ embedder (Embeddings): Embedding model for deduplication.+ extraction_mode (str): "one_stage" or "two_stage". Default is "two_stage".+ chunk_size (int): Maximum characters per chunk.+ chunk_overlap (int): Overlap between chunks.+ max_workers (int): Number of parallel processing worker threads.+ verbose (bool): Enable progress logging.+ **kwargs: Additional AutoGraph parameters.+ """+ super().__init__(+ node_schema=EmergencyEntity,+ edge_schema=ResponseFlow,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ Visualize emergency response graph using OntoSight.++ Args:+ top_k_nodes_for_search (int): Number of entities to retrieve. Default 3.+ top_k_edges_for_search (int): Number of relationships to retrieve. Default 3.+ top_k_nodes_for_chat (int): Number of entities in chat context. Default 3.+ top_k_edges_for_chat (int): Number of relationships in chat context. Default 3.+ """++ def node_label_extractor(node: EmergencyEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: ResponseFlow) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/en/industry/equipment_topology_graph.py b/hyperextract/templates/en/industry/equipment_topology_graph.pynew file mode 100644index 0000000..ba1957f--- /dev/null+++ b/hyperextract/templates/en/industry/equipment_topology_graph.py@@ -0,0 +1,188 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema Definition+# ==============================================================================+++class IndustrialEquipment(BaseModel):+ """+ Industrial equipment entity, including main equipment, auxiliary equipment, instruments, valves, pipelines, etc.+ """++ name: str = Field(description="Equipment or component name.")+ category: str = Field(+ description='Category: main equipment, auxiliary equipment, component, instrument, valve, pipeline, system, motor, pump, fan, container, etc.'+ )+ location: Optional[str] = Field(+ None,+ description="Installation location (e.g., production workshop floor 1, main building floor 2).",+ )+ status: Optional[str] = Field(+ None,+ description="Operating status: running, standby, maintenance, stopped.",+ )+ specification: Optional[str] = Field(+ None,+ description="Specifications or technical parameters.",+ )+ manufacturer: Optional[str] = Field(+ None,+ description="Manufacturer.",+ )+++class EquipmentConnection(BaseModel):+ """+ Connection relationship between equipment.+ """++ source: str = Field(description="Upstream equipment or source equipment name.")+ target: str = Field(description="Downstream equipment or target equipment name.")+ connection_type: str = Field(+ description='Connection type: material transfer, energy transfer, control signal, process flow, electrical connection, instrument monitoring.'+ )+ description: Optional[str] = Field(+ None,+ description="Detailed description of the connection (e.g., high-temperature material flow, circulating water loop, closed-loop control system).",+ )+++# ==============================================================================+# 2. Prompts+# ==============================================================================++_PROMPT = (+ "You are an industrial equipment management expert. Extract equipment entities and their interconnections from industrial equipment documents.\n\n"+ "Rules:\n"+ "- Identify all equipment, components, and systems, including main equipment, auxiliary equipment, instruments, valves, pumps, fans, motors, etc.\n"+ "- Classify equipment types (main/auxiliary/component/instrument/valve/pipeline/system).\n"+ "- Extract connection relationships between equipment, including material transfer, energy transfer, control signals, etc.\n"+ "- Record installation location and operating status.\n"+)++_NODE_PROMPT = (+ "You are an industrial equipment management expert. Extract all equipment entities (nodes) from documents.\n\n"+ "Extraction Rules:\n"+ "- Identify equipment names and component names.\n"+ "- Classify equipment categories (main equipment, auxiliary equipment, component, instrument, valve, pipeline, system, motor, pump, fan, container, etc.).\n"+ "- Record installation location and operating status.\n"+ "- Do not establish relationships between equipment.\n"+)++_EDGE_PROMPT = (+ "You are an industrial equipment management expert. Based on the equipment list, extract connection relationships between equipment (edges).\n\n"+ "Extraction Rules:\n"+ "- Identify material transfer relationships between equipment (upstream → downstream).\n"+ "- Identify energy transfer relationships (driven equipment → driven equipment).\n"+ "- Identify control signal relationships (control equipment → controlled equipment).\n"+ "- Identify process flow relationships (previous process → next process).\n"+ "- Identify electrical connections and instrument monitoring relationships.\n"+ "- Only establish relationships in the provided equipment list, do not create new equipment nodes.\n"+)++# ==============================================================================+# 3. Template Class+# ==============================================================================+++class EquipmentTopologyGraph(AutoGraph[IndustrialEquipment, EquipmentConnection]):+ """+ Applicable Documents: Equipment system diagrams, Piping and Instrumentation Diagrams (P&ID), equipment lists, equipment records, system manuals, equipment chapters in maintenance procedures.++ This template extracts equipment topology relationships from industrial equipment documents.+ It identifies physical connections, material flows, energy transfer, and control signal+ relationships between equipment to construct an equipment system topology graph.++ Example:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> topology = EquipmentTopologyGraph(llm_client=llm, embedder=embedder)+ >>> doc = "Line A consists of reactor B, cooling pump C and control cabinet D. Material from reactor B is transported through pipeline to cooling pump C for cooling, C is driven by motor E. Control cabinet D monitors B's temperature in real-time and controls E's speed."+ >>> topology.feed_text(doc)+ >>> topology.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ Initialize Equipment Topology Graph template.++ Args:+ llm_client (BaseChatModel): LLM for entity and relationship extraction.+ embedder (Embeddings): Embedding model for deduplication.+ extraction_mode (str): "one_stage" or "two_stage". Default is "two_stage".+ chunk_size (int): Maximum characters per chunk.+ chunk_overlap (int): Overlap between chunks.+ max_workers (int): Number of parallel processing worker threads.+ verbose (bool): Enable progress logging.+ **kwargs: Additional AutoGraph parameters.+ """+ super().__init__(+ node_schema=IndustrialEquipment,+ edge_schema=EquipmentConnection,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.connection_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ Visualize equipment topology graph using OntoSight.++ Args:+ top_k_nodes_for_search (int): Number of entities to retrieve. Default 3.+ top_k_edges_for_search (int): Number of relationships to retrieve. Default 3.+ top_k_nodes_for_chat (int): Number of entities in chat context. Default 3.+ top_k_edges_for_chat (int): Number of relationships in chat context. Default 3.+ """++ def node_label_extractor(node: IndustrialEquipment) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: EquipmentConnection) -> str:+ return edge.connection_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/en/industry/failure_case_graph.py b/hyperextract/templates/en/industry/failure_case_graph.pynew file mode 100644index 0000000..ea99042--- /dev/null+++ b/hyperextract/templates/en/industry/failure_case_graph.py@@ -0,0 +1,182 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema Definition+# ==============================================================================+++class CaseEntity(BaseModel):+ """+ Failure case entity, including phenomena, causes, measures, lessons, etc.+ """++ name: str = Field(description="Name of the entity such as phenomenon or measure.")+ category: str = Field(+ description='Category: phenomenon, cause, measure, lesson.'+ )+ description: Optional[str] = Field(+ None,+ description="Further elaboration and explanation of the entity.",+ )+ equipment: Optional[str] = Field(+ None,+ description="Involved equipment name.",+ )+++class CaseChain(BaseModel):+ """+ Relationship between failure case stages.+ """++ source: str = Field(description="Upstream stage name.")+ target: str = Field(description="Downstream stage name.")+ relation_type: str = Field(+ description='Relation type: leads to, takes, produces, discovers. Use "leads to" for cause-result, "takes" for taking measures.'+ )+ time_sequence: Optional[str] = Field(+ None,+ description="Temporal relationship: discovery, analysis, processing, summary.",+ )+++# ==============================================================================+# 2. Prompts+# ==============================================================================++_PROMPT = (+ "You are an industrial equipment failure analysis expert. Extract failure phenomena, causes, handling measures, and lessons learned from failure case documents.\n\n"+ "Rules:\n"+ "- Identify failure phenomena and abnormal manifestations.\n"+ "- Analyze failure causes and root causes.\n"+ "- Extract handling measures and solutions.\n"+ "- Summarize lessons learned and improvement suggestions.\n"+ "- Establish a complete chain from discovery to processing.\n"+)++_NODE_PROMPT = (+ "You are an industrial equipment failure analysis expert. Extract all related entities (nodes) from failure case documents.\n\n"+ "Extraction Rules:\n"+ "- Identify failure phenomena and abnormal manifestations.\n"+ "- Identify failure causes and root causes.\n"+ "- Identify handling measures and solutions.\n"+ "- Identify lessons learned and improvement suggestions.\n"+ "- Record involved equipment names.\n"+ "- Do not establish relationships between stages.\n"+)++_EDGE_PROMPT = (+ "You are an industrial equipment failure analysis expert. Based on the entity list, extract relationship between failure case stages (edges).\n\n"+ "Extraction Rules:\n"+ "- Identify association from phenomenon to cause.\n"+ "- Identify association from cause to measure.\n"+ "- Identify association from measure to lesson.\n"+ "- Temporal relationship: discovery → analysis → processing → summary.\n"+ "- Only establish relationships within the provided entity list.\n"+)++# ==============================================================================+# 3. Template Class+# ==============================================================================+++class FailureCaseGraph(AutoGraph[CaseEntity, CaseChain]):+ """+ Applicable Documents: Failure case library, accident analysis reports, equipment anomaly records, maintenance reports.++ This template extracts failure phenomena, causes, measures, and lessons from failure case documents.+ It identifies the complete failure evolution chain from discovery to processing,+ providing reference for equipment maintenance and prevention.++ Example:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> failure_case = FailureCaseGraph(llm_client=llm, embedder=embedder)+ >>> doc = "In January 2024, the main motor of Line A suddenly emitted abnormal sounds accompanied by increased vibration. Inspection revealed severe bearing wear, immediately replaced bearing and returned to normal. This failure reminds us to strengthen daily bearing inspection."+ >>> failure_case.feed_text(doc)+ >>> failure_case.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ Initialize Failure Case Graph template.++ Args:+ llm_client (BaseChatModel): LLM for entity and relationship extraction.+ embedder (Embeddings): Embedding model for deduplication.+ extraction_mode (str): "one_stage" or "two_stage". Default is "two_stage".+ chunk_size (int): Maximum characters per chunk.+ chunk_overlap (int): Overlap between chunks.+ max_workers (int): Number of parallel processing worker threads.+ verbose (bool): Enable progress logging.+ **kwargs: Additional AutoGraph parameters.+ """+ super().__init__(+ node_schema=CaseEntity,+ edge_schema=CaseChain,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ Visualize failure case graph using OntoSight.++ Args:+ top_k_nodes_for_search (int): Number of entities to retrieve. Default 3.+ top_k_edges_for_search (int): Number of relationships to retrieve. Default 3.+ top_k_nodes_for_chat (int): Number of entities in chat context. Default 3.+ top_k_edges_for_chat (int): Number of relationships in chat context. Default 3.+ """++ def node_label_extractor(node: CaseEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: CaseChain) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/en/industry/inspection_record_graph.py b/hyperextract/templates/en/industry/inspection_record_graph.pynew file mode 100644index 0000000..29671a8--- /dev/null+++ b/hyperextract/templates/en/industry/inspection_record_graph.py@@ -0,0 +1,171 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema Definition+# ==============================================================================+++class InspectionEntity(BaseModel):+ """+ Inspection entity, including equipment and inspection items.+ """++ name: str = Field(description="Entity name (e.g., CNC machining center, robotic arm system, motor operation status, bearing temperature inspection).")+ category: str = Field(+ description='Category: equipment, inspection item.'+ )+ description: Optional[str] = Field(+ None,+ description="Description of this entity.",+ )+++class InspectionHierarchy(BaseModel):+ """+ Hierarchy relationship between inspection entities.+ """++ source: str = Field(description="Parent entity (whole/equipment) name.")+ target: str = Field(description="Child entity (inspection item/part) name.")+ relation_type: str = Field(+ description='Relation type: belongs to, subclass. Use "belongs to" to indicate inspection item belongs to a specific equipment.'+ )+ details: Optional[str] = Field(+ None,+ description="Detailed description of the relationship.",+ )+++# ==============================================================================+# 2. Prompts+# ==============================================================================++_PROMPT = (+ "You are an industrial equipment inspection analysis expert. Extract equipment and inspection items from inspection records to build inspection hierarchy.\n\n"+ "Rules:\n"+ "- Identify major equipment (e.g., CNC machining center, robotic arm system, material handling system).\n"+ "- Identify inspection items under each equipment (e.g., motor operation status, bearing temperature, coolant level).\n"+ "- Establish belonging relationship (Part-Of) between inspection items and equipment.\n"+)++_NODE_PROMPT = (+ "You are an industrial equipment inspection analysis expert. Extract all entities (nodes) from inspection records.\n\n"+ "Extraction Rules:\n"+ "- Identify equipment names (main categories).\n"+ "- Identify inspection item names (specific check points).\n"+ "- Assign category for each entity (equipment/inspection item).\n"+ "- Do not establish relationships between entities.\n"+)++_EDGE_PROMPT = (+ "You are an industrial equipment inspection analysis expert. Based on the entity list, extract hierarchy relationships between entities (edges).\n\n"+ "Extraction Rules:\n"+ "- Identify belonging relationship (Part-Of) between inspection items and equipment.\n"+ "- For example: motor operation status belongs to CNC machining center.\n"+ "- Only establish relationships within the provided entity list.\n"+)++# ==============================================================================+# 3. Template Class+# ==============================================================================+++class InspectionRecordGraph(AutoGraph[InspectionEntity, InspectionHierarchy]):+ """+ Applicable Documents: Inspection record books, equipment operation records, inspection daily reports, equipment point inspection forms.++ This template extracts equipment and inspection items from inspection records to build inspection hierarchy.+ It identifies the belonging relationship (Part-Of) between equipment and inspection items.++ Example:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> inspection = InspectionRecordGraph(llm_client=llm, embedder=embedder)+ >>> doc = "March 15, 2024, daily inspection of Line A. CNC machining center: motor operating normally..."+ >>> inspection.feed_text(doc)+ >>> inspection.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ Initialize Inspection Record Graph template.++ Args:+ llm_client (BaseChatModel): LLM for entity and relationship extraction.+ embedder (Embeddings): Embedding model for deduplication.+ extraction_mode (str): "one_stage" or "two_stage". Default is "two_stage".+ chunk_size (int): Maximum characters per chunk.+ chunk_overlap (int): Overlap between chunks.+ max_workers (int): Number of parallel processing worker threads.+ verbose (bool): Enable progress logging.+ **kwargs: Additional AutoGraph parameters.+ """+ super().__init__(+ node_schema=InspectionEntity,+ edge_schema=InspectionHierarchy,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ Visualize inspection record graph using OntoSight.++ Args:+ top_k_nodes_for_search (int): Number of entities to retrieve. Default 3.+ top_k_edges_for_search (int): Number of relationships to retrieve. Default 3.+ top_k_nodes_for_chat (int): Number of entities in chat context. Default 3.+ top_k_edges_for_chat (int): Number of relationships in chat context. Default 3.+ """++ def node_label_extractor(node: InspectionEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: InspectionHierarchy) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/en/industry/operating_mode_graph.py b/hyperextract/templates/en/industry/operating_mode_graph.pynew file mode 100644index 0000000..0c5c4b0--- /dev/null+++ b/hyperextract/templates/en/industry/operating_mode_graph.py@@ -0,0 +1,184 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema Definition+# ==============================================================================+++class ModeEntity(BaseModel):+ """+ Mode entity, including modes and conditions.+ """++ name: str = Field(description="Entity name (e.g., automatic operation mode, manual debug mode, standby mode, emergency stop mode, press start button, press stop button, fault occurs).")+ category: str = Field(+ description='Category: mode, condition. Modes include automatic, manual debug, standby, etc.; conditions include start button, stop button, fault signal, etc.'+ )+ description: Optional[str] = Field(+ None,+ description="Description of this entity.",+ )+ load_range: Optional[str] = Field(+ None,+ description="Load range (e.g., 0-50%, 50-80%, 80-100%), only valid for mode category.",+ )+++class ModeTransition(BaseModel):+ """+ Transition relationship between modes, or trigger relationship between conditions and modes.+ """++ source: str = Field(description="Source entity name (mode or condition).")+ target: str = Field(description="Target entity name (mode or condition).")+ relation_type: str = Field(+ description='Relation type: switches to, triggers. Use "switches to" for mode-to-mode switching, "triggers" for condition triggering mode.'+ )+ transition_condition: Optional[str] = Field(+ None,+ description="Switching condition (e.g., press start button, press stop button, fault occurs).",+ )+ transition_procedure: Optional[str] = Field(+ None,+ description="Switching procedure.",+ )+++# ==============================================================================+# 2. Prompts+# ==============================================================================++_PROMPT = (+ "You are an industrial equipment mode analysis expert. Extract mode and condition entities and their relationships from operating procedure documents.\n\n"+ "Rules:\n"+ "- Identify various operation modes, such as automatic, manual debug, standby, emergency stop, etc.\n"+ "- Identify various trigger conditions, such as press start button, press stop button, fault occurs, etc.\n"+ "- Identify applicable conditions and load ranges for each mode.\n"+ "- Extract switching relationships between modes (switches to).\n"+ "- Extract trigger relationships from conditions to modes (triggers).\n"+)++_NODE_PROMPT = (+ "You are an industrial equipment mode analysis expert. Extract all entities (nodes) from operating procedure documents.\n\n"+ "Extraction Rules:\n"+ "- Identify mode names (e.g., automatic operation mode, manual debug mode, standby mode, emergency stop mode).\n"+ "- Identify condition names (e.g., press start button, press stop button, fault occurs, return to normal).\n"+ "- Assign category for each entity (mode/condition).\n"+ "- Record load range for each mode.\n"+ "- Do not establish relationships between entities.\n"+)++_EDGE_PROMPT = (+ "You are an industrial equipment mode analysis expert. Based on the entity list, extract relationships between modes and conditions (edges).\n\n"+ "Extraction Rules:\n"+ "- Identify switching relationships between modes (source mode switches to target mode).\n"+ "- Identify trigger relationships from conditions to modes (condition triggers target mode).\n"+ "- Use relation type as \"switches to\" or \"triggers\".\n"+ "- Only establish relationships within the provided entity list.\n"+)++# ==============================================================================+# 3. Template Class+# ==============================================================================+++class OperatingModeGraph(AutoGraph[ModeEntity, ModeTransition]):+ """+ Applicable Documents: Operating procedures, equipment operation manuals, mode switching manuals.++ This template extracts mode types and switching conditions from operating procedures.+ It identifies switching conditions and procedures between different modes.++ Example:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> mode = OperatingModeGraph(llm_client=llm, embedder=embedder)+ >>> doc = "Equipment has two operation modes: automatic mode and manual mode. Press start button to switch from standby to automatic mode..."+ >>> mode.feed_text(doc)+ >>> mode.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ Initialize Operating Mode Graph template.++ Args:+ llm_client (BaseChatModel): LLM for entity and relationship extraction.+ embedder (Embeddings): Embedding model for deduplication.+ extraction_mode (str): "one_stage" or "two_stage". Default is "two_stage".+ chunk_size (int): Maximum characters per chunk.+ chunk_overlap (int): Overlap between chunks.+ max_workers (int): Number of parallel processing worker threads.+ verbose (bool): Enable progress logging.+ **kwargs: Additional AutoGraph parameters.+ """+ super().__init__(+ node_schema=ModeEntity,+ edge_schema=ModeTransition,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ Visualize operating mode graph using OntoSight.++ Args:+ top_k_nodes_for_search (int): Number of entities to retrieve. Default 3.+ top_k_edges_for_search (int): Number of relationships to retrieve. Default 3.+ top_k_nodes_for_chat (int): Number of entities in chat context. Default 3.+ top_k_edges_for_chat (int): Number of relationships in chat context. Default 3.+ """++ def node_label_extractor(node: ModeEntity) -> str:+ load = f" [{node.load_range}]" if node.load_range else ""+ return f"{node.name} ({node.category}){load}"++ def edge_label_extractor(edge: ModeTransition) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/en/industry/operation_flow_graph.py b/hyperextract/templates/en/industry/operation_flow_graph.pynew file mode 100644index 0000000..fe72d9f--- /dev/null+++ b/hyperextract/templates/en/industry/operation_flow_graph.py@@ -0,0 +1,182 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema Definition+# ==============================================================================+++class OperationEntity(BaseModel):+ """+ Operation flow entity, including steps, states, equipment, etc.+ """++ name: str = Field(description="Entity specific name (e.g., turn on auxiliary power, start hydraulic system, check status).")+ category: str = Field(+ description='Category: step, state, equipment.'+ )+ description: Optional[str] = Field(+ None,+ description="Detailed operation description for this entity.",+ )+ expected_result: Optional[str] = Field(+ None,+ description="Expected result after executing this step.",+ )+++class OperationTransition(BaseModel):+ """+ Transition relationship between operation steps.+ """++ source: str = Field(description="Current step name.")+ target: str = Field(description="Next step name.")+ relation_type: str = Field(+ description='Relation type: next step, trigger, leads to. Use "next step" for flow sequence.'+ )+ trigger_condition: Optional[str] = Field(+ None,+ description="Condition to trigger the next step.",+ )+ state_change: Optional[str] = Field(+ None,+ description="Description of state change.",+ )+++# ==============================================================================+# 2. Prompts+# ==============================================================================++_PROMPT = (+ "You are an industrial operation flow analysis expert. Extract operation steps, equipment states, and expected results from operating procedure documents.\n\n"+ "Rules:\n"+ "- Identify each operation step and execution sequence.\n"+ "- Record detailed operation content for each step.\n"+ "- Extract equipment state changes and expected results.\n"+ "- Establish transition relationships between steps.\n"+)++_NODE_PROMPT = (+ "You are an industrial operation flow analysis expert. Extract all entities (nodes) from operating procedure documents.\n\n"+ "Extraction Rules:\n"+ "- Identify operation step names.\n"+ "- Identify equipment state names.\n"+ "- Identify related equipment names.\n"+ "- Record operation descriptions and expected results for each step.\n"+ "- Do not establish relationships between steps.\n"+)++_EDGE_PROMPT = (+ "You are an industrial operation flow analysis expert. Based on the entity list, extract transition relationships between operation steps (edges).\n\n"+ "Extraction Rules:\n"+ "- Identify execution sequence of steps (current step → next step).\n"+ "- Extract conditions to trigger the next step.\n"+ "- Record equipment state changes.\n"+ "- Only establish relationships within the provided entity list.\n"+)++# ==============================================================================+# 3. Template Class+# ==============================================================================+++class OperationFlowGraph(AutoGraph[OperationEntity, OperationTransition]):+ """+ Applicable Documents: Operating procedures, start/stop operation tickets, equipment operation manuals, safety operation procedures.++ This template extracts operation steps, equipment states, and expected results from operating procedures.+ It identifies step sequences and state changes in operation flows, providing reference for operation training and safety control.++ Example:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> operation = OperationFlowGraph(llm_client=llm, embedder=embedder)+ >>> doc = "Startup procedure: 1. Check if power is normal; 2. Turn on main switch of control cabinet; 3. Start motor; 4. Confirm operating status. After power is normal, turn on main switch, after main switch is closed, start motor."+ >>> operation.feed_text(doc)+ >>> operation.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ Initialize Operation Flow Graph template.++ Args:+ llm_client (BaseChatModel): LLM for entity and relationship extraction.+ embedder (Embeddings): Embedding model for deduplication.+ extraction_mode (str): "one_stage" or "two_stage". Default is "two_stage".+ chunk_size (int): Maximum characters per chunk.+ chunk_overlap (int): Overlap between chunks.+ max_workers (int): Number of parallel processing worker threads.+ verbose (bool): Enable progress logging.+ **kwargs: Additional AutoGraph parameters.+ """+ super().__init__(+ node_schema=OperationEntity,+ edge_schema=OperationTransition,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ Visualize operation flow graph using OntoSight.++ Args:+ top_k_nodes_for_search (int): Number of entities to retrieve. Default 3.+ top_k_edges_for_search (int): Number of relationships to retrieve. Default 3.+ top_k_nodes_for_chat (int): Number of entities in chat context. Default 3.+ top_k_edges_for_chat (int): Number of relationships in chat context. Default 3.+ """++ def node_label_extractor(node: OperationEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: OperationTransition) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/en/industry/safety_control_graph.py b/hyperextract/templates/en/industry/safety_control_graph.pynew file mode 100644index 0000000..4c58d98--- /dev/null+++ b/hyperextract/templates/en/industry/safety_control_graph.py@@ -0,0 +1,182 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema Definition+# ==============================================================================+++class SafetyEntity(BaseModel):+ """+ Safety control entity, including hazard sources, risk points, control measures, responsible persons, etc.+ """++ name: str = Field(description="Entity name (e.g., high temperature high pressure equipment, electric shock risk, wear protective equipment, safety supervisor).")+ category: str = Field(+ description='Category: hazard source, risk point, control measure, responsible person.'+ )+ description: Optional[str] = Field(+ None,+ description="Description of this entity.",+ )+++class SafetyRelation(BaseModel):+ """+ Safety control relationship.+ """++ source: str = Field(description="Source entity name (hazard source or risk point).")+ target: str = Field(description="Target entity name (control measure or responsible person).")+ relation_type: str = Field(+ description='Relation type: controls, responsible for. Use "controls" for hazard source/risk point to control measure, "responsible for" for control measure to responsible person.'+ )+ control_measure: Optional[str] = Field(+ None,+ description="Specific content of control measure.",+ )+ responsible_person: Optional[str] = Field(+ None,+ description="Name of responsible person or department.",+ )+++# ==============================================================================+# 2. Prompts+# ==============================================================================++_PROMPT = (+ "You are an industrial safety management analysis expert. Extract hazard sources, risk points, and control measures from safety procedure documents to build safety control relationships.\n\n"+ "Rules:\n"+ "- Identify hazard sources (e.g., high temperature high pressure equipment, electrical equipment, chemicals).\n"+ "- Identify risk points (e.g., electric shock risk, burn risk, mechanical injury).\n"+ "- Identify control measures (e.g., wear protective equipment, regular maintenance, ventilation).\n"+ "- Identify responsible persons (e.g., safety supervisor, equipment person in charge).\n"+ "- Establish relationships from hazard sources/risk points to control measures/responsible persons.\n"+)++_NODE_PROMPT = (+ "You are an industrial safety management analysis expert. Extract all entities (nodes) from safety procedure documents.\n\n"+ "Extraction Rules:\n"+ "- Identify hazard source names.\n"+ "- Identify risk point names.\n"+ "- Identify control measure names.\n"+ "- Identify responsible person names.\n"+ "- Assign category for each entity (hazard source/risk point/control measure/responsible person).\n"+ "- Do not establish relationships between entities.\n"+)++_EDGE_PROMPT = (+ "You are an industrial safety management analysis expert. Based on the entity list, extract safety control relationships (edges).\n\n"+ "Extraction Rules:\n"+ "- Identify association from hazard source to control measure.\n"+ "- Identify association from risk point to control measure.\n"+ "- Identify association from control measure to responsible person.\n"+ "- Record specific content of control measures.\n"+ "- Record responsible person information.\n"+ "- Only establish relationships within the provided entity list.\n"+)++# ==============================================================================+# 3. Template Class+# ==============================================================================+++class SafetyControlGraph(AutoGraph[SafetyEntity, SafetyRelation]):+ """+ Applicable Documents: Safety procedures, safety risk assessment reports, occupational health and safety manuals.++ This template extracts hazard sources, risk points, and control measures from safety procedures to build safety control relationships.+ It uses category to distinguish heterogeneous nodes and identifies the correspondence between safety risks and control responsibilities.++ Example:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> safety = SafetyControlGraph(llm_client=llm, embedder=embedder)+ >>> doc = "High temperature equipment has burn risk, need to wear protective gloves. Equipment person in charge is responsible for supervision and inspection..."+ >>> safety.feed_text(doc)+ >>> safety.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ Initialize Safety Control Graph template.++ Args:+ llm_client (BaseChatModel): LLM for entity and relationship extraction.+ embedder (Embeddings): Embedding model for deduplication.+ extraction_mode (str): "one_stage" or "two_stage". Default is "two_stage".+ chunk_size (int): Maximum characters per chunk.+ chunk_overlap (int): Overlap between chunks.+ max_workers (int): Number of parallel processing worker threads.+ verbose (bool): Enable progress logging.+ **kwargs: Additional AutoGraph parameters.+ """+ super().__init__(+ node_schema=SafetyEntity,+ edge_schema=SafetyRelation,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ Visualize safety control graph using OntoSight.++ Args:+ top_k_nodes_for_search (int): Number of entities to retrieve. Default 3.+ top_k_edges_for_search (int): Number of relationships to retrieve. Default 3.+ top_k_nodes_for_chat (int): Number of entities in chat context. Default 3.+ top_k_edges_for_chat (int): Number of relationships in chat context. Default 3.+ """++ def node_label_extractor(node: SafetyEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: SafetyRelation) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/en/industry/system_topology_graph.py b/hyperextract/templates/en/industry/system_topology_graph.pynew file mode 100644index 0000000..fd6060e--- /dev/null+++ b/hyperextract/templates/en/industry/system_topology_graph.py@@ -0,0 +1,177 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema Definition+# ==============================================================================+++class SystemEntity(BaseModel):+ """+ System topology entity, including factory, system, subsystem, equipment, etc.+ """++ name: str = Field(description="Entity name (e.g., Factory A, Manufacturing Workshop A, CNC machining system, cooling system).")+ category: str = Field(+ description='Category: factory, system, subsystem, equipment.'+ )+ function: Optional[str] = Field(+ None,+ description="Function description.",+ )+ capacity: Optional[str] = Field(+ None,+ description="Capacity or scale.",+ )+++class SystemHierarchy(BaseModel):+ """+ System hierarchy relationship.+ """++ source: str = Field(description="Parent entity name (factory or system).")+ target: str = Field(description="Child entity name (system or subsystem or equipment).")+ relation_type: str = Field(+ description='Relation type: contains, belongs to, subordinate. Use "contains" to indicate parent contains child.'+ )+++# ==============================================================================+# 2. Prompts+# ==============================================================================++_PROMPT = (+ "You are an industrial system architecture analysis expert. Extract hierarchy relationships between factory, system, subsystem, and equipment from system manuals.\n\n"+ "Rules:\n"+ "- Identify factories (e.g., Factory A, Factory B).\n"+ "- Identify production systems (e.g., manufacturing workshop, processing workshop).\n"+ "- Identify subsystems (e.g., CNC machining system, cooling system, material handling system).\n"+ "- Identify specific equipment (e.g., CNC machining center, robotic arm, pump).\n"+ "- Establish hierarchical inclusion relationships between upper and lower levels.\n"+)++_NODE_PROMPT = (+ "You are an industrial system architecture analysis expert. Extract all entities (nodes) from system manuals.\n\n"+ "Extraction Rules:\n"+ "- Identify factory names.\n"+ "- Identify production system names.\n"+ "- Identify subsystem names.\n"+ "- Identify specific equipment names.\n"+ "- Assign category for each entity (factory/system/subsystem/equipment).\n"+ "- Do not establish relationships between entities.\n"+)++_EDGE_PROMPT = (+ "You are an industrial system architecture analysis expert. Based on the entity list, extract system hierarchy relationships (edges).\n\n"+ "Extraction Rules:\n"+ "- Identify inclusion relationship between factory and system.\n"+ "- Identify inclusion relationship between system and subsystem.\n"+ "- Identify inclusion relationship between subsystem and equipment.\n"+ "- Record hierarchy type.\n"+ "- Only establish relationships within the provided entity list.\n"+)++# ==============================================================================+# 3. Template Class+# ==============================================================================+++class SystemTopologyGraph(AutoGraph[SystemEntity, SystemHierarchy]):+ """+ Applicable Documents: System manuals, factory layout diagrams, system architecture documents.++ This template extracts hierarchy relationships between factory, system, subsystem, and equipment from system manuals.+ It constructs a complete factory system architecture view.++ Example:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> topology = SystemTopologyGraph(llm_client=llm, embedder=embedder)+ >>> doc = "Factory A contains Manufacturing Workshop A, Manufacturing Workshop A includes CNC machining system and material handling system..."+ >>> topology.feed_text(doc)+ >>> topology.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ Initialize System Topology Graph template.++ Args:+ llm_client (BaseChatModel): LLM for entity and relationship extraction.+ embedder (Embeddings): Embedding model for deduplication.+ extraction_mode (str): "one_stage" or "two_stage". Default is "two_stage".+ chunk_size (int): Maximum characters per chunk.+ chunk_overlap (int): Overlap between chunks.+ max_workers (int): Number of parallel processing worker threads.+ verbose (bool): Enable progress logging.+ **kwargs: Additional AutoGraph parameters.+ """+ super().__init__(+ node_schema=SystemEntity,+ edge_schema=SystemHierarchy,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ Visualize system topology graph using OntoSight.++ Args:+ top_k_nodes_for_search (int): Number of entities to retrieve. Default 3.+ top_k_edges_for_search (int): Number of relationships to retrieve. Default 3.+ top_k_nodes_for_chat (int): Number of entities in chat context. Default 3.+ top_k_edges_for_chat (int): Number of relationships in chat context. Default 3.+ """++ def node_label_extractor(node: SystemEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: SystemHierarchy) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/zh/industry/__init__.py b/hyperextract/templates/zh/industry/__init__.pyindex e69de29..1b6e581 100644--- a/hyperextract/templates/zh/industry/__init__.py+++ b/hyperextract/templates/zh/industry/__init__.py@@ -0,0 +1,25 @@+"""+工业领域模板,用于从工业设备文档中提取结构化知识。++包含设备拓扑、风险传导、故障案例、检修工序等图谱模板。+"""++from .equipment_topology_graph import EquipmentTopologyGraph+from .failure_case_graph import FailureCaseGraph+from .operation_flow_graph import OperationFlowGraph+from .inspection_record_graph import InspectionRecordGraph+from .emergency_response_graph import EmergencyResponseGraph+from .safety_control_graph import SafetyControlGraph+from .system_topology_graph import SystemTopologyGraph+from .operating_mode_graph import OperatingModeGraph++__all__ = [+ "EquipmentTopologyGraph",+ "FailureCaseGraph",+ "OperationFlowGraph",+ "InspectionRecordGraph",+ "EmergencyResponseGraph",+ "SafetyControlGraph",+ "SystemTopologyGraph",+ "OperatingModeGraph",+]diff --git a/hyperextract/templates/zh/industry/emergency_response_graph.py b/hyperextract/templates/zh/industry/emergency_response_graph.pynew file mode 100644index 0000000..f07390d--- /dev/null+++ b/hyperextract/templates/zh/industry/emergency_response_graph.py@@ -0,0 +1,180 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema 定义+# ==============================================================================+++class EmergencyEntity(BaseModel):+ """+ 应急预案实体,包括事故场景、响应动作、部门等。+ """++ name: str = Field(description="实体名称(如:火灾、停电、报警、疏散人员、设备部等)。")+ category: str = Field(+ description='类别:事故场景、响应动作、部门。'+ )+ description: Optional[str] = Field(+ None,+ description="对该实体的描述。",+ )+++class ResponseFlow(BaseModel):+ """+ 应急响应流程关系。+ """++ source: str = Field(description="源实体名称(事故场景或响应动作)。")+ target: str = Field(description="目标实体名称(响应动作或部门)。")+ relation_type: str = Field(+ description='关系类型:触发、执行、负责。'+ )+ time_limit: Optional[str] = Field(+ None,+ description="响应时间要求(如:5分钟内、10分钟内)。",+ )+ success_criterion: Optional[str] = Field(+ None,+ description="成功标准(如:人员安全撤离、火势控制)。",+ )+++# ==============================================================================+# 2. 提示词 (Prompts)+# ==============================================================================++_PROMPT = (+ "你是工业应急管理分析专家。从应急预案文档中提取事故场景、响应动作和部门,构建应急响应流程。\n\n"+ "规则:\n"+ "- 识别事故场景(如火灾、泄漏、停电、设备故障等)。\n"+ "- 识别响应动作(如报警、疏散人员、关闭电源等)。\n"+ "- 识别负责部门(如安保部、设备部、急救部等)。\n"+ "- 建立从事故场景到响应动作的流程关系。\n"+ "- 记录时间要求和成功标准。\n"+)++_NODE_PROMPT = (+ "你是工业应急管理分析专家。从应急预案文档中提取所有实体(节点)。\n\n"+ "提取规则:\n"+ "- 识别事故场景名称。\n"+ "- 识别响应动作名称。\n"+ "- 识别负责部门名称。\n"+ "- 为每个实体指定类别(事故场景/响应动作/部门)。\n"+ "- 不建立实体之间的关系。\n"+)++_EDGE_PROMPT = (+ "你是工业应急管理分析专家。在获得实体清单的基础上,提取应急响应流程关系(边)。\n\n"+ "提取规则:\n"+ "- 识别从事故场景到响应动作的关联。\n"+ "- 识别从响应动作到负责部门的关联。\n"+ "- 记录响应时间要求。\n"+ "- 记录成功标准。\n"+ "- 仅在提供的实体列表中建立关系。\n"+)++# ==============================================================================+# 3. 模板类+# ==============================================================================+++class EmergencyResponseGraph(AutoGraph[EmergencyEntity, ResponseFlow]):+ """+ 适用文档: 应急预案、应急处置方案、安全规程。++ 模板用于从应急预案中提取事故场景、响应动作和部门,构建应急响应流程。+ 通过 category 区分异质节点,识别应急响应的流程和责任分工。++ 使用示例:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> emergency = EmergencyResponseGraph(llm_client=llm, embedder=embedder)+ >>> doc = "发生火灾时,应立即报警并启动应急预案。安保部负责疏散人员,设备部负责关闭电源..."+ >>> emergency.feed_text(doc)+ >>> emergency.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ 初始化应急预案图谱模板。++ Args:+ llm_client (BaseChatModel): 用于实体和关系提取的 LLM。+ embedder (Embeddings): 用于去重的嵌入模型。+ extraction_mode (str): "one_stage" 或 "two_stage"。默认为 "two_stage"。+ chunk_size (int): 每个分块的最大字符数。+ chunk_overlap (int): 分块之间的重叠。+ max_workers (int): 并行处理工作线程数。+ verbose (bool): 是否启用进度日志。+ **kwargs: AutoGraph 的其他参数。+ """+ super().__init__(+ node_schema=EmergencyEntity,+ edge_schema=ResponseFlow,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ 使用 OntoSight 可视化应急预案图。++ Args:+ top_k_nodes_for_search (int): 检索的实体数。默认 3。+ top_k_edges_for_search (int): 检索的关系数。默认 3。+ top_k_nodes_for_chat (int): 对话上下文中的实体数。默认 3。+ top_k_edges_for_chat (int): 对话上下文中的关系数。默认 3。+ """++ def node_label_extractor(node: EmergencyEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: ResponseFlow) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/zh/industry/equipment_topology_graph.py b/hyperextract/templates/zh/industry/equipment_topology_graph.pynew file mode 100644index 0000000..0ed423c--- /dev/null+++ b/hyperextract/templates/zh/industry/equipment_topology_graph.py@@ -0,0 +1,187 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema 定义+# ==============================================================================+++class IndustrialEquipment(BaseModel):+ """+ 工业设备实体,包括主机、辅机、部件、仪表、阀门、管路等。+ """++ name: str = Field(description="设备或部件名称。")+ category: str = Field(+ description='类别:主机、辅机、部件、仪表、阀门、管路、系统、电机、泵、风机、容器等。'+ )+ location: Optional[str] = Field(+ None,+ description="安装位置(如:生产车间一层、主厂房二层)。",+ )+ status: Optional[str] = Field(+ None,+ description="运行状态:运行、备用、检修、停运。",+ )+ specification: Optional[str] = Field(+ None,+ description="规格型号或技术参数。",+ )+ manufacturer: Optional[str] = Field(+ None,+ description="制造厂家。",+ )+++class EquipmentConnection(BaseModel):+ """+ 设备之间的连接关系。+ """++ source: str = Field(description="上游设备或源设备名称。")+ target: str = Field(description="下游设备或目标设备名称。")+ connection_type: str = Field(+ description='连接类型:物料输送、能量传递、控制信号、工艺流程、电气连接、仪表监测。'+ )+ description: Optional[str] = Field(+ None,+ description="连接关系的详细描述(如:高温物料流向、循环水回路、闭环控制系统)。",+ )+++# ==============================================================================+# 2. 提示词 (Prompts)+# ==============================================================================++_PROMPT = (+ "你是工业设备管理专家。从工业设备文档中提取设备实体及其相互连接关系。\n\n"+ "规则:\n"+ "- 识别所有设备、部件和系统,包括主机、辅机、仪表、阀门、泵、风机、电机等。\n"+ "- 分类设备类型(主机/辅机/部件/仪表/阀门/管路/系统)。\n"+ "- 提取设备之间的连接关系,包括物料输送、能量传递、控制信号等。\n"+ "- 记录安装位置和运行状态。\n"+)++_NODE_PROMPT = (+ "你是工业设备管理专家。从文档中提取所有设备实体(节点)。\n\n"+ "提取规则:\n"+ "- 识别设备名称和部件名称。\n"+ "- 分类设备类别(主机、辅机、部件、仪表、阀门、管路、系统、电机、泵、风机、容器等)。\n"+ "- 记录安装位置和运行状态。\n"+ "- 不建立设备之间的关系。\n"+)++_EDGE_PROMPT = (+ "你是工业设备管理专家。在获得设备清单的基础上,提取设备之间的连接关系(边)。\n\n"+ "提取规则:\n"+ "- 识别设备之间的物料输送关系(上游→下游)。\n"+ "- 识别能量传递关系(驱动设备→被驱动设备)。\n"+ "- 识别控制信号关系(控制设备→被控设备)。\n"+ "- 识别工艺流程关系(前一工序→后一工序)。\n"+ "- 识别电气连接和仪表监测关系。\n"+ "- 仅在提供的设备列表中建立关系,不要创建新的设备节点。\n"+)++# ==============================================================================+# 3. 模板类+# ==============================================================================+++class EquipmentTopologyGraph(AutoGraph[IndustrialEquipment, EquipmentConnection]):+ """+ 适用文档: 设备系统图、管道仪表图(P&ID)、设备清单、设备台账、系统说明书、检修规程中的设备章节。++ 模板用于从工业设备文档中提取设备拓扑关系。识别设备之间的物理连接、+ 物料流向、能量传递和控制信号关系,构建设备系统拓扑图。++ 使用示例:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> topology = EquipmentTopologyGraph(llm_client=llm, embedder=embedder)+ >>> doc = "A生产线由反应釜B、冷却泵C和控制柜D组成。反应釜B产生的物料通过管道输送至冷却泵C进行冷却,C由电机E驱动。控制柜D实时监测B的温度并控制E的转速。"+ >>> topology.feed_text(doc)+ >>> topology.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ 初始化设备拓扑图谱模板。++ Args:+ llm_client (BaseChatModel): 用于实体和关系提取的 LLM。+ embedder (Embeddings): 用于去重的嵌入模型。+ extraction_mode (str): "one_stage" 或 "two_stage"。默认为 "two_stage"。+ chunk_size (int): 每个分块的最大字符数。+ chunk_overlap (int): 分块之间的重叠。+ max_workers (int): 并行处理工作线程数。+ verbose (bool): 是否启用进度日志。+ **kwargs: AutoGraph 的其他参数。+ """+ super().__init__(+ node_schema=IndustrialEquipment,+ edge_schema=EquipmentConnection,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.connection_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ 使用 OntoSight 可视化设备拓扑图。++ Args:+ top_k_nodes_for_search (int): 检索的实体数。默认 3。+ top_k_edges_for_search (int): 检索的关系数。默认 3。+ top_k_nodes_for_chat (int): 对话上下文中的实体数。默认 3。+ top_k_edges_for_chat (int): 对话上下文中的关系数。默认 3。+ """++ def node_label_extractor(node: IndustrialEquipment) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: EquipmentConnection) -> str:+ return edge.connection_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/zh/industry/failure_case_graph.py b/hyperextract/templates/zh/industry/failure_case_graph.pynew file mode 100644index 0000000..d68c152--- /dev/null+++ b/hyperextract/templates/zh/industry/failure_case_graph.py@@ -0,0 +1,181 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema 定义+# ==============================================================================+++class CaseEntity(BaseModel):+ """+ 故障案例实体,包括现象、原因、措施、教训等。+ """++ name: str = Field(description="现象/措施等实体的名称。")+ category: str = Field(+ description='类别:现象、原因、措施、教训。'+ )+ description: Optional[str] = Field(+ None,+ description="对该实体内涵的进一步阐述和说明。",+ )+ equipment: Optional[str] = Field(+ None,+ description="涉及设备名称。",+ )+++class CaseChain(BaseModel):+ """+ 故障案例环节之间的关联关系。+ """++ source: str = Field(description="上游环节名称。")+ target: str = Field(description="下游环节名称。")+ relation_type: str = Field(+ description='关系类型:导致、采取、产生、发现'+ )+ time_sequence: Optional[str] = Field(+ None,+ description="时序关系:发现、分析、处理、总结。",+ )+++# ==============================================================================+# 2. 提示词 (Prompts)+# ==============================================================================++_PROMPT = (+ "你是工业设备故障分析专家。从故障案例文档中提取故障现象、原因、处理措施和经验教训。\n\n"+ "规则:\n"+ "- 识别故障现象和异常表现。\n"+ "- 分析故障原因和根本原因。\n"+ "- 提取处理措施和解决方案。\n"+ "- 总结经验教训和改进建议。\n"+ "- 建立从发现到处理的完整链条。\n"+)++_NODE_PROMPT = (+ "你是工业设备故障分析专家。从故障案例文档中提取所相关实体(节点)。\n\n"+ "提取规则:\n"+ "- 识别故障现象和异常表现。\n"+ "- 识别故障原因和根本原因。\n"+ "- 识别处理措施和解决方案。\n"+ "- 识别经验教训和改进建议。\n"+ "- 记录涉及的设备名称。\n"+ "- 不建立环节之间的关系。\n"+)++_EDGE_PROMPT = (+ "你是工业设备故障分析专家。在获得实体清单的基础上,提取故障环节之间的关联关系(边)。\n\n"+ "提取规则:\n"+ "- 识别从现象到原因的关联。\n"+ "- 识别从原因到措施的关联。\n"+ "- 识别从措施到教训的关联。\n"+ "- 时序关系:发现 → 分析 → 处理 → 总结。\n"+ "- 仅在提供的实体列表中建立关系。\n"+)++# ==============================================================================+# 3. 模板类+# ==============================================================================+++class FailureCaseGraph(AutoGraph[CaseEntity, CaseChain]):+ """+ 适用文档: 故障案例库、事故分析报告、设备异常记录、检修报告。++ 模板用于从故障案例文档中提取故障现象、原因、措施和教训。+ 识别从发现到处理的完整故障演进链条,为设备维护和预防提供参考。++ 使用示例:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> failure_case = FailureCaseGraph(llm_client=llm, embedder=embedder)+ >>> doc = "2024年1月,A生产线主电机突发异响并伴随振动加剧。检查发现轴承磨损严重,立即更换轴承后恢复正常。此故障提醒需加强轴承日常巡检。"+ >>> failure_case.feed_text(doc)+ >>> failure_case.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ 初始化故障案例图谱模板。++ Args:+ llm_client (BaseChatModel): 用于实体和关系提取的 LLM。+ embedder (Embeddings): 用于去重的嵌入模型。+ extraction_mode (str): "one_stage" 或 "two_stage"。默认为 "two_stage"。+ chunk_size (int): 每个分块的最大字符数。+ chunk_overlap (int): 分块之间的重叠。+ max_workers (int): 并行处理工作线程数。+ verbose (bool): 是否启用进度日志。+ **kwargs: AutoGraph 的其他参数。+ """+ super().__init__(+ node_schema=CaseEntity,+ edge_schema=CaseChain,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ 使用 OntoSight 可视化故障案例图。++ Args:+ top_k_nodes_for_search (int): 检索的实体数。默认 3。+ top_k_edges_for_search (int): 检索的关系数。默认 3。+ top_k_nodes_for_chat (int): 对话上下文中的实体数。默认 3。+ top_k_edges_for_chat (int): 对话上下文中的关系数。默认 3。+ """++ def node_label_extractor(node: CaseEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: CaseChain) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/zh/industry/inspection_record_graph.py b/hyperextract/templates/zh/industry/inspection_record_graph.pynew file mode 100644index 0000000..494026f--- /dev/null+++ b/hyperextract/templates/zh/industry/inspection_record_graph.py@@ -0,0 +1,171 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema 定义+# ==============================================================================+++class InspectionEntity(BaseModel):+ """+ 巡检实体,包括设备和巡检项。+ """++ name: str = Field(description="实体名称(如:数控加工中心、机械臂系统、电机运行状态、轴承温度检查等)。")+ category: str = Field(+ description='类别:设备、巡检项。'+ )+ description: Optional[str] = Field(+ None,+ description="对该实体的描述。",+ )+++class InspectionHierarchy(BaseModel):+ """+ 巡检实体之间的层级关系。+ """++ source: str = Field(description="父实体(整体/设备)名称。")+ target: str = Field(description="子实体(巡检项/部分)名称。")+ relation_type: str = Field(+ description='关系类型:属于、子类。'+ )+ details: Optional[str] = Field(+ None,+ description="关系详细说明。",+ )+++# ==============================================================================+# 2. 提示词 (Prompts)+# ==============================================================================++_PROMPT = (+ "你是工业设备巡检分析专家。从巡检记录文档中提取设备和巡检项,构建巡检层级结构。\n\n"+ "规则:\n"+ "- 识别大设备(如数控加工中心、机械臂系统、物料输送系统等)。\n"+ "- 识别每个设备下的巡检项(如电机运行状态、轴承温度、冷却液位等)。\n"+ "- 建立巡检项与设备之间的从属关系。\n"+)++_NODE_PROMPT = (+ "你是工业设备巡检分析专家。从巡检记录文档中提取所有实体(节点)。\n\n"+ "提取规则:\n"+ "- 识别设备名称(大类)。\n"+ "- 识别巡检项名称(具体检查点)。\n"+ "- 为每个实体指定类别(设备/巡检项)。\n"+ "- 不建立实体之间的关系。\n"+)++_EDGE_PROMPT = (+ "你是工业设备巡检分析专家。在获得实体清单的基础上,提取实体之间的层级关系(边)。\n\n"+ "提取规则:\n"+ "- 识别巡检项与设备之间的从属关系。\n"+ "- 例如:电机运行状态 属于 数控加工中心。\n"+ "- 仅在提供的实体列表中建立关系。\n"+)++# ==============================================================================+# 3. 模板类+# ==============================================================================+++class InspectionRecordGraph(AutoGraph[InspectionEntity, InspectionHierarchy]):+ """+ 适用文档: 巡检记录本、设备运行记录、巡检日报、设备点检表。++ 模板用于从巡检记录中提取设备和巡检项,构建巡检层级结构。+ 识别设备与巡检项之间的从属关系(Part-Of)。++ 使用示例:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> inspection = InspectionRecordGraph(llm_client=llm, embedder=embedder)+ >>> doc = "2024年3月15日,对A生产线进行日常巡检。数控加工中心:电机运行正常..."+ >>> inspection.feed_text(doc)+ >>> inspection.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ 初始化巡检层级图谱模板。++ Args:+ llm_client (BaseChatModel): 用于实体和关系提取的 LLM。+ embedder (Embeddings): 用于去重的嵌入模型。+ extraction_mode (str): "one_stage" 或 "two_stage"。默认为 "two_stage"。+ chunk_size (int): 每个分块的最大字符数。+ chunk_overlap (int): 分块之间的重叠。+ max_workers (int): 并行处理工作线程数。+ verbose (bool): 是否启用进度日志。+ **kwargs: AutoGraph 的其他参数。+ """+ super().__init__(+ node_schema=InspectionEntity,+ edge_schema=InspectionHierarchy,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ 使用 OntoSight 可视化巡检层级图。++ Args:+ top_k_nodes_for_search (int): 检索的实体数。默认 3。+ top_k_edges_for_search (int): 检索的关系数。默认 3。+ top_k_nodes_for_chat (int): 对话上下文中的实体数。默认 3。+ top_k_edges_for_chat (int): 对话上下文中的关系数。默认 3。+ """++ def node_label_extractor(node: InspectionEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: InspectionHierarchy) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/zh/industry/operating_mode_graph.py b/hyperextract/templates/zh/industry/operating_mode_graph.pynew file mode 100644index 0000000..43d5e65--- /dev/null+++ b/hyperextract/templates/zh/industry/operating_mode_graph.py@@ -0,0 +1,184 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema 定义+# ==============================================================================+++class ModeEntity(BaseModel):+ """+ 工况实体,包括工况和条件。+ """++ name: str = Field(description="实体名称(如:自动运行模式、手动调试模式、待机模式、紧急停止模式、按下启动按钮、按下停止按钮、发生故障等)。")+ category: str = Field(+ description='类别:工况、条件。工况如自动运行、手动调试、待机等;条件如启动按钮、停止按钮、故障信号等。'+ )+ description: Optional[str] = Field(+ None,+ description="对该实体的描述。",+ )+ load_range: Optional[str] = Field(+ None,+ description="负荷范围(如:0-50%、50-80%、80-100%等),仅对工况类别有效。",+ )+++class ModeTransition(BaseModel):+ """+ 工况与工况之间的切换关系,或条件与工况之间的触发关系。+ """++ source: str = Field(description="源实体名称(工况或条件)。")+ target: str = Field(description="目标实体名称(工况或条件)。")+ relation_type: str = Field(+ description='关系类型:切换到、触发。'+ )+ transition_condition: Optional[str] = Field(+ None,+ description="切换条件(如:按下启动按钮、按下停止按钮、发生故障等)。",+ )+ transition_procedure: Optional[str] = Field(+ None,+ description="切换步骤。",+ )+++# ==============================================================================+# 2. 提示词 (Prompts)+# ==============================================================================++_PROMPT = (+ "你是工业设备工况分析专家。从运行规程文档中提取工况和条件实体,以及它们之间的关系。\n\n"+ "规则:\n"+ "- 识别各种运行模式(工况),如自动运行、手动调试、待机、紧急停止等。\n"+ "- 识别各种触发条件,如按下启动按钮、按下停止按钮、发生故障等。\n"+ "- 识别每种工况的适用条件和负荷范围。\n"+ "- 提取工况之间的切换关系(切换到)。\n"+ "- 提取条件触发工况的关系(触发)。\n"+)++_NODE_PROMPT = (+ "你是工业设备工况分析专家。从运行规程文档中提取所有实体(节点)。\n\n"+ "提取规则:\n"+ "- 识别工况名称(如自动运行模式、手动调试模式、待机模式、紧急停止模式等)。\n"+ "- 识别条件名称(如按下启动按钮、按下停止按钮、发生故障、恢复正常等)。\n"+ "- 为每个实体指定类别(工况/条件)。\n"+ "- 记录每种工况的负荷范围。\n"+ "- 不建立实体之间的关系。\n"+)++_EDGE_PROMPT = (+ "你是工业设备工况分析专家。在获得实体清单的基础上,提取工况与条件之间的关系(边)。\n\n"+ "提取规则:\n"+ "- 识别工况之间的切换关系(源工况 切换到 目标工况)。\n"+ "- 识别条件对工况的触发关系(条件 触发 目标工况)。\n"+ "- 关系类型使用 切换到 或 触发。\n"+ "- 仅在提供的实体列表中建立关系。\n"+)++# ==============================================================================+# 3. 模板类+# ==============================================================================+++class OperatingModeGraph(AutoGraph[ModeEntity, ModeTransition]):+ """+ 适用文档: 运行规程、设备操作手册、工况切换说明书。++ 模板用于从运行规程中提取工况类型和切换条件。+ 识别不同工况之间的切换条件和步骤。++ 使用示例:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> mode = OperatingModeGraph(llm_client=llm, embedder=embedder)+ >>> doc = "设备有两种运行模式:自动模式和手动模式。按下启动按钮从待机切换到自动模式..."+ >>> mode.feed_text(doc)+ >>> mode.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ 初始化工况切换图谱模板。++ Args:+ llm_client (BaseChatModel): 用于实体和关系提取的 LLM。+ embedder (Embeddings): 用于去重的嵌入模型。+ extraction_mode (str): "one_stage" 或 "two_stage"。默认为 "two_stage"。+ chunk_size (int): 每个分块的最大字符数。+ chunk_overlap (int): 分块之间的重叠。+ max_workers (int): 并行处理工作线程数。+ verbose (bool): 是否启用进度日志。+ **kwargs: AutoGraph 的其他参数。+ """+ super().__init__(+ node_schema=ModeEntity,+ edge_schema=ModeTransition,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ 使用 OntoSight 可视化工况切换图。++ Args:+ top_k_nodes_for_search (int): 检索的实体数。默认 3。+ top_k_edges_for_search (int): 检索的关系数。默认 3。+ top_k_nodes_for_chat (int): 对话上下文中的实体数。默认 3。+ top_k_edges_for_chat (int): 对话上下文中的关系数。默认 3。+ """++ def node_label_extractor(node: ModeEntity) -> str:+ load = f" [{node.load_range}]" if node.load_range else ""+ return f"{node.name} ({node.category}){load}"++ def edge_label_extractor(edge: ModeTransition) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/zh/industry/operation_flow_graph.py b/hyperextract/templates/zh/industry/operation_flow_graph.pynew file mode 100644index 0000000..7da1a67--- /dev/null+++ b/hyperextract/templates/zh/industry/operation_flow_graph.py@@ -0,0 +1,182 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema 定义+# ==============================================================================+++class OperationEntity(BaseModel):+ """+ 操作流程实体,包括步骤、状态、设备等。+ """++ name: str = Field(description="实体具体名称(如:开启辅助电源、启动液压系统、检查状态等)。")+ category: str = Field(+ description='类别:步骤、状态、设备。'+ )+ description: Optional[str] = Field(+ None,+ description="对该实体的详细操作描述。",+ )+ expected_result: Optional[str] = Field(+ None,+ description="执行该步骤后的预期结果。",+ )+++class OperationTransition(BaseModel):+ """+ 操作步骤之间的流转关系。+ """++ source: str = Field(description="当前步骤名称。")+ target: str = Field(description="下一步骤名称。")+ relation_type: str = Field(+ description='关系类型:下一步、触发、导致等。'+ )+ trigger_condition: Optional[str] = Field(+ None,+ description="触发下一步骤的条件。",+ )+ state_change: Optional[str] = Field(+ None,+ description="状态变化描述。",+ )+++# ==============================================================================+# 2. 提示词 (Prompts)+# ==============================================================================++_PROMPT = (+ "你是工业操作流程分析专家。从运行规程文档中提取操作步骤、设备状态和预期结果。\n\n"+ "规则:\n"+ "- 识别各个操作步骤和执行顺序。\n"+ "- 记录每一步骤的详细操作内容。\n"+ "- 提取设备状态变化和预期结果。\n"+ "- 建立步骤之间的流转关系。\n"+)++_NODE_PROMPT = (+ "你是工业操作流程分析专家。从运行规程文档中提取所有实体(节点)。\n\n"+ "提取规则:\n"+ "- 识别操作步骤名称。\n"+ "- 识别设备状态名称。\n"+ "- 识别相关设备名称。\n"+ "- 记录每一步骤的操作描述和预期结果。\n"+ "- 不建立步骤之间的关系。\n"+)++_EDGE_PROMPT = (+ "你是工业操作流程分析专家。在获得实体清单的基础上,提取操作步骤之间的流转关系(边)。\n\n"+ "提取规则:\n"+ "- 识别步骤的执行顺序(当前步骤→下一步骤)。\n"+ "- 提取触发下一步骤的条件。\n"+ "- 记录设备状态的变化。\n"+ "- 仅在提供的实体列表中建立关系。\n"+)++# ==============================================================================+# 3. 模板类+# ==============================================================================+++class OperationFlowGraph(AutoGraph[OperationEntity, OperationTransition]):+ """+ 适用文档: 运行规程、启停操作票、设备操作手册、安全操作规程。++ 模板用于从运行规程中提取操作步骤、设备状态和预期结果。+ 识别操作流程中的步骤顺序和状态变化,为操作培训和安全控制提供参考。++ 使用示例:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> operation = OperationFlowGraph(llm_client=llm, embedder=embedder)+ >>> doc = "开机流程:1. 检查电源是否正常;2. 开启控制柜主开关;3. 启动电机;4. 确认运行状态。电源正常后开启主开关,主开关合闸后启动电机。"+ >>> operation.feed_text(doc)+ >>> operation.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ 初始化操作流程图谱模板。++ Args:+ llm_client (BaseChatModel): 用于实体和关系提取的 LLM。+ embedder (Embeddings): 用于去重的嵌入模型。+ extraction_mode (str): "one_stage" 或 "two_stage"。默认为 "two_stage"。+ chunk_size (int): 每个分块的最大字符数。+ chunk_overlap (int): 分块之间的重叠。+ max_workers (int): 并行处理工作线程数。+ verbose (bool): 是否启用进度日志。+ **kwargs: AutoGraph 的其他参数。+ """+ super().__init__(+ node_schema=OperationEntity,+ edge_schema=OperationTransition,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ 使用 OntoSight 可视化操作流程图。++ Args:+ top_k_nodes_for_search (int): 检索的实体数。默认 3。+ top_k_edges_for_search (int): 检索的关系数。默认 3。+ top_k_nodes_for_chat (int): 对话上下文中的实体数。默认 3。+ top_k_edges_for_chat (int): 对话上下文中的关系数。默认 3。+ """++ def node_label_extractor(node: OperationEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: OperationTransition) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/zh/industry/safety_control_graph.py b/hyperextract/templates/zh/industry/safety_control_graph.pynew file mode 100644index 0000000..96de2ac--- /dev/null+++ b/hyperextract/templates/zh/industry/safety_control_graph.py@@ -0,0 +1,182 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema 定义+# ==============================================================================+++class SafetyEntity(BaseModel):+ """+ 安全管控实体,包括危险源、风险点、管控措施、责任人等。+ """++ name: str = Field(description="实体名称(如:高温高压设备、触电风险、佩戴防护用品、安全主管等)。")+ category: str = Field(+ description='类别:危险源、风险点、管控措施、责任人。'+ )+ description: Optional[str] = Field(+ None,+ description="对该实体的描述。",+ )+++class SafetyRelation(BaseModel):+ """+ 安全管控关系。+ """++ source: str = Field(description="源实体名称(危险源或风险点)。")+ target: str = Field(description="目标实体名称(管控措施或责任人)。")+ relation_type: str = Field(+ description='关系类型:管控、负责等。'+ )+ control_measure: Optional[str] = Field(+ None,+ description="管控措施具体内容。",+ )+ responsible_person: Optional[str] = Field(+ None,+ description="责任人姓名或部门。",+ )+++# ==============================================================================+# 2. 提示词 (Prompts)+# ==============================================================================++_PROMPT = (+ "你是工业安全管理分析专家。从安全规程文档中提取危险源、风险点和管控措施,构建安全管控关系。\n\n"+ "规则:\n"+ "- 识别危险源(如高温高压设备、电气设备、化学品等)。\n"+ "- 识别风险点(如触电风险、烫伤风险、机械伤害等)。\n"+ "- 识别管控措施(如佩戴防护用品、定期检修、通风换气等)。\n"+ "- 识别责任人(如安全主管、设备负责人等)。\n"+ "- 建立从危险源/风险点到管控措施/责任人的关系。\n"+)++_NODE_PROMPT = (+ "你是工业安全管理分析专家。从安全规程文档中提取所有实体(节点)。\n\n"+ "提取规则:\n"+ "- 识别危险源名称。\n"+ "- 识别风险点名称。\n"+ "- 识别管控措施名称。\n"+ "- 识别责任人名称。\n"+ "- 为每个实体指定类别(危险源/风险点/管控措施/责任人)。\n"+ "- 不建立实体之间的关系。\n"+)++_EDGE_PROMPT = (+ "你是工业安全管理分析专家。在获得实体清单的基础上,提取安全管控关系(边)。\n\n"+ "提取规则:\n"+ "- 识别从危险源到管控措施的关联。\n"+ "- 识别从风险点到管控措施的关联。\n"+ "- 识别从管控措施到责任人的关联。\n"+ "- 记录管控措施的具体内容。\n"+ "- 记录责任人信息。\n"+ "- 仅在提供的实体列表中建立关系。\n"+)++# ==============================================================================+# 3. 模板类+# ==============================================================================+++class SafetyControlGraph(AutoGraph[SafetyEntity, SafetyRelation]):+ """+ 适用文档: 安全规程、安全风险评估报告、职业健康安全手册。++ 模板用于从安全规程中提取危险源、风险点和管控措施,构建安全管控关系。+ 通过 category 区分异质节点,识别安全风险与管控责任的对应关系。++ 使用示例:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> safety = SafetyControlGraph(llm_client=llm, embedder=embedder)+ >>> doc = "高温设备存在烫伤风险,需佩戴防护手套。由设备负责人负责监督检查..."+ >>> safety.feed_text(doc)+ >>> safety.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ 初始化安全管控图谱模板。++ Args:+ llm_client (BaseChatModel): 用于实体和关系提取的 LLM。+ embedder (Embeddings): 用于去重的嵌入模型。+ extraction_mode (str): "one_stage" 或 "two_stage"。默认为 "two_stage"。+ chunk_size (int): 每个分块的最大字符数。+ chunk_overlap (int): 分块之间的重叠。+ max_workers (int): 并行处理工作线程数。+ verbose (bool): 是否启用进度日志。+ **kwargs: AutoGraph 的其他参数。+ """+ super().__init__(+ node_schema=SafetyEntity,+ edge_schema=SafetyRelation,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ 使用 OntoSight 可视化安全管控图。++ Args:+ top_k_nodes_for_search (int): 检索的实体数。默认 3。+ top_k_edges_for_search (int): 检索的关系数。默认 3。+ top_k_nodes_for_chat (int): 对话上下文中的实体数。默认 3。+ top_k_edges_for_chat (int): 对话上下文中的关系数。默认 3。+ """++ def node_label_extractor(node: SafetyEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: SafetyRelation) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/hyperextract/templates/zh/industry/system_topology_graph.py b/hyperextract/templates/zh/industry/system_topology_graph.pynew file mode 100644index 0000000..12707e1--- /dev/null+++ b/hyperextract/templates/zh/industry/system_topology_graph.py@@ -0,0 +1,177 @@+from typing import Optional, Any+from pydantic import BaseModel, Field+from langchain_core.language_models.chat_models import BaseChatModel+from langchain_core.embeddings import Embeddings+from hyperextract.types import AutoGraph++# ==============================================================================+# 1. Schema 定义+# ==============================================================================+++class SystemEntity(BaseModel):+ """+ 系统拓扑实体,包括厂区、系统、子系统、设备等。+ """++ name: str = Field(description="实体名称(如:A工厂、制造车间A、数控加工系统、冷却系统等)。")+ category: str = Field(+ description='类别:厂区、系统、子系统、设备。'+ )+ function: Optional[str] = Field(+ None,+ description="功能描述。",+ )+ capacity: Optional[str] = Field(+ None,+ description="容量或规模。",+ )+++class SystemHierarchy(BaseModel):+ """+ 系统层级关系。+ """++ source: str = Field(description="上级实体名称(厂区或系统)。")+ target: str = Field(description="下级实体名称(系统或子系统或设备)。")+ relation_type: str = Field(+ description='关系类型:包含。'+ )+++# ==============================================================================+# 2. 提示词 (Prompts)+# ==============================================================================++_PROMPT = (+ "你是工业系统架构分析专家。从系统说明书中提取厂区、系统、子系统和设备的层级关系。\n\n"+ "规则:\n"+ "- 识别厂区(如A工厂、B工厂)。\n"+ "- 识别生产系统(如制造车间、加工车间)。\n"+ "- 识别子系统(如数控加工系统、冷却系统、物料输送系统)。\n"+ "- 识别具体设备(如数控加工中心、机械臂、泵等)。\n"+ "- 建立上下级的层级包含关系。\n"+)++_NODE_PROMPT = (+ "你是工业系统架构分析专家。从系统说明书中提取所有实体(节点)。\n\n"+ "提取规则:\n"+ "- 识别厂区名称。\n"+ "- 识别生产系统名称。\n"+ "- 识别子系统名称。\n"+ "- 识别具体设备名称。\n"+ "- 为每个实体指定类别(厂区/系统/子系统/设备)。\n"+ "- 不建立实体之间的关系。\n"+)++_EDGE_PROMPT = (+ "你是工业系统架构分析专家。在获得实体清单的基础上,提取系统层级关系(边)。\n\n"+ "提取规则:\n"+ "- 识别厂区与系统之间的包含关系。\n"+ "- 识别系统与子系统之间的包含关系。\n"+ "- 识别子系统与设备之间的包含关系。\n"+ "- 记录层级类型。\n"+ "- 仅在提供的实体列表中建立关系。\n"+)++# ==============================================================================+# 3. 模板类+# ==============================================================================+++class SystemTopologyGraph(AutoGraph[SystemEntity, SystemHierarchy]):+ """+ 适用文档: 系统说明书、工厂布局图、系统架构文档。++ 模板用于从系统说明书中提取厂区、系统、子系统和设备的层级关系。+ 构建完整的工厂系统架构视图。++ 使用示例:+ >>> from langchain_openai import ChatOpenAI, OpenAIEmbeddings+ >>> llm = ChatOpenAI(model="gpt-4o")+ >>> embedder = OpenAIEmbeddings()+ >>> topology = SystemTopologyGraph(llm_client=llm, embedder=embedder)+ >>> doc = "A工厂包含制造车间A,制造车间A包括数控加工系统和物料输送系统..."+ >>> topology.feed_text(doc)+ >>> topology.show()+ """++ def __init__(+ self,+ llm_client: BaseChatModel,+ embedder: Embeddings,+ *,+ extraction_mode: str = "two_stage",+ chunk_size: int = 2048,+ chunk_overlap: int = 256,+ max_workers: int = 10,+ verbose: bool = False,+ **kwargs: Any,+ ):+ """+ 初始化系统拓扑图谱模板。++ Args:+ llm_client (BaseChatModel): 用于实体和关系提取的 LLM。+ embedder (Embeddings): 用于去重的嵌入模型。+ extraction_mode (str): "one_stage" 或 "two_stage"。默认为 "two_stage"。+ chunk_size (int): 每个分块的最大字符数。+ chunk_overlap (int): 分块之间的重叠。+ max_workers (int): 并行处理工作线程数。+ verbose (bool): 是否启用进度日志。+ **kwargs: AutoGraph 的其他参数。+ """+ super().__init__(+ node_schema=SystemEntity,+ edge_schema=SystemHierarchy,+ node_key_extractor=lambda x: x.name.strip().lower(),+ edge_key_extractor=lambda x: (+ f"{x.source.strip()}--({x.relation_type})-->{x.target.strip()}"+ ),+ nodes_in_edge_extractor=lambda x: (x.source.strip(), x.target.strip()),+ llm_client=llm_client,+ embedder=embedder,+ extraction_mode=extraction_mode,+ chunk_size=chunk_size,+ chunk_overlap=chunk_overlap,+ max_workers=max_workers,+ verbose=verbose,+ prompt=_PROMPT,+ prompt_for_node_extraction=_NODE_PROMPT,+ prompt_for_edge_extraction=_EDGE_PROMPT,+ **kwargs,+ )++ def show(+ self,+ *,+ top_k_nodes_for_search: int = 3,+ top_k_edges_for_search: int = 3,+ top_k_nodes_for_chat: int = 3,+ top_k_edges_for_chat: int = 3,+ ) -> None:+ """+ 使用 OntoSight 可视化系统拓扑图。++ Args:+ top_k_nodes_for_search (int): 检索的实体数。默认 3。+ top_k_edges_for_search (int): 检索的关系数。默认 3。+ top_k_nodes_for_chat (int): 对话上下文中的实体数。默认 3。+ top_k_edges_for_chat (int): 对话上下文中的关系数。默认 3。+ """++ def node_label_extractor(node: SystemEntity) -> str:+ return f"{node.name} ({node.category})"++ def edge_label_extractor(edge: SystemHierarchy) -> str:+ return edge.relation_type++ super().show(+ node_label_extractor=node_label_extractor,+ edge_label_extractor=edge_label_extractor,+ top_k_nodes_for_search=top_k_nodes_for_search,+ top_k_edges_for_search=top_k_edges_for_search,+ top_k_nodes_for_chat=top_k_nodes_for_chat,+ top_k_edges_for_chat=top_k_edges_for_chat,+ )diff --git a/tests/fixtures/test_samples/en/industry/emergency_response.md b/tests/fixtures/test_samples/en/industry/emergency_response.mdnew file mode 100644index 0000000..98f3117--- /dev/null+++ b/tests/fixtures/test_samples/en/industry/emergency_response.md@@ -0,0 +1,157 @@+# Automated Assembly Line A1 Emergency Response Plan++**Document Number**: EP-2024-001+**Version**: v2.0+**Preparation Date**: January 2024+**Scope of Application**: Automated Assembly Line A1 and surrounding areas++---++## 1. General Provisions++### 1.1 Purpose++This plan is formulated to effectively prevent, timely control and eliminate hazards from emergencies of Automated Assembly Line A1, minimize casualties and property losses caused by emergencies, and ensure equipment safety and smooth production.++### 1.2 Scope of Application++This plan applies to emergency response for various emergencies occurring in Automated Assembly Line A1, including fire, leakage, power outage, equipment failure, personnel injury and other accidents.++---++## 2. Emergency Response Organization++### 2.1 Emergency Command Center++| Role | Name | Responsibility |+|------|------|----------------|+| Commander-in-Chief | Manager Wang | Fully responsible for emergency response |+| Deputy Commander | Supervisor Li | Assist commander, responsible for on-site command |+| Team Member | Zhang Maintenance | Equipment emergency response |+| Team Member | Security Personnel | On-site security and evacuation |++### 2.2 Emergency Response Departments++| Department | Responsibility |+|------------|----------------|+| Security Department | On-site security, personnel evacuation, safety guard |+| Equipment Department | Equipment emergency response, fault troubleshooting |+| First Aid Department | On-site first aid, medical rescue |+| Logistics Department | Material support, communication |++---++## 3. Emergency Response Procedures++### 3.1 Fire Emergency Response++**Trigger Condition**: Fire detected or fire alarm++**Response Procedure**:++| Step | Response Action | Department | Time Limit | Success Criterion----------------|------------|------------| |+|------|------------------|+| 1 | Immediately press alarm button upon discovering fire | On-duty staff | Immediately | Alarm signal sent |+| 2 | Call internal alarm phone to report fire | On-duty staff | Within 1 min | Report successful |+| 3 | Activate fire broadcast to notify personnel evacuation | Security Department | Within 2 min | Broadcast covers entire area |+| 4 | Open fire hydrants and use fire extinguishers for initial firefighting | Equipment Department | Within 3 min | Fire controlled |+| 5 | Turn off power and gas valves in fire area | Equipment Department | Within 2 min | Power cut off |+| 6 | Evacuate production area personnel to safe assembly point | Security Department | Within 5 min | All personnel evacuated |+| 7 | Call 119 to request fire brigade support | Security Department | Immediately | Alarm successful |+| 8 | Welcome fire brigade and provide on-site information | Security Department | Within 10 min | Fire brigade arrived |++### 3.2 Chemical Leakage Emergency Response++**Trigger Condition**: Chemical leakage detected++**Response Procedure**:++| Step | Response Action | Department | Time Limit | Success Criterion |+|------|----------------|------------|------------|------------------|+| 1 | Stop operation immediately, close leakage source | On-duty staff | Immediately | Leakage source closed |+| 2 | Activate ventilation equipment to dilute leakage concentration | Equipment Department | Within 2 min | Ventilation activated |+| 3 | Use adsorption materials to contain leakage | Equipment Department | Within 3 min | Leakage contained |+| 4 | Evacuate surrounding personnel, set up警戒区域 | Security Department | Within 5 min | Personnel evacuated |+| 5 | Call emergency phone to request medical support | Security Department | Immediately | Medical support requested |+| 6 | Clean up leakage, resume production | Equipment Department | Within 30 min | Site cleaned up |++### 3.3 Power Outage Emergency Response++**Trigger Condition**: Sudden power outage++**Response Procedure**:++| Step | Response Action | Department | Time Limit | Success Criterion |+|------|----------------|------------|------------|------------------|+| 1 | Immediately start backup power | Equipment Department | Within 10 sec | Backup power started |+| 2 | Activate emergency lighting to ensure personnel safety evacuation | Equipment Department | Within 30 sec | Emergency lighting activated |+| 3 | Shut down main equipment to prevent damage | Equipment Department | Within 1 min | Equipment shut down |+| 4 | Personnel evacuate production area in order | Security Department | Within 3 min | Personnel evacuated |+| 5 | Investigate cause of power outage, assess recovery time | Equipment Department | Within 10 min | Cause identified |+| 6 | After power restored, restart equipment in sequence | Equipment Department | Within 20 min | Equipment restarted |++### 3.4 Equipment Failure Emergency Response++**Trigger Condition**: Critical equipment serious failure++**Response Procedure**:++| Step | Response Action | Department | Time Limit | Success Criterion |+|------|----------------|------------|------------|------------------|+| 1 | Press emergency stop button, stop equipment operation | Operator | Immediately | Equipment stopped |+| 2 | Cut off equipment power to prevent failure expansion | Operator | Immediately | Power cut off |+| 3 | Report equipment failure situation | Operator | Within 1 min | Report sent |+| 4 | Maintenance personnel arrive for fault diagnosis | Equipment Department | Within 15 min | Diagnosis completed |+| 5 | Assess failure degree, formulate repair plan | Equipment Department | Within 30 min | Plan formulated |+| 6 | Implement repair, resume production | Equipment Department | Within 2 hours | Production resumed |++### 3.5 Personnel Injury Emergency Response++**Trigger Condition**: Personnel injury accident occurs++**Response Procedure**:++| Step | Response Action | Department | Time Limit | Success Criterion |+|------|----------------|------------|------------|------------------|+| 1 | Stop operation immediately, ensure site safety | On-duty staff | Immediately | Site secured |+| 2 | Check injured person's condition | On-duty staff | Immediately | Condition assessed |+| 3 | Perform on-site first aid | First Aid Department | Within 5 min | First aid completed |+| 4 | Call 120 emergency phone | First Aid Department | Immediately | Emergency call made |+| 5 | Arrange personnel to welcome ambulance | First Aid Department | Within 10 min | Ambulance received |+| 6 | Protect site, cooperate with investigation | Security Department | Ongoing | Site protected |++---++## 4. Emergency Support++### 4.1 Material Support++- Fire fighting equipment: Fire extinguishers, fire hydrants, fire broadcast+- First aid supplies: First aid kits, stretchers, protective clothing+- Emergency lighting: Emergency lights, flashlights+- Communication equipment: Walkie-talkies, mobile phones++### 4.2 Training and Drills++- Conduct emergency drills quarterly+- New employee training includes emergency content+- Organize comprehensive emergency drill annually++---++## 5. Plan Management++### 5.1 Plan Revision++This plan is revised annually, and should be revised promptly if major changes occur.++### 5.2 Plan Interpretation++This plan is interpreted by the Safety and Environmental Protection Department.++---++**Prepared by**: Safety and Environmental Protection Department+**Reviewed by**: Production Department+**Approved by**: General Manager+**Effective Date**: January 15, 2024diff --git a/tests/fixtures/test_samples/en/industry/equipment_topology.md b/tests/fixtures/test_samples/en/industry/equipment_topology.mdnew file mode 100644index 0000000..ca94d07--- /dev/null+++ b/tests/fixtures/test_samples/en/industry/equipment_topology.md@@ -0,0 +1,141 @@+# Advanced Manufacturing Line: Automated Assembly System Technical Documentation++**Document Type**: Equipment Topology Specification+**System Version**: v3.2+**Last Updated**: 2024+**Department**: Engineering & Maintenance++---++## 1. System Overview++The **Automated Assembly Line A1** is a high-precision manufacturing system designed for electronic component assembly. The system integrates multiple equipment units including CNC machining centers, robotic arms, automated guided vehicles (AGVs), and quality inspection stations. This document provides detailed equipment topology information for maintenance planning and system optimization.++---++## 2. Equipment List++### 2.1 Core Production Equipment++| Equipment ID | Equipment Name | Type | Location | Status | Manufacturer | Specification |+|--------------|----------------|------|----------|--------|--------------|---------------|+| M-001 | CNC Machining Center Alpha | Main Unit | Production Hall A, Zone 1 | Running | TechMach Industries | TM-5000X |+| M-002 | CNC Machining Center Beta | Main Unit | Production Hall A, Zone 1 | Running | TechMach Industries | TM-5000X |+| S-001 | Industrial Robot Arm R1 | Auxiliary | Production Hall A, Zone 2 | Running | AutoBot Robotics | AR-200 |+| S-002 | Industrial Robot Arm R2 | Auxiliary | Production Hall A, Zone 2 | Running | AutoBot Robotics | AR-200 |+| S-003 | Industrial Robot Arm R3 | Auxiliary | Production Hall A, Zone 3 | Standby | AutoBot Robotics | AR-150 |+| P-001 | Cooling Pump Unit A | Auxiliary | Production Hall A, Basement | Running | FlowTech Pumps | CP-300 |+| P-002 | Cooling Pump Unit B | Auxiliary | Production Hall A, Basement | Running | FlowTech Pumps | CP-300 |+| V-001 | Main Control Valve | Valve | Production Hall A, Zone 1 | Running | ValveMaster Corp | CV-500 |+| V-002 | Safety Release Valve | Valve | Production Hall A, Zone 2 | Running | ValveMaster Corp | CV-200 |+| MTR-001 | Drive Motor M1 | Motor | Production Hall A, Zone 1 | Running | PowerDrive Ltd | DM-750 |+| MTR-002 | Drive Motor M2 | Motor | Production Hall A, Zone 1 | Running | PowerDrive Ltd | DM-750 |++### 2.2 Material Handling Equipment++| Equipment ID | Equipment Name | Type | Location | Status | Manufacturer | Specification |+|--------------|----------------|------|----------|--------|--------------|---------------|+| AGV-001 | Automated Guided Vehicle 1 | System | Production Hall A | Running | LogiMove AGV | LM-1000 |+| AGV-002 | Automated Guided Vehicle 2 | System | Production Hall A | Running | LogiMove AGV | LM-1000 |+| CV-001 | Conveyor Belt System | System | Production Hall A, Zone 1-4 | Running | ConvTech | CT-500 |++### 2.3 Monitoring & Control Equipment++| Equipment ID | Equipment Name | Type | Location | Status | Manufacturer | Specification |+|--------------|----------------|------|----------|--------|--------------|---------------|+| INS-001 | Temperature Sensor T1 | Instrument | Production Hall A, Zone 1 | Running | SensorPro | ST-100 |+| INS-002 | Pressure Sensor P1 | Instrument | Production Hall A, Zone 1 | Running | SensorPro | SP-200 |+| INS-003 | Flow Sensor F1 | Instrument | Production Hall A, Zone 2 | Running | SensorPro | SF-150 |+| CTR-001 | Main Control Cabinet | System | Production Hall A, Control Room | Running | ControlMaster | MC-800 |+| CTR-001 | Human-Machine Interface | System | Production Hall A, Control Room | Running | InterfaceTech | HMI-700 |++---++## 3. Equipment Topology Relationships++### 3.1 Material Flow Path++The primary material flow follows this sequence:++**Raw Material Storage → CNC Machining Center Alpha (M-001) → CNC Machining Center Beta (M-002) → Quality Inspection Station → Finished Product Storage**++- Raw materials enter the production line through the Conveyor Belt System (CV-001)+- M-001 performs initial machining, then transfers workpieces to M-002+- M-002 completes final machining and outputs to quality inspection+- AGV-001 transports finished products to storage area++### 3.2 Energy Transmission System++**Power Supply → Main Control Cabinet (CTR-001) → Drive Motors (MTR-001, MTR-002) → CNC Machining Centers (M-001, M-002)**++- Main power supply provides 380V three-phase power to CTR-001+- CTR-001 distributes power to individual drive motors+- MTR-001 drives M-001 spindle rotation+- MTR-002 drives M-002 spindle rotation++### 3.3 Control Signal Network++**Human-Machine Interface (CTR-002) → Main Control Cabinet (CTR-001) → Robot Arms (S-001, S-002, S-003) → CNC Machining Centers**++- HMI serves as the primary operator interface+- CTR-001 processes commands and sends control signals+- S-001 and S-002 perform workpiece loading/unloading+- S-003 serves as backup for S-002++### 3.4 Cooling System Circuit++**Cooling Pump Unit A (P-001) → CNC Machining Center Alpha (M-001) → Cooling Pump Unit A (Return)**+**Cooling Pump Unit B (P-002) → CNC Machining Center Beta (M-002) → Cooling Pump Unit B (Return)**++- P-001 circulates cooling fluid through M-001+- P-002 circulates cooling fluid through M-002+- Main Control Valve (V-001) regulates flow to M-001+- Safety Release Valve (V-002) provides overpressure protection++### 3.5 Monitoring & Feedback Loops++**Temperature Sensor T1 (INS-001) → Main Control Cabinet (CTR-001) → Cooling Pump Unit A (P-001)**++- INS-001 monitors M-001 operating temperature+- CTR-001 receives temperature data and adjusts P-001 speed+- Closed-loop control maintains temperature within acceptable range++**Pressure Sensor P1 (INS-002) → Main Control Cabinet (CTR-001) → Safety Release Valve (V-002)**++- INS-002 monitors hydraulic system pressure+- When pressure exceeds threshold, V-002 automatically opens+- Emergency relief protects system from overpressure damage++---++## 4. System Interconnections Summary++| Source Equipment | Target Equipment | Connection Type | Description |+|------------------|------------------|-----------------|-------------|+| CV-001 | M-001 | Material Handling | workpiece transfer |+| M-001 | M-002 | Material Handling | sequential processing |+| M-002 | AGV-001 | Material Handling | finished product transport |+| CTR-001 | MTR-001 | Electrical Power | spindle drive power |+| CTR-001 | MTR-002 | Electrical Power | spindle drive power |+| CTR-001 | S-001 | Control Signal | robot coordination |+| CTR-001 | S-002 | Control Signal | robot coordination |+| CTR-001 | S-003 | Control Signal | backup robot control |+| P-001 | M-001 | Cooling Circuit | cooling fluid supply |+| P-002 | M-002 | Cooling Circuit | cooling fluid supply |+| V-001 | M-001 | Cooling Circuit | flow regulation |+| V-002 | P-002 | Cooling Circuit | overpressure protection |+| INS-001 | CTR-001 | Instrument Signal | temperature feedback |+| INS-002 | CTR-001 | Instrument Signal | pressure feedback |+| CTR-002 | CTR-001 | Control Signal | operator commands |++---++## 5. Maintenance Notes++- **Preventive Maintenance**: Replace filters on P-001 and P-002 every 3 months+- **Predictive Maintenance**: Monitor vibration data on MTR-001 and MTR-002+- **Emergency Response**: V-002 must be tested monthly to ensure proper operation++---++*For technical support, contact: [email protected]*diff --git a/tests/fixtures/test_samples/en/industry/failure_case.md b/tests/fixtures/test_samples/en/industry/failure_case.mdnew file mode 100644index 0000000..0cc36cc--- /dev/null+++ b/tests/fixtures/test_samples/en/industry/failure_case.md@@ -0,0 +1,121 @@+# Equipment Failure Case Analysis Report++**Report Number**: FA-2024-001+**Prepared Date**: March 15, 2024+**Equipment Name**: Automated Assembly Line A1 - Main Motor+**Failure Date**: January 10, 2024++---++## 1. Failure Overview++### 1.1 Equipment Information++| Item | Content |+|------|---------|+| Equipment ID | MTR-001 |+| Equipment Name | Main Motor |+| Model | DM-750 |+| Manufacturer | PowerDrive Ltd |+| Installation Location | Production Hall A, Zone 1 |+| Commissioning Date | June 2022 |++### 1.2 Failure Phenomenon++At 9:30 AM on January 10, 2024, the main motor (MTR-001) of Automated Assembly Line A1 suddenly emitted abnormal sounds during operation, accompanied by significantly increased vibration. The operator immediately pressed the emergency stop button, and the equipment stopped running.++**Specific Phenomena**:+- Motor emitted sharp metal friction sounds+- Body vibration amplitude exceeded normal values by 3 times+- Bearing temperature rapidly rose to 85°C+- Inverter showed abnormal current fluctuations++---++## 2. Failure Analysis++### 2.1 Preliminary Inspection++After the maintenance personnel arrived at the site, they conducted preliminary inspections:++1. **Visual Inspection**: No obvious damage to motor housing, no abnormal odors+2. **Insulation Test**: Winding insulation resistance normal, ruling out short circuit possibility+3. **Vibration Test**: Vibration value exceeded standard, mainly concentrated at bearing position+4. **Temperature Test**: Bearing seat temperature was high at 85°C++### 2.2 In-depth Analysis++After disassembly and inspection, the root causes of the failure were confirmed:++**Main Cause**: Severe bearing wear++- Bearing raceway showed obvious wear marks+- Rolling element surface had spalling phenomenon+- Lubricating grease deteriorated and turned black, losing its lubrication function++**Secondary Cause**: Long-term lack of preventive maintenance++- Since commissioning, the motor had never undergone bearing replacement+- Lubricating grease was not regularly replenished as required+- Operating load was consistently at high levels++---++## 3. Handling Measures++### 3.1 Emergency Response++1. Immediately stopped equipment operation and cut off power+2. Marked failure status and hung warning signs+3. Started standby motor to maintain production++### 3.2 Root Cause Treatment++1. **Bearing Replacement**: Replaced with same specification bearing (Model: 6208-2RS)+2. **Lubricating Grease Supplement**: Used high-quality lubricating grease (Model: L-XBCHA3)+3. **Bearing Seat Cleaning**: Thoroughly removed old lubricating grease and impurities+4. **Electrical Testing**: Tested winding resistance to ensure normal electrical performance++### 3.3 Treatment Results++| Item | Before Treatment | After Treatment |+|------|------------------|-----------------|+| Vibration Value | 12mm/s | 2.5mm/s |+| Bearing Temperature | 85°C | 42°C |+| Operating Current | Fluctuating ±15% | Stable ±3% |+| Noise Level | Abnormal sharp | Normal |++---++## 4. Lessons Learned++### 4.1 Lesson Summary++The insights from this failure:++1. **Lack of Preventive Maintenance**: Bearing had reached its service life without timely replacement, which was the root cause of the failure. Equipment health files should be established to track the service life of key components.++2. **Insufficient Inspection Detail**: Daily inspections failed to timely detect early symptoms of bearing abnormal sounds and increased vibration. Training for inspection personnel needs to be strengthened to improve early failure identification capabilities.++3. **Insufficient Spare Parts Management**: Insufficient standby bearing inventory extended maintenance waiting time. Spare parts inventory management should be improved to ensure adequate key spare parts.++### 4.2 Improvement Suggestions++1. **Establish Predictive Maintenance System**: Introduce vibration monitoring and temperature monitoring systems to achieve failure early warning+2. **Improve Maintenance Schedule**: Develop detailed equipment maintenance calendar and perform maintenance tasks on time+3. **Strengthen Personnel Training**: Enhance professional skills of operators and maintenance personnel+4. **Optimize Spare Parts Management**: Establish key spare parts safety stock mechanism++---++## 5. Attachments++- Failure site photos+- Bearing inspection report+- Maintenance record form++---++**Prepared by**: Zhang Maintenance+**Reviewed by**: Li Supervisor+**Approved by**: Wang Managerdiff --git a/tests/fixtures/test_samples/en/industry/inspection_record.md b/tests/fixtures/test_samples/en/industry/inspection_record.mdnew file mode 100644index 0000000..1efc492--- /dev/null+++ b/tests/fixtures/test_samples/en/industry/inspection_record.md@@ -0,0 +1,102 @@+# Equipment Daily Inspection Record++**Inspection Unit**: Equipment Maintenance Department+**Inspection Date**: March 15, 2024+**Inspection Type**: Daily Routine Inspection+**Inspector**: Zhang San++---++## 1. Inspection Overview++This inspection covered all equipment of Automated Assembly Line A1, including CNC machining centers, robotic arm systems, material handling systems, cooling systems, and electrical control systems. The inspection started at 9:00 AM and ended at 11:30 AM.++---++## 2. Inspection Items and Results++### 2.1 CNC Machining Center Inspection++| Inspection Item | Finding | Measures | Status |+|----------------|---------|----------|--------|+| Motor Operation | Running smoothly, no abnormal sounds | Normal, continue monitoring | ✅ Normal |+| Bearing Temperature | Temperature at 42°C, within normal range | Normal, keep monitoring | ✅ Normal |+| Lubrication Oil Level | Oil level normal, no leakage | Normal | ✅ Normal |+| Tool Status | Tool wear within acceptable range | Normal | ✅ Normal |+| Coolant Level | Coolant level slightly low | Top up coolant | ⚠️ Processed |++**Top up coolant**: Found low coolant level in CNC machining center M-001, immediately topped up to normal level.++### 2.2 Robotic Arm System Inspection++| Inspection Item | Finding | Measures | Status |+|----------------|---------|----------|--------|+| Robotic Arm R1 Operation | Operating normally, smooth movement | Normal | ✅ Normal |+| Robotic Arm R2 Operation | Operating normally | Normal | ✅ Normal |+| Robotic Arm R3 Status | In standby status | Normal | ✅ Normal |+| Gripper Clamping Force | Clamping force normal | Normal | ✅ Normal |+| Safety Fence | Fence closed properly | Normal | ✅ Normal |++### 2.3 Material Handling System Inspection++| Inspection Item | Finding | Measures | Status |+|----------------|---------|----------|--------|+| Conveyor Belt Operation | Running smoothly, no deviation | Normal | ✅ Normal |+| AGV-001 Status | Power at 85%, operating normally | Normal | ✅ Normal |+| AGV-002 Status | Power at 92%, operating normally | Normal | ✅ Normal |+| Sensor Status | Sensors clean, signal normal | Normal | ✅ Normal |++### 2.4 Cooling System Inspection++| Inspection Item | Finding | Measures | Status |+|----------------|---------|----------|--------|+| Cooling Pump A Operation | Operating normally, pressure stable | Normal | ✅ Normal |+| Cooling Pump B Operation | Operating normally | Normal | ✅ Normal |+| Temperature Sensor T1 | Temperature reading normal | Normal | ✅ Normal |+| Filter Status | Filter clean | Normal | ✅ Normal |++### 2.5 Electrical Control System Inspection++| Inspection Item | Finding | Measures | Status |+|----------------|---------|----------|--------|+| Main Control Cabinet | No abnormal alarms | Normal | ✅ Normal |+| Inverter Operation | Operating parameters normal | Normal | ✅ Normal |+| Cable Connections | Connections secure, no looseness | Normal | ✅ Normal |+| Grounding System | Grounding good | Normal | ✅ Normal |++---++## 3. Abnormality Summary++### 3.1 Processed Abnormalities++| No. | Equipment | Abnormality Description | Measures | Result |+|------|-----------|------------------------|----------|--------|+| 1 | CNC Machining Center M-001 | Coolant level low | Top up coolant | Restored |++---++## 4. Inspection Summary++### 4.1 Overall Evaluation++Overall inspection was good, all equipment operating normally. Only one minor abnormality found (low coolant level), which was processed on-site.++### 4.2 Suggestions++1. Recommend increasing coolant level monitoring frequency to prevent recurrence+2. AGV-001 power consumption relatively fast, recommend checking battery status+3. Recommend regular sensor cleaning to ensure detection accuracy++### 4.3 Next Inspection Plan++- Inspection Date: March 18, 2024+- Inspection Type: Weekly Inspection+- Key Focus: Cooling system operation status, AGV battery endurance capability++---++**Inspector Signature**: Zhang San+**Date**: March 15, 2024+**Reviewed by**: Li Si+**Review Date**: March 15, 2024diff --git a/tests/fixtures/test_samples/en/industry/operating_mode.md b/tests/fixtures/test_samples/en/industry/operating_mode.mdnew file mode 100644index 0000000..9674cdc--- /dev/null+++ b/tests/fixtures/test_samples/en/industry/operating_mode.md@@ -0,0 +1,244 @@+# Automated Assembly Line A1 Operating Mode Switching Manual++**Document Number**: OM-2024-001+**Version**: v1.0+**Preparation Date**: February 2024+**Applicable Equipment**: Automated Assembly Line A1++---++## 1. Overview++This document describes the operating modes and mode switching conditions of Automated Assembly Line A1. Operators shall strictly follow this manual for mode switching operations to ensure safe equipment operation.++---++## 2. Operating Modes++Automated Assembly Line A1 supports the following operating modes:++### 2.1 Shutdown Mode++**Mode Description**: Equipment completely stops operation, all systems powered off.++**Applicable Conditions**:+- Production task completed+- Equipment maintenance+- Long-term shutdown++**Load Range**: 0%++### 2.2 Standby Mode++**Mode Description**: Equipment is in hot standby state, main power remains powered, control system ready, can start quickly.++**Applicable Conditions**:+- Pre-production preparation+- Production pause+- Short break++**Load Range**: 5-10%++### 2.3 Manual Debug Mode++**Mode Description**: Equipment is manually controlled by operators, used for equipment debugging, maintenance and fault troubleshooting.++**Applicable Conditions**:+- Equipment debugging+- Maintenance operations+- Fault troubleshooting+- New program testing++**Load Range**: 0-30%++### 2.4 Automatic Operation Mode++**Mode Description**: Equipment automatically runs according to preset program without human intervention.++**Applicable Conditions**:+- Normal production operation+- Mass production++**Load Range**: 30-100%++### 2.5 Emergency Stop Mode++**Mode Description**: Equipment immediately stops all actions, cuts off power source.++**Applicable Conditions**:+- Emergency occurs+- Equipment failure+- Personnel safety threatened++**Load Range**: 0%++---++## 3. Mode Switching++### 3.1 Shutdown Mode → Standby Mode++**Switching Conditions**:+- Close main power switch+- Control system self-test passed++**Switching Steps**:+1. Close main power switch+2. Start auxiliary system+3. Control system self-test+4. Enter standby state++**Switching Time**: Approximately 30 seconds++### 3.2 Standby Mode → Manual Debug Mode++**Switching Conditions**:+- Engage manual handle+- Select manual mode++**Switching Steps**:+1. Engage manual handle+2. Select manual mode on HMI+3. Confirm mode switch+4. Enter manual debug state++**Switching Time**: Approximately 5 seconds++### 3.3 Manual Debug Mode → Standby Mode++**Switching Conditions**:+- Disengage manual handle+- Exit manual mode++**Switching Steps**:+1. Disengage manual handle+2. Select exit manual mode on HMI+3. Confirm exit+4. Return to standby state++**Switching Time**: Approximately 3 seconds++### 3.4 Standby Mode → Automatic Operation Mode++**Switching Conditions**:+- Production task ready+- Materials sufficient+- All subsystems normal+- Press automatic start button++**Switching Steps**:+1. Confirm production task is issued+2. Confirm materials are sufficient+3. Confirm all systems status normal+4. Press automatic start button+5. System loads production program+6. Gradually increase operation speed+7. Enter automatic operation state++**Switching Time**: Approximately 60 seconds++### 3.5 Automatic Operation Mode → Standby Mode++**Switching Conditions**:+- Production task completed+- Press pause button++**Switching Steps**:+1. Press pause button+2. Wait for current process to complete+3. Equipment stops automatic operation+4. Keep power supply+5. Enter standby state++**Switching Time**: Approximately 30 seconds++### 3.6 Automatic Operation Mode → Emergency Stop Mode++**Switching Conditions**:+- Press emergency stop button+- Serious fault detected+- Safety guard opened++**Switching Steps**:+1. Press emergency stop button (or fault triggered)+2. Immediately stop all moving parts+3. Cut off main power+4. Activate alarm device+5. Enter emergency stop state++**Switching Time**: Immediate++### 3.7 Emergency Stop Mode → Standby Mode++**Switching Conditions**:+- Fault cleared+- Site safety confirmed+- Press reset button++**Switching Steps**:+1. Confirm fault is cleared+2. Confirm site is safe+3. Close emergency stop button+4. Press reset button+5. System self-test+6. Enter standby state++**Switching Time**: Approximately 60 seconds++---++## 4. Mode Switching Flowchart++```+ ┌──────────────┐+ │ Shutdown │+ │ Mode │+ └──────┬───────┘+ │+ ┌──────▼───────┐+ │ Standby │+ │ Mode │+ └──────┬───────┘+ │+ ┌──────────────┴──────────────┐+ │ │+ ┌──────▼───────┐ ┌───────▼──────┐+ │ Manual │ │ Automatic │+ │ Debug Mode │ │ Mode │+ └──────┬───────┘ └──────┬───────┘+ │ │+ └──────────┬───────────────────┘+ │+ ┌──────▼───────┐+ │ Emergency │+ │ Stop │+ │ Mode │+ └──────────────┘+```++---++## 5. Precautions++1. **Safety First**: Ensure personnel safety during any mode switching+2. **Sequential Execution**: Must follow switching steps in sequence, do not skip steps+3. **Status Confirmation**: Confirm current status meets switching conditions before switching+4. **Exception Handling**: Stop immediately and report if exception occurs during switching++---++## 6. Load and Mode Reference Table++| Mode | Load Range | Description |+|------|-----------|-------------|+| Shutdown Mode | 0% | Completely powered off |+| Standby Mode | 5-10% | Hot standby |+| Manual Debug Mode | 0-30% | Low load debugging |+| Automatic Operation Mode | 30-100% | Normal production |+| Emergency Stop Mode | 0% | Immediate stop |++---++**Prepared by**: Equipment Department+**Reviewed by**: Technical Department+**Approved by**: Production Departmentdiff --git a/tests/fixtures/test_samples/en/industry/operation_flow.md b/tests/fixtures/test_samples/en/industry/operation_flow.mdnew file mode 100644index 0000000..829e835--- /dev/null+++ b/tests/fixtures/test_samples/en/industry/operation_flow.md@@ -0,0 +1,189 @@+# Automated Assembly Line A1 Startup Operation Procedure++**Procedure Number**: OP-2024-001+**Version**: v2.1+**Preparation Date**: February 2024+**Applicable Equipment**: Automated Assembly Line A1++---++## 1. Scope of Application++This procedure applies to the startup operation of Automated Assembly Line A1, including CNC machining centers, robotic arm systems, material handling systems, and quality inspection stations.++---++## 2. Pre-Startup Checks++### 2.1 Environment Check++| Check Item | Check Content | Status |+|------------|---------------|--------|+| Temperature | Environment temperature should be within 15-30°C | □ |+| Humidity | Relative humidity should be within 40-70% | □ |+| Cleanliness | No debris or water accumulation around equipment | □ |++### 2.2 Equipment Check++| Check Item | Check Content | Status |+|------------|---------------|--------|+| Power Supply | Main power voltage normal, three-phase balanced | □ |+| Air Source | Air pressure maintained at 0.5-0.7MPa | □ |+| Lubrication | All lubrication points have sufficient grease | □ |+| Safety Devices | Emergency stop button, door locks normal | □ |++---++## 3. Startup Procedure++### 3.1 Step 1: Start Auxiliary System++**Operation**: Turn on auxiliary power supply for control cabinet++- Open control cabinet door+- Close auxiliary power switch+- Confirm auxiliary power indicator lights up++**Expected Result**: Auxiliary power normally connected, control panel shows ready status++**Trigger Condition**: Auxiliary power normal++### 3.2 Step 2: Start Hydraulic System++**Operation**: Start hydraulic station++- Press hydraulic station start button+- Wait for hydraulic pressure to rise to set value+- Check hydraulic oil level++**Expected Result**: Hydraulic pressure stable at 3.5MPa, oil level normal++**Trigger Condition**: Hydraulic pressure reaches set value++### 3.3 Step 3: Start Cooling System++**Operation**: Turn on cooling pump++- Turn on cooling pump power switch+- Adjust coolant flow to appropriate value+- Check coolant temperature++**Expected Result**: Cooling system正常运行,进出口温差在5-10°C++**Trigger Condition**: Cooling pump runs without abnormality++### 3.4 Step 4: Start Control System++**Operation**: Start main control system++- Select "Automatic Mode" on HMI+- Click "System Start" button+- Wait for system self-test to complete++**Expected Result**: HMI displays "System Ready", no alarm information++**Trigger Condition**: System self-test passed++### 3.5 Step 5: Activate Servo System++**Operation**: Start servo drive++- Start each axis servo driver in sequence+- Wait for servo system to be ready+- Perform origin reference return++**Expected Result**: Each axis returns to reference origin, position display correct++**Trigger Condition**: Servo system without fault++### 3.6 Step 6: Start Material Handling System++**Operation**: Start conveyor and AGV++- Start conveyor motor+- Activate AGV navigation system+- Set transport path++**Expected Result**: Conveyor runs normally, AGV in position and on standby++**Trigger Condition**: Conveyor runs smoothly++### 3.7 Step 7: Start Robotic System++**Operation**: Activate robotic arm++- Start robotic arm control cabinet+- Load processing program+- Perform robotic arm origin return++**Expected Result**: Each robotic arm joint normal, reaching origin position++**Trigger Condition**: Robotic arm without collision alarm++### 3.8 Step 8: Start Quality Inspection System++**Operation**: Turn on inspection equipment++- Start vision inspection system+- Calibrate inspection parameters+- Load inspection program++**Expected Result**: Inspection system ready, can normally identify workpieces++**Trigger Condition**: Inspection system self-test passed++---++## 4. Full Startup Confirmation++After completing the above steps, perform full confirmation:++| Check Item | Confirmation Content | Result |+|------------|---------------------|--------|+| System Status | All subsystems display "Ready" | □ |+| Communication Status | All equipment communication normal | □ |+| Safety Status | Safety doors closed, emergency stop released | □ |+| Production Mode | Switch to automatic production mode | □ |++---++## 5. Startup Abnormality Handling++### 5.1 Insufficient Hydraulic Pressure++- Check if hydraulic oil is sufficient+- Check if hydraulic pump is normal+- Check for leaks++### 5.2 Cooling System Alarm++- Check coolant level+- Check cooling pump operating status+- Clean cooling filter++### 5.3 Servo System Fault++- Check servo drive alarm code+- Check motor connection+- Perform fault reset++---++## 6. Shutdown Procedure++### 6.1 Normal Shutdown++1. Stop material input+2. Wait for current process to complete+3. Stop each subsystem in sequence+4. Turn off main power++### 6.2 Emergency Shutdown++Press emergency stop button, equipment stops immediately, then follow normal procedure to check before restarting.++---++**Prepared by**: Equipment Department+**Reviewed by**: Technical Department+**Approved by**: Production Departmentdiff --git a/tests/fixtures/test_samples/en/industry/safety_control.md b/tests/fixtures/test_samples/en/industry/safety_control.mdnew file mode 100644index 0000000..39195bd--- /dev/null+++ b/tests/fixtures/test_samples/en/industry/safety_control.md@@ -0,0 +1,156 @@+# Automated Assembly Line A1 Safety Control Manual++**Document Number**: SC-2024-001+**Version**: v1.5+**Preparation Date**: February 2024+**Scope of Application**: All operators of Automated Assembly Line A1++---++## 1. General Provisions++### 1.1 Purpose++This manual is formulated to strengthen safety production management of Automated Assembly Line A1, prevent and reduce production safety accidents, and protect employee life safety and physical health.++### 1.2 Scope of Application++This manual applies to all operational activities of Automated Assembly Line A1, including equipment operation, maintenance, inspection and testing.++---++## 2. Hazard Identification++### 2.1 Equipment Hazards++| No. | Hazard Name | Hazard Factors | Possible Consequences |+|-----|-------------|----------------|----------------------|+| 1 | CNC Machining Center | High temperature parts, rotating parts | Burns, mechanical injury |+| 2 | Industrial Robotic Arm | Moving parts, clamping force | Crush injury, impact injury |+| 3 | Cooling System | High pressure liquid, temperature change | Burns, frostbite |+| 4 | Hydraulic Station | High pressure oil, aging seals | High pressure jet injury |+| 5 | Electrical Control Cabinet | Electrical components, high voltage power | Electric shock, electrocution |++### 2.2 Environmental Hazards++| No. | Hazard Name | Hazard Factors | Possible Consequences |+|-----|-------------|----------------|----------------------|+| 1 | Workshop Passageway | Floor oil contamination, object stacking | Falls, trips |+| 2 | Material Stacking Area | Material tipping, instability | Crushing, collision |+| 3 | Noise Area | Equipment operating noise | Hearing damage |+| 4 | Chemical Storage | Toxic and hazardous chemicals | Poisoning, chemical burns |++### 2.3 Behavioral Hazards++| No. | Hazard Name | Hazard Factors | Possible Consequences |+|-----|-------------|----------------|----------------------|+| 1 | Violation of Operations | Violating operating procedures | Equipment damage, personal injury |+| 2 | Fatigue Operations | Continuous work, insufficient rest | Slow reaction, misoperation |+| 3 | Missing Protection | Not wearing protective equipment | Personal injury |++---++## 3. Risk Points and Control Measures++### 3.1 Mechanical Equipment Risks++| Risk Point | Risk Level | Control Measures | Responsible Person |+|------------|-------------|------------------|-------------------|+| CNC Machining Center Operation | Major Risk | 1. Strictly follow operating procedures 2. Wear protective goggles and gloves 3. Prohibit opening protective doors during operation 4. Regularly check protective device effectiveness | Equipment Person in Charge |+| Robotic Arm Operating Area | Major Risk | 1. Set safety fences and warning signs 2. Install light curtain protection devices 3. Confirm safe area is clear before operation 4. Strictly prohibit unauthorized entry into operating area | Team Leader |+| Hydraulic System Maintenance | Greater Risk | 1. Release pressure before maintenance 2. Wear protective gloves and goggles 3. Use professional tools for maintenance 4. Conduct pressure test after maintenance | Maintenance Technician |++### 3.2 Electrical Safety Risks++| Risk Point | Risk Level | Control Measures | Responsible Person |+|------------|-------------|------------------|-------------------|+| Electrical Cabinet Operation | Major Risk | 1. Only qualified electricians with electrical work certificates can operate 2. Perform voltage verification before operation 3. Wear insulating shoes and gloves 4. Prohibit live work | Electrician |+| Temporary Electricity Use | Greater Risk | 1. Complete temporary electricity use approval 2. Use qualified electrical equipment 3. Regularly check line insulation performance 4. Implement one machine one switch one protection | Equipment Person in Charge |+| Static Electricity Protection | General Risk | 1. Wear anti-static work clothes 2. Ensure equipment grounding is reliable 3. Maintain appropriate ambient humidity | Safety Officer |++### 3.3 Chemical Safety Risks++| Risk Point | Risk Level | Control Measures | Responsible Person |+|------------|-------------|------------------|-------------------|+| Coolant Use | Greater Risk | 1. Wear protective gloves and goggles 2. Keep workplace ventilated 3. Avoid direct skin contact 4. Regularly test coolant concentration | Equipment Person in Charge |+| Lubricating Grease | General Risk | 1. Wear protective gloves 2. Avoid contact with mouth and eyes 3. Use special tools for application 4. Collect waste oil for unified disposal | Maintenance Technician |+| Cleaning Agent Use | Greater Risk | 1. Use in ventilated areas 2. Wear gas masks 3. Store away from fire sources 4. Operate according to MSDS requirements | Team Leader |++### 3.4 Environmental Safety Risks++| Risk Point | Risk Level | Control Measures | Responsible Person |+|------------|-------------|------------------|-------------------|+| Passageway Blockage | General Risk | 1. Keep passageways clear 2. Do not stack materials in passageways 3. Clean oil stains and debris promptly 4. Install anti-slip facilities | Team Leader |+| Noise Hazard | General Risk | 1. Wear earplugs or earmuffs 2. Control at noise source 3. Conduct noise testing regularly 4. Arrange work time reasonably | Safety Officer |+| Material Stacking | Greater Risk | 1. Stack neatly and stably 2. Do not exceed specified height 3. Leave safety passages 4. Regularly check stacking status | Warehouse Keeper |++---++## 4. Personal Protective Equipment++### 4.1 Required Protective Equipment++| Protective Equipment | Applicable Area | Replacement Cycle | Responsible Person |+|---------------------|-----------------|-------------------|-------------------|+| Safety Helmet | All work areas | Replace when damaged | Individual Employee |+| Protective Goggles | Processing area, maintenance area | Replace when damaged | Individual Employee |+| Protective Gloves | When contacting chemicals, mechanical equipment | Replace when damaged | Individual Employee |+| Earplugs/Earmuffs | Noise areas | Replace weekly | Individual Employee |+| Insulating Shoes | Electrical work areas | Replace every 6 months | Individual Employee |+| Anti-static Work Clothes | All work areas | Replace every 1 year | Individual Employee |++### 4.2 Protective Equipment Usage Regulations++1. Must correctly wear protective equipment before work+2. Must immediately replace damaged or ineffective protective equipment+3. Strictly prohibit unauthorized modification or removal of protective devices+4. Must return protective equipment when leaving position or transferring++---++## 5. Safety Responsibility System++### 5.1 Safety Responsibilities at All Levels++| Role | Safety Responsibilities |+|------|----------------------|+| General Manager | Fully responsible for company safety production work |+| Safety Supervisor | Responsible for safety management system construction, safety supervision and inspection |+| Equipment Person in Charge | Responsible for equipment safe operation, hazard investigation and rectification |+| Team Leader | Responsible for team safety management, employee safety education |+| Operators | Strictly follow safety procedures, correctly use protective equipment |++### 5.2 Safety Assessment and Rewards/Penalties++- Conduct monthly safety performance assessment+- Reward promptly reporting discovered hazards+- Penalize violations according to regulations+- Commend annual safety advanced individuals++---++## 6. Hazard Investigation and Rectification++### 6.1 Hazard Investigation Frequency++| Investigation Type | Frequency | Responsible Person |+|-------------------|-----------|-------------------|+| Daily Inspection | Daily | On-duty Employee |+| Weekly Inspection | Weekly | Team Leader |+| Monthly Inspection | Monthly | Equipment Person in Charge |+| Special Inspection | Quarterly | Safety Supervisor |++### 6.2 Hazard Rectification Process++1. Discover hazard, record hazard information+2. Assess hazard level, determine rectification measures+3. Issue rectification notice, implement rectification responsibility+4. Implement rectification, accept rectification results+5. Close file, continuous improvement++---++**Prepared by**: Safety and Environmental Protection Department+**Reviewed by**: Production Department+**Approved by**: General Manager+**Effective Date**: February 15, 2024diff --git a/tests/fixtures/test_samples/en/industry/system_topology.md b/tests/fixtures/test_samples/en/industry/system_topology.mdnew file mode 100644index 0000000..8beac72--- /dev/null+++ b/tests/fixtures/test_samples/en/industry/system_topology.md@@ -0,0 +1,185 @@+# Factory A System Architecture Documentation++**Document Number**: SA-2024-001+**Version**: v1.0+**Preparation Date**: January 2024++---++## 1. Factory Overview++Factory A is a modern manufacturing factory of the company, located in the industrial park, covering an area of approximately 50,000 square meters. The factory mainly engages in electronic product manufacturing and precision machining business.++### 1.1 Factory Scale++| Item | Data |+|------|------|+| Occupied Area | 50,000 square meters |+| Building Area | 35,000 square meters |+| Employee Count | Approximately 500 people |+| Annual Output Value | 500 million yuan |++---++## 2. Factory Layout++Factory A consists of the following main functional areas:++### 2.1 Production Areas++| Area Name | Function | Area |+|-----------|----------|------|+| Manufacturing Workshop A | Automated assembly production line | 8,000 square meters |+| Manufacturing Workshop B | Precision machining center | 6,000 square meters |+| Manufacturing Workshop C | Assembly workshop | 5,000 square meters |++### 2.2 Support Areas++| Area Name | Function | Area |+|-----------|----------|------|+| Warehouse Area | Raw materials and finished product storage | 10,000 square meters |+| Utility Station | Power, water, gas supply | 2,000 square meters |+| Office Area | Administrative offices | 3,000 square meters |++---++## 3. Production Systems++### 3.1 Manufacturing Workshop A - Automated Assembly Production Line++Manufacturing Workshop A is the core production workshop of the factory, mainly including the following systems:++#### 3.1.1 CNC Machining System++| Equipment Name | Specification | Quantity | Function |+|---------------|--------------|----------|----------|+| CNC Machining Center Alpha | TM-5000X | 2 units | Precision parts machining |+| CNC Machining Center Beta | TM-5000X | 2 units | Precision parts machining |++#### 3.1.2 Robotic System++| Equipment Name | Specification | Quantity | Function |+|---------------|--------------|----------|----------|+| Industrial Robotic Arm R1 | AR-200 | 3 units | Workpiece handling and assembly |+| Industrial Robotic Arm R2 | AR-200 | 3 units | Workpiece handling and assembly |+| Industrial Robotic Arm R3 | AR-150 | 2 units | Backup robotic arm |++#### 3.1.3 Material Handling System++| Equipment Name | Specification | Quantity | Function |+|---------------|--------------|----------|----------|+| Conveyor Belt System | CT-500 | 1 set | Workpiece transportation |+| Automated Guided Vehicle AGV | LM-1000 | 4 units | Material distribution |++#### 3.1.4 Support Systems++| System Name | Function |+|-------------|----------|+| Cooling System | Provide cooling for CNC equipment |+| Lubrication System | Provide lubrication for mechanical equipment |+| Hydraulic System | Provide power for pneumatic equipment |+| Dust Removal System | Keep workshop clean |++### 3.2 Manufacturing Workshop B - Precision Machining Center++Manufacturing Workshop B mainly undertakes high-precision parts machining tasks:++| System Name | Main Equipment | Function |+|-------------|----------------|----------|+| Turning System | 4 CNC lathes | Parts turning machining |+| Milling System | 3 CNC milling machines | Parts milling machining |+| Grinding System | 2 precision grinders | Parts precision grinding |+| Inspection System | Coordinate measuring machine | Dimension inspection |++### 3.3 Manufacturing Workshop C - Assembly Workshop++Manufacturing Workshop C is responsible for product assembly:++| System Name | Function |+|-------------|----------|+| Final Assembly Line | Product final assembly |+| Testing Line | Product function testing |+| Packaging Line | Product packaging and storage |++---++## 4. Utility Systems++### 4.1 Power Supply System++| Item | Data |+|------|------|+| Transformer Capacity | 2000KVA |+| Supply Voltage | 10KV |+| Backup Power | Diesel generator 500KW |++### 4.2 Water Supply System++| Item | Data |+|------|------|+| Daily Water Supply | 200 tons |+| Water Supply Pressure | 0.3MPa |++### 4.3 Gas Supply System++| Item | Data |+|------|------|+| Air Compressors | 3 units |+| Supply Pressure | 0.7MPa |++---++## 5. Hierarchy Structure Summary++The system hierarchy structure of Factory A is as follows:++```+Factory A+├── Manufacturing Workshop A+│ ├── CNC Machining System+│ │ ├── CNC Machining Center Alpha+│ │ └── CNC Machining Center Beta+│ ├── Robotic System+│ │ ├── Industrial Robotic Arm R1+│ │ ├── Industrial Robotic Arm R2+│ │ └── Industrial Robotic Arm R3+│ ├── Material Handling System+│ │ ├── Conveyor Belt System+│ │ └── Automated Guided Vehicle AGV+│ └── Support Systems+│ ├── Cooling System+│ ├── Lubrication System+│ ├── Hydraulic System+│ └── Dust Removal System+├── Manufacturing Workshop B+│ ├── Turning System+│ ├── Milling System+│ ├── Grinding System+│ └── Inspection System+├── Manufacturing Workshop C+│ ├── Final Assembly Line+│ ├── Testing Line+│ └── Packaging Line+├── Warehouse Area+├── Utility Station+│ ├── Power Supply System+│ ├── Water Supply System+│ └── Gas Supply System+└── Office Area+```++---++## 6. System Relationships++The following relationships exist between systems:++- Manufacturing Workshops A, B, and C share utility services from the Utility Station (power, water, gas)+- The Warehouse Area provides raw material supply and finished product storage for the three manufacturing workshops+- The Material Handling System connects various manufacturing workshops to achieve material flow++---++**Prepared by**: Engineering Department+**Reviewed by**: Technical Department+**Approved by**: Factory Managementdiff --git a/tests/fixtures/test_samples/zh/industry/emergency_response.md b/tests/fixtures/test_samples/zh/industry/emergency_response.mdnew file mode 100644index 0000000..ddeb553--- /dev/null+++ b/tests/fixtures/test_samples/zh/industry/emergency_response.md@@ -0,0 +1,157 @@+# 自动化装配线A1 应急预案++**文档编号**: EP-2024-001+**版本**: v2.0+**编制日期**: 2024年1月+**适用范围**: 自动化装配线A1及周边区域++---++## 1. 总则++### 1.1 编制目的++为有效预防、及时控制和消除自动化装配线A1突发事件的危害,最大限度地减少突发事件造成的人员伤亡和财产损失,保障设备安全和生产顺利进行,特制定本预案。++### 1.2 适用范围++本预案适用于自动化装配线A1发生的各类突发事件的应急处置,包括火灾、泄漏、停电、设备故障、人员受伤等事故。++---++## 2. 应急组织机构++### 2.1 应急指挥中心++| 角色 | 姓名 | 职责 |+|------|------|------|+| 总指挥 | 王经理 | 全面负责应急响应工作 |+| 副总指挥 | 李主管 | 协助总指挥工作,负责现场指挥 |+| 组员 | 张维修 | 设备应急处置 |+| 组员 | 安保人员 | 现场安保与疏散 |++### 2.2 应急响应部门++| 部门 | 职责 |+|------|------|+| 安保部 | 现场安保、人员疏散、安全警戒 |+| 设备部 | 设备应急处置、故障排除 |+| 急救部 | 现场急救、医疗救护 |+| 后勤部 | 物资保障、通信联络 |++---++## 3. 应急响应流程++### 3.1 火灾应急响应++**触发条件**:发现火情或火警报警++**响应流程**:++| 步骤 | 响应动作 | 负责部门 | 时间要求 | 成功标准 |+|------|---------|---------|---------|----------|+| 1 | 发现火情立即按下报警按钮 | 当班员工 | 立即 | 报警信号发出 |+| 2 | 拨打内部报警电话报告火情 | 当班员工 | 1分钟内 | 报告成功 |+| 3 | 启动消防广播,通知人员疏散 | 安保部 | 2分钟内 | 广播覆盖全场 |+| 4 | 开启消防栓和灭火器进行初期灭火 | 设备部 | 3分钟内 | 火势得到控制 |+| 5 | 关闭着火区域电源和燃气阀门 | 设备部 | 2分钟内 | 电源已切断 |+| 6 | 疏散生产区域人员至安全集合点 | 安保部 | 5分钟内 | 人员全部撤离 |+| 7 | 拨打119报警,请求消防队支援 | 安保部 | 立即 | 报警成功 |+| 8 | 迎接消防队并提供现场情况 | 安保部 | 10分钟内 | 消防队到达现场 |++### 3.2 化学品泄漏应急响应++**触发条件**:发现化学品泄漏++**响应流程**:++| 步骤 | 响应动作 | 负责部门 | 时间要求 | 成功标准 |+|------|---------|---------|---------|----------|+| 1 | 立即停止作业,关闭泄漏源 | 当班员工 | 立即 | 泄漏源已关闭 |+| 2 | 开启通风设备,稀释泄漏物浓度 | 设备部 | 2分钟内 | 通风设备已开启 |+| 3 | 使用吸附材料围堵泄漏物 | 设备部 | 3分钟内 | 泄漏已围堵 |+| 4 | 疏散周边人员,设置警戒区域 | 安保部 | 5分钟内 | 人员已疏散 |+| 5 | 拨打急救电话,请求医疗支援 | 安保部 | 立即 | 医疗支援已请求 |+| 6 | 清理泄漏物,恢复生产 | 设备部 | 30分钟内 | 现场清理完毕 |++### 3.3 停电应急响应++**触发条件**:发生突然停电++**响应流程**:++| 步骤 | 响应动作 | 负责部门 | 时间要求 | 成功标准 |+|------|---------|---------|---------|----------|+| 1 | 立即启动备用电源 | 设备部 | 10秒内 | 备用电源已启动 |+| 2 | 启用应急照明,保障人员安全撤离 | 设备部 | 30秒内 | 应急照明已开启 |+| 3 | 关闭主要设备,防止设备损坏 | 设备部 | 1分钟内 | 设备已关闭 |+| 4 | 人员有序撤离生产区域 | 安保部 | 3分钟内 | 人员已撤离 |+| 5 | 排查停电原因,评估恢复时间 | 设备部 | 10分钟内 | 原因已查明 |+| 6 | 恢复供电后,按顺序重启设备 | 设备部 | 20分钟内 | 设备已重启 |++### 3.4 设备故障应急响应++**触发条件**:关键设备发生严重故障++**响应流程**:++| 步骤 | 响应动作 | 负责部门 | 时间要求 | 成功标准 |+|------|---------|---------|---------|----------|+| 1 | 按下急停按钮,停止设备运行 | 操作员 | 立即 | 设备已停止 |+| 2 | 切断设备电源,防止故障扩大 | 操作员 | 立即 | 电源已切断 |+| 3 | 报告设备故障情况 | 操作员 | 1分钟内 | 报告已发出 |+| 4 | 维修人员到场,进行故障诊断 | 设备部 | 15分钟内 | 诊断完成 |+| 5 | 评估故障程度,制定修复方案 | 设备部 | 30分钟内 | 方案已制定 |+| 6 | 实施修复,恢复生产 | 设备部 | 2小时内 | 生产已恢复 |++### 3.5 人员受伤应急响应++**触发条件**:发生人员受伤事故++**响应流程**:++| 步骤 | 响应动作 | 负责部门 | 时间要求 | 成功标准 |+|------|---------|---------|---------|----------|+| 1 | 立即停止作业,确保现场安全 | 当班员工 | 立即 | 现场已安全 |+| 2 | 检查受伤人员伤情 | 当班员工 | 立即 | 伤情已评估 |+| 3 | 进行现场急救处理 | 急救部 | 5分钟内 | 急救已完成 |+| 4 | 拨打120急救电话 | 急救部 | 立即 | 急救电话已拨打 |+| 5 | 安排人员迎接救护车 | 急救部 | 10分钟内 | 救护车已接到 |+| 6 | 保护现场,配合调查 | 安保部 | 持续 | 现场已保护 |++---++## 4. 应急保障++### 4.1 物资保障++- 消防器材:灭火器、消防栓、消防广播+- 急救物资:急救箱、担架、防护服+- 应急照明:应急灯、手电筒+- 通信设备:对讲机、移动电话++### 4.2 培训与演练++- 每季度进行一次应急演练+- 新员工入职培训包含应急内容+- 每年组织一次综合应急演练++---++## 5. 预案管理++### 5.1 预案修订++本预案每年修订一次,如有重大变更应及时修订。++### 5.2 预案解释++本预案由安全环保部负责解释。++---++**编制人**: 安全环保部+**审核人**: 生产部+**批准人**: 总经理+**生效日期**: 2024年1月15日diff --git a/tests/fixtures/test_samples/zh/industry/equipment_topology.md b/tests/fixtures/test_samples/zh/industry/equipment_topology.mdnew file mode 100644index 0000000..62a7145--- /dev/null+++ b/tests/fixtures/test_samples/zh/industry/equipment_topology.md@@ -0,0 +1,141 @@+# 先进制造生产线:自动化装配系统技术文档++**文档类型**: 设备拓扑规格说明书+**系统版本**: v3.2+**更新日期**: 2024年+**所属部门**: 工程与维护部++---++## 1. 系统概述++**自动化装配线A1** 是一套高精度电子元件制造系统。该系统集成了多台设备,包括数控加工中心、工业机器人、自动导引车(AGV)和质量检测站。本文档提供详细的设备拓扑信息,用于维护规划和系统优化。++---++## 2. 设备清单++### 2.1 核心生产设备++| 设备编号 | 设备名称 | 类型 | 位置 | 状态 | 制造商 | 规格型号 |+|---------|----------|------|------|------|--------|----------|+| M-001 | 数控加工中心Alpha | 主机 | 制造车间A,一区 | 运行中 | 精工机械 | TM-5000X |+| M-002 | 数控加工中心Beta | 主机 | 制造车间A,一区 | 运行中 | 精工机械 | TM-5000X |+| S-001 | 工业机械臂R1 | 辅机 | 制造车间A,二区 | 运行中 | 智造机器人 | AR-200 |+| S-002 | 工业机械臂R2 | 辅机 | 制造车间A,二区 | 运行中 | 智造机器人 | AR-200 |+| S-003 | 工业机械臂R3 | 辅机 | 制造车间A,三区 | 备用 | 智造机器人 | AR-150 |+| P-001 | 冷却泵单元A | 辅机 | 制造车间A,地下一层 | 运行中 | 流体科技 | CP-300 |+| P-002 | 冷却泵单元B | 辅机 | 制造车间A,地下一层 | 运行中 | 流体科技 | CP-300 |+| V-001 | 主控制阀 | 阀门 | 制造车间A,一区 | 运行中 | 阀控专家 | CV-500 |+| V-002 | 安全泄压阀 | 阀门 | 制造车间A,二区 | 运行中 | 阀控专家 | CV-200 |+| MTR-001 | 驱动电机M1 | 电机 | 制造车间A,一区 | 运行中 | 动力驱动 | DM-750 |+| MTR-002 | 驱动电机M2 | 电机 | 制造车间A,一区 | 运行中 | 动力驱动 | DM-750 |++### 2.2 物料输送设备++| 设备编号 | 设备名称 | 类型 | 位置 | 状态 | 制造商 | 规格型号 |+|---------|----------|------|------|------|--------|----------|+| AGV-001 | 自动导引车1 | 系统 | 制造车间A | 运行中 | 物流智控 | LM-1000 |+| AGV-002 | 自动导引车2 | 系统 | 制造车间A | 运行中 | 物流智控 | LM-1000 |+| CV-001 | 传送带系统 | 系统 | 制造车间A,一至四区 | 运行中 | 传送科技 | CT-500 |++### 2.3 监控与控制设备++| 设备编号 | 设备名称 | 类型 | 位置 | 状态 | 制造商 | 规格型号 |+|---------|----------|------|------|------|--------|----------|+| INS-001 | 温度传感器T1 | 仪表 | 制造车间A,一区 | 运行中 | 传感专家 | ST-100 |+| INS-002 | 压力传感器P1 | 仪表 | 制造车间A,一区 | 运行中 | 传感专家 | SP-200 |+| INS-003 | 流量传感器F1 | 仪表 | 制造车间A,二区 | 运行中 | 传感专家 | SF-150 |+| CTR-001 | 主控制柜 | 系统 | 制造车间A,控制室 | 运行中 | 控制大师 | MC-800 |+| CTR-002 | 人机界面 | 系统 | 制造车间A,控制室 | 运行中 | 界面科技 | HMI-700 |++---++## 3. 设备拓扑关系++### 3.1 物料流向路径++主要物料流向遵循以下顺序:++**原料仓库 → 数控加工中心Alpha(M-001)→ 数控加工中心Beta(M-002)→ 质量检测站 → 成品仓库**++- 原料通过传送带系统(CV-001)进入生产线+- M-001进行初加工,然后将工件传输至M-002+- M-002完成最终加工后输出至质量检测+- AGV-001将成品运输至存储区++### 3.2 能量传递系统++**电源 → 主控制柜(CTR-001)→ 驱动电机(MTR-001、MTR-002)→ 数控加工中心**++- 主电源提供380V三相电源至CTR-001+- CTR-001向各驱动电机分配电力+- MTR-001驱动M-001主轴旋转+- MTR-002驱动M-002主轴旋转++### 3.3 控制信号网络++**人机界面(CTR-002)→ 主控制柜(CTR-001)→ 机械臂(S-001、S-002、S-003)→ 数控加工中心**++- HMI作为主要操作员界面+- CTR-001处理命令并发送控制信号+- S-001和S-002执行工件上下料+- S-002作为S-002的备份++### 3.4 冷却系统回路++**冷却泵单元A(P-001)→ 数控加工中心Alpha(M-001)→ 冷却泵单元A(回水)**+**冷却泵单元B(P-002)→ 数控加工中心Beta(M-002)→ 冷却泵单元B(回水)**++- P-001循环冷却介质至M-001+- P-002循环冷却介质至M-002+- 主控制阀(V-001)调节至M-001的流量+- 安全泄压阀(V-002)提供超压保护++### 3.5 监测与反馈回路++**温度传感器T1(INS-001)→ 主控制柜(CTR-001)→ 冷却泵单元A(P-001)**++- INS-001监测M-001工作温度+- CTR-001接收温度数据并调整P-001转速+- 闭环控制将温度维持在可接受范围内++**压力传感器P1(INS-002)→ 主控制柜(CTR-001)→ 安全泄压阀(V-002)**++- INS-002监测液压系统压力+- 当压力超过阈值时,V-002自动开启+- 应急泄压保护系统免受过压损坏++---++## 4. 系统互联汇总表++| 源设备 | 目标设备 | 连接类型 | 描述 |+|--------|----------|---------|------|+| CV-001 | M-001 | 物料输送 | 工件传输 |+| M-001 | M-002 | 物料输送 | 顺序加工 |+| M-002 | AGV-001 | 物料输送 | 成品运输 |+| CTR-001 | MTR-001 | 电气连接 | 主轴驱动电源 |+| CTR-001 | MTR-002 | 电气连接 | 主轴驱动电源 |+| CTR-001 | S-001 | 控制信号 | 机器人协调 |+| CTR-001 | S-002 | 控制信号 | 机器人协调 |+| CTR-001 | S-003 | 控制信号 | 备份机器人控制 |+| P-001 | M-001 | 冷却回路 | 冷却介质供应 |+| P-002 | M-002 | 冷却回路 | 冷却介质供应 |+| V-001 | M-001 | 冷却回路 | 流量调节 |+| V-002 | P-002 | 冷却回路 | 超压保护 |+| INS-001 | CTR-001 | 仪表信号 | 温度反馈 |+| INS-002 | CTR-001 | 仪表信号 | 压力反馈 |+| CTR-002 | CTR-001 | 控制信号 | 操作员指令 |++---++## 5. 维护注意事项++- **预防性维护**: 每3个月更换P-001和P-002的过滤器+- **预测性维护**: 监测MTR-001和MTR-002的振动数据+- **应急响应**: 每月测试V-002确保正常运行++---++*如需技术支持,请联系:[email protected]*diff --git a/tests/fixtures/test_samples/zh/industry/failure_case.md b/tests/fixtures/test_samples/zh/industry/failure_case.mdnew file mode 100644index 0000000..06944b8--- /dev/null+++ b/tests/fixtures/test_samples/zh/industry/failure_case.md@@ -0,0 +1,121 @@+# 设备故障案例分析报告++**报告编号**: FA-2024-001+**编制日期**: 2024年3月15日+**设备名称**: 自动化装配线A1 - 主电机+**故障日期**: 2024年1月10日++---++## 1. 故障概述++### 1.1 设备信息++| 项目 | 内容 |+|------|------|+| 设备编号 | MTR-001 |+| 设备名称 | 主电机 |+| 规格型号 | DM-750 |+| 制造商 | 动力驱动有限公司 |+| 安装位置 | 制造车间A,一区 |+| 投运日期 | 2022年6月 |++### 1.2 故障现象++2024年1月10日上午9时30分,自动化装配线A1的主电机(MTR-001)运行过程中突然发出异常声响,并伴随振动明显加剧。操作人员立即按下急停按钮,设备停止运行。++**具体现象**:+- 电机发出尖锐的金属摩擦声+- 机身振动幅值超过正常值3倍+- 轴承温度快速上升至85℃+- 变频器显示电流波动异常++---++## 2. 故障分析++### 2.1 初步检查++维修人员到达现场后,首先进行初步检查:++1. **外观检查**:电机外壳无明显损伤,无异常气味+2. **绝缘检测**:绕组绝缘电阻正常,排除短路可能+3. **振动检测**:振动值超标,主要集中在轴承部位+4. **温度检测**:轴承座温度偏高已达85℃++### 2.2 深入分析++经拆解检查,确认故障根本原因如下:++**主要原因**:轴承磨损严重++- 轴承滚道出现明显磨损痕迹+- 滚动体表面有剥落现象+- 润滑脂变质发黑,失去了润滑作用++**次要原因**:长期未进行预防性维护++- 该电机自投运以来未进行过轴承更换+- 润滑脂未按要求定期补充+- 运行负荷长期处于高负荷状态++---++## 3. 处理措施++### 3.1 应急处理++1. 立即停止设备运行,切断电源+2. 标记故障状态,悬挂警示标识+3. 启动备用电机,维持生产++### 3.2 根本处理++1. **更换轴承**:更换同规格轴承(型号:6208-2RS)+2. **补充润滑脂**:使用优质润滑脂(型号:L-XBCHA3)+3. **清洁轴承座**:彻底清除旧润滑脂和杂质+4. **电气检测**:检测绕组阻值,确保电气性能正常++### 3.3 处理结果++| 项目 | 处理前 | 处理后 |+|------|--------|--------|+| 振动值 | 12mm/s | 2.5mm/s |+| 轴承温度 | 85℃ | 42℃ |+| 运行电流 | 波动±15% | 稳定±3% |+| 噪音水平 | 异常尖锐 | 正常 |++---++## 4. 经验教训++### 4.1 教训总结++本次故障给我们的启示:++1. **预防性维护缺失**:轴承已到使用寿命未及时更换,是导致故障的根本原因。应建立设备健康档案,追踪关键部件的使用寿命。++2. **巡检不够细致**:日常巡检未能及时发现轴承异常声响和振动加剧的早期症状。需加强巡检人员的培训,提高故障早期识别能力。++3. **备件管理不足**:备用轴承库存不足,导致维修等待时间延长。应完善备件库存管理,确保关键备件充足。++### 4.2 改进建议++1. **建立预测性维护体系**:引入振动监测和温度监测系统,实现故障预警+2. **完善维护计划**:制定详细的设备维护日历,按时执行维护任务+3. **加强人员培训**:提升操作人员和维修人员的专业技能+4. **优化备件管理**:建立关键备件安全库存机制++---++## 5. 附件++- 故障现场照片+- 轴承检测报告+- 维修记录表++---++**编制人**: 张维修+**审核人**: 李主管+**批准人**: 王经理diff --git a/tests/fixtures/test_samples/zh/industry/inspection_record.md b/tests/fixtures/test_samples/zh/industry/inspection_record.mdnew file mode 100644index 0000000..93eb59b--- /dev/null+++ b/tests/fixtures/test_samples/zh/industry/inspection_record.md@@ -0,0 +1,102 @@+# 设备日常巡检记录++**巡检单位**: 设备维护部+**巡检日期**: 2024年3月15日+**巡检类型**: 日例巡检+**巡检人**: 张三++---++## 1. 巡检概况++本次巡检覆盖自动化装配线A1全部设备,包括数控加工中心、机械臂系统、物料输送系统、冷却系统及电气控制系统。巡检从上午9:00开始,至11:30结束。++---++## 2. 巡检项目与结果++### 2.1 数控加工中心巡检++| 巡检项 | 发现内容 | 措施 | 状态 |+|--------|---------|------|------|+| 电机运行状态 | 运行平稳,无异常声响 | 正常,继续观察 | ✅ 正常 |+| 轴承温度 | 温度显示42℃,在正常范围内 | 正常,保持监测 | ✅ 正常 |+| 润滑油位 | 油位正常,无泄漏 | 正常 | ✅ 正常 |+| 刀具状态 | 刀具磨损在允许范围内 | 正常 | ✅ 正常 |+| 冷却液位 | 冷却液位偏低 | 补充冷却液 | ⚠️ 已处理 |++**补充冷却液**:发现M-001数控加工中心冷却液位偏低,立即补充冷却液至正常液位。++### 2.2 机械臂系统巡检++| 巡检项 | 发现内容 | 措施 | 状态 |+|--------|---------|------|------|+| 机械臂R1运行 | 运行正常,动作流畅 | 正常 | ✅ 正常 |+| 机械臂R2运行 | 运行正常 | 正常 | ✅ 正常 |+| 机械臂R3状态 | 处于备用状态 | 正常 | ✅ 正常 |+| 夹具夹持力 | 夹持力正常 | 正常 | ✅ 正常 |+| 安全护栏 | 护栏闭合正常 | 正常 | ✅ 正常 |++### 2.3 物料输送系统巡检++| 巡检项 | 发现内容 | 措施 | 状态 |+|--------|---------|------|------|+| 传送带运行 | 运行平稳,无跑偏 | 正常 | ✅ 正常 |+| AGV-001状态 | 电量85%,运行正常 | 正常 | ✅ 正常 |+| AGV-002状态 | 电量92%,运行正常 | 正常 | ✅ 正常 |+| 传感器状态 | 传感器清洁,信号正常 | 正常 | ✅ 正常 |++### 2.4 冷却系统巡检++| 巡检项 | 发现内容 | 措施 | 状态 |+|--------|---------|------|------|+| 冷却泵A运行 | 运行正常,压力稳定 | 正常 | ✅ 正常 |+| 冷却泵B运行 | 运行正常 | 正常 | ✅ 正常 |+| 温度传感器T1 | 显示温度正常 | 正常 | ✅ 正常 |+| 过滤器状态 | 过滤器清洁 | 正常 | ✅ 正常 |++### 2.5 电气控制系统巡检++| 巡检项 | 发现内容 | 措施 | 状态 |+|--------|---------|------|------|+| 主控制柜 | 无异常报警 | 正常 | ✅ 正常 |+| 变频器运行 | 运行参数正常 | 正常 | ✅ 正常 |+| 电缆连接 | 连接牢固,无松动 | 正常 | ✅ 正常 |+| 接地系统 | 接地良好 | 正常 | ✅ 正常 |++---++## 3. 异常情况汇总++### 3.1 已处理异常++| 序号 | 设备 | 异常描述 | 处理措施 | 处理结果 |+|------|------|---------|---------|----------|+| 1 | 数控加工中心M-001 | 冷却液位偏低 | 补充冷却液 | 已恢复 |++---++## 4. 巡检总结++### 4.1 总体评价++本次巡检整体情况良好,各设备运行正常。仅发现1处轻微异常(冷却液位偏低),已现场处理完毕。++### 4.2 建议事项++1. 建议增加冷却液液位监测频次,防止再次出现液位过低情况+2. AGV-001电量消耗较快,建议检查电池状态+3. 建议定期清洁传感器,确保检测精度++### 4.3 下次巡检计划++- 巡检日期:2024年3月18日+- 巡检类型:周例巡检+- 重点关注:冷却系统运行状态、AGV电池续航能力++---++**巡检人签字**: 张三+**日期**: 2024年3月15日+**审核人**: 李四+**审核日期**: 2024年3月15日diff --git a/tests/fixtures/test_samples/zh/industry/operating_mode.md b/tests/fixtures/test_samples/zh/industry/operating_mode.mdnew file mode 100644index 0000000..f4df5f5--- /dev/null+++ b/tests/fixtures/test_samples/zh/industry/operating_mode.md@@ -0,0 +1,239 @@+# 自动化装配线A1 工况切换说明书++**文档编号**: OM-2024-001+**版本**: v1.0+**编制日期**: 2024年2月+**适用设备**: 自动化装配线A1++---++## 1. 概述++本文档说明自动化装配线A1的运行模式及工况切换条件。操作人员应严格按照本说明书进行工况切换操作,确保设备安全运行。++---++## 2. 运行模式++自动化装配线A1支持以下几种运行模式:++### 2.1 关机模式++**模式说明**: 设备完全停止运行,所有系统断电。++**适用条件**:+- 生产任务结束+- 设备维护保养+- 长期停机++**负荷范围**: 0%++### 2.2 待机模式++**模式说明**: 设备处于热待机状态,主电源保持供电,控制系统就绪,可快速启动。++**适用条件**:+- 生产前准备+- 生产间隙暂停+- 短暂休息++**负荷范围**: 5-10%++### 2.3 手动调试模式++**模式说明**: 设备由操作人员手动控制,用于设备调试、检修和故障排查。++**适用条件**:+- 设备调试+- 检修作业+- 故障排查+- 新程序测试++**负荷范围**: 0-30%++### 2.4 自动运行模式++**模式说明**: 设备按照预设程序自动运行,无需人工干预。++**适用条件**:+- 正常生产运行+- 大批量生产++**负荷范围**: 30-100%++### 2.5 紧急停止模式++**模式说明**: 设备立即停止所有动作,切断动力源。++**适用条件**:+- 发生紧急情况+- 设备故障+- 人员安全受到威胁++**负荷范围**: 0%++---++## 3. 工况切换++### 3.1 关机模式 → 待机模式++**切换条件**:+- 合上主电源开关+- 控制系统自检通过++**切换步骤**:+1. 合上主电源开关+2. 启动辅助系统+3. 控制系统自检+4. 进入待机状态++**切换时间**: 约30秒++### 3.2 待机模式 → 手动调试模式++**切换条件**:+- 按下手动手柄+- 选择手动模式++**切换步骤**:+1. 按下手动手柄+2. 在HMI上选择手动模式+3. 确认模式切换+4. 进入手动调试状态++**切换时间**: 约5秒++### 3.3 手动调试模式 → 待机模式++**切换条件**:+- 关闭手柄开关+- 选择退出手动模式++**切换步骤**:+1. 关闭手柄开关+2. 在HMI上选择退出手动模式+3. 确认退出+4. 返回待机状态++**切换时间**: 约3秒++### 3.4 待机模式 → 自动运行模式++**切换条件**:+- 生产任务就绪+- 物料充足+- 所有子系统正常+- 按下自动启动按钮++**切换步骤**:+1. 确认生产任务已下达+2. 确认物料充足+3. 确认各系统状态正常+4. 按下自动启动按钮+5. 系统加载生产程序+6. 逐步提升运行速度+7. 进入自动运行状态++**切换时间**: 约60秒++### 3.5 自动运行模式 → 待机模式++**切换条件**:+- 生产任务完成+- 按下暂停按钮++**切换步骤**:+1. 按下暂停按钮+2. 等待当前工序完成+3. 设备停止自动运行+4. 保持电源供电+5. 进入待机状态++**切换时间**: 约30秒++### 3.6 自动运行模式 → 紧急停止模式++**切换条件**:+- 按下急停按钮+- 检测到严重故障+- 安全护栏被打开++**切换步骤**:+1. 按下急停按钮(或触发故障)+2. 立即停止所有运动部件+3. 切断主电源+4. 启动报警装置+5. 进入紧急停止状态++**切换时间**: 立即++### 3.7 紧急停止模式 → 待机模式++**切换条件**:+- 故障已排除+- 现场安全确认+- 按下复位按钮++**切换步骤**:+1. 确认故障已排除+2. 确认现场安全+3. 关闭急停按钮+4. 按下复位按钮+5. 系统自检+6. 进入待机状态++**切换时间**: 约60秒++---++## 4. 工况切换流程图++```+ ┌──────────────┐+ │ 关机模式 │+ └──────┬───────┘+ │+ ┌──────▼───────┐+ │ 待机模式 │+ └──────┬───────┘+ │+ ┌──────────────┴──────────────┐+ │ │+ ┌──────▼───────┐ ┌───────▼──────┐+ │ 手动调试模式 │ │ 自动运行模式 │+ └──────┬───────┘ └──────┬───────┘+ │ │+ └──────────┬───────────────────┘+ │+ ┌──────▼───────┐+ │ 紧急停止模式 │+ └──────────────┘+```++---++## 5. 注意事项++1. **安全第一**: 任何工况切换都必须确保人员安全+2. **顺序执行**: 必须按照切换步骤顺序执行,不得跳过步骤+3. **状态确认**: 切换前必须确认当前状态满足切换条件+4. **异常处理**: 切换过程中出现异常应立即停止并上报++---++## 6. 负荷与工况对照表++| 工况 | 负荷范围 | 说明 |+|------|---------|------|+| 关机模式 | 0% | 完全断电 |+| 待机模式 | 5-10% | 热待机 |+| 手动调试模式 | 0-30% | 低负荷调试 |+| 自动运行模式 | 30-100% | 正常生产 |+| 紧急停止模式 | 0% | 立即停止 |++---++**编制人**: 设备部+**审核人**: 技术部+**批准人**: 生产部diff --git a/tests/fixtures/test_samples/zh/industry/operation_flow.md b/tests/fixtures/test_samples/zh/industry/operation_flow.mdnew file mode 100644index 0000000..71d7c6b--- /dev/null+++ b/tests/fixtures/test_samples/zh/industry/operation_flow.md@@ -0,0 +1,189 @@+# 自动化装配线A1 开机操作规程++**规程编号**: OP-2024-001+**版本**: v2.1+**编制日期**: 2024年2月+**适用设备**: 自动化装配线A1++---++## 1. 适用范围++本规程适用于自动化装配线A1的开机操作,包括数控加工中心、机械臂系统、物料输送系统和质量检测站的开机流程。++---++## 2. 开机前检查++### 2.1 环境检查++| 检查项目 | 检查内容 | 状态 |+|---------|---------|------|+| 温度 | 环境温度应在15-30℃范围内 | □ |+| 湿度 | 相对湿度应在40-70%范围内 | □ |+| 清洁度 | 设备周围无杂物、无积水 | □ |++### 2.2 设备检查++| 检查项目 | 检查内容 | 状态 |+|---------|---------|------|+| 电源 | 主电源电压正常,三相平衡 | □ |+| 气源 | 气压维持在0.5-0.7MPa | □ |+| 润滑 | 各润滑点油脂充足 | □ |+| 安全装置 | 急停按钮、防护门锁正常 | □ |++---++## 3. 开机流程++### 3.1 第一步:开启辅助系统++**操作步骤**:开启控制柜辅助电源++- 打开控制柜门+- 合上辅助电源开关+- 确认辅助电源指示灯亮起++**预期结果**:辅助电源正常接通,控制面板显示就绪状态++**触发条件**:辅助电源正常++### 3.2 第二步:启动液压系统++**操作步骤**:启动液压站++- 按下液压站启动按钮+- 等待液压压力上升至设定值+- 检查液压油位是否正常++**预期结果**:液压压力稳定在3.5MPa,油位正常++**触发条件**:液压压力达到设定值++### 3.3 第三步:启动冷却系统++**操作步骤**:开启冷却泵++- 打开冷却泵电源开关+- 调节冷却液流量至合适值+- 检查冷却液温度++**预期结果**:冷却系统正常运行,进出口温差在5-10℃++**触发条件**:冷却泵运行无异常++### 3.4 第四步:启动控制系统++**操作步骤**:启动主控制系统++- 在HMI上选择"自动模式"+- 点击"系统启动"按钮+- 等待系统自检完成++**预期结果**:HMI显示"系统就绪",无报警信息++**触发条件**:系统自检通过++### 3.5 第五步:激活伺服系统++**操作步骤**:启动伺服驱动++- 依次启动各轴伺服驱动器+- 等待伺服系统就绪+- 执行原点复归操作++**预期结果**:各轴回到参考原点,位置显示正确++**触发条件**:伺服系统无故障++### 3.6 第六步:启动物料输送系统++**操作步骤**:开启传送带和AGV++- 启动传送带电机+- 激活AGV导航系统+- 设定输送路径++**预期结果**:传送带正常运行,AGV就位待命++**触发条件**:传送带运行平稳++### 3.7 第七步:启动机器人系统++**操作步骤**:激活机械臂++- 启动机械臂控制柜+- 加载加工程序+- 执行机械臂原点复归++**预期结果**:机械臂各关节正常,到达原点位置++**触发条件**:机械臂无碰撞报警++### 3.8 第八步:启动质量检测系统++**操作步骤**:开启检测设备++- 启动视觉检测系统+- 校准检测参数+- 加载检测程序++**预期结果**:检测系统就绪,可正常识别工件++**触发条件**:检测系统自检通过++---++## 4. 全面启动确认++完成上述步骤后,进行全面确认:++| 检查项 | 确认内容 | 结果 |+|-------|---------|------|+| 系统状态 | 所有子系统显示"就绪" | □ |+| 通信状态 | 各设备通信正常 | □ |+| 安全状态 | 安全门关闭,急停释放 | □ |+| 生产模式 | 切换至自动生产模式 | □ |++---++## 5. 开机异常处理++### 5.1 液压压力不足++- 检查液压油是否充足+- 检查液压泵是否正常+- 检查是否有泄漏++### 5.2 冷却系统报警++- 检查冷却液位+- 检查冷却泵运行状态+- 清洗冷却过滤器++### 5.3 伺服系统故障++- 检查伺服驱动器报警代码+- 检查电机连接+- 执行故障复位++---++## 6. 关机流程++### 6.1 正常关机++1. 停止物料输入+2. 等待当前工序完成+3. 依次停止各子系统+4. 关闭主电源++### 6.2 紧急关机++按下急停按钮,设备立即停止,然后按照正常流程检查后重新启动。++---++**编制人**: 设备部+**审核人**: 技术部+**批准人**: 生产部diff --git a/tests/fixtures/test_samples/zh/industry/safety_control.md b/tests/fixtures/test_samples/zh/industry/safety_control.mdnew file mode 100644index 0000000..75106f9--- /dev/null+++ b/tests/fixtures/test_samples/zh/industry/safety_control.md@@ -0,0 +1,156 @@+# 自动化装配线A1 安全管控手册++**文档编号**: SC-2024-001+**版本**: v1.5+**编制日期**: 2024年2月+**适用范围**: 自动化装配线A1全体作业人员++---++## 1. 总则++### 1.1 编制目的++为加强自动化装配线A1的安全生产管理,预防和减少生产安全事故,保障员工生命安全和身体健康,特制定本手册。++### 1.2 适用范围++本手册适用于自动化装配线A1的所有作业活动,包括设备操作、检修维护、巡检检查等。++---++## 2. 危险源辨识++### 2.1 设备类危险源++| 序号 | 危险源名称 | 危险因素 | 可能导致后果 |+|------|-----------|---------|-------------|+| 1 | 数控加工中心 | 高温部件、旋转部件 | 烫伤、机械伤害 |+| 2 | 工业机械臂 | 运动部件、夹持力 | 挤压伤害、撞击伤害 |+| 3 | 冷却系统 | 高压液体、温度变化 | 烫伤、冻伤 |+| 4 | 液压站 | 高压油液、密封件老化 | 高压射流伤害 |+| 5 | 电气控制柜 | 电气元件、高压电源 | 触电、电击伤害 |++### 2.2 环境类危险源++| 序号 | 危险源名称 | 危险因素 | 可能导致后果 |+|------|-----------|---------|-------------|+| 1 | 车间通道 | 地面油污、物件堆放 | 摔伤、绊倒 |+| 2 | 物料堆放区 | 物料倾倒、不稳定 | 砸伤、碰撞 |+| 3 | 噪声区域 | 设备运行噪声 | 听力损伤 |+| 4 | 化学品存储 | 有毒有害化学品 | 中毒、化学灼伤 |++### 2.3 行为类危险源++| 序号 | 危险源名称 | 危险因素 | 可能导致后果 |+|------|-----------|---------|-------------|+| 1 | 违章操作 | 违反操作规程 | 设备损坏、人身伤害 |+| 2 | 疲劳作业 | 连续作业、休息不足 | 反应迟钝、误操作 |+| 3 | 防护缺失 | 未佩戴防护用品 | 人身伤害 |++---++## 3. 风险点与管控措施++### 3.1 机械设备风险++| 风险点 | 风险等级 | 管控措施 | 责任人 |+|--------|---------|---------|--------|+| 数控加工中心操作 | 重大风险 | 1. 严格按照操作规程作业 2. 佩戴防护眼镜和防护手套 3. 禁止在设备运行时打开防护门 4. 定期检查防护装置有效性 | 设备负责人 |+| 机械臂运行区域 | 重大风险 | 1. 设置安全围栏和警示标识 2. 安装光幕保护装置 3. 作业前确认安全区域无人 4. 严禁违规进入运行区域 | 班组长 |+| 液压系统检修 | 较大风险 | 1. 检修前先泄压 2. 佩戴防护手套和防护眼镜 3. 使用专业工具进行检修 4. 检修后进行压力测试 | 维修工 |++### 3.2 电气安全风险++| 风险点 | 风险等级 | 管控措施 | 责任人 |+|--------|---------|---------|--------|+| 电气柜操作 | 重大风险 | 1. 持有电工作业证人员方可操作 2. 作业前进行验电确认 3. 佩戴绝缘鞋和绝缘手套 4. 禁止带电作业 | 电工 |+| 临时用电 | 较大风险 | 1. 办理临时用电审批 2. 使用合格的电气设备 3. 定期检查线路绝缘性能 4. 做到一机一闸一保护 | 设备负责人 |+| 静电防护 | 一般风险 | 1. 穿戴防静电工作服 2. 设备接地可靠 3. 保持环境湿度适宜 | 安全员 |++### 3.3 化学安全风险++| 风险点 | 风险等级 | 管控措施 | 责任人 |+|--------|---------|---------|--------|+| 冷却液使用 | 较大风险 | 1. 佩戴防护手套和防护眼镜 2. 保持工作场所通风 3. 避免皮肤直接接触 4. 定期检测冷却液浓度 | 设备负责人 |+| 润滑油脂 | 一般风险 | 1. 佩戴防护手套 2. 避免入口和眼睛接触 3. 使用专用工具添加 4. 废油统一回收处理 | 维修工 |+| 清洗剂使用 | 较大风险 | 1. 在通风处使用 2. 佩戴防毒面具 3. 远离火源存放 4. 按照MSDS要求操作 | 班组长 |++### 3.4 环境安全风险++| 风险点 | 风险等级 | 管控措施 | 责任人 |+|--------|---------|---------|--------|+| 通道堵塞 | 一般风险 | 1. 保持通道畅通 2. 不在通道堆放物料 3. 及时清理油污和杂物 4. 设置防滑设施 | 班组长 |+| 噪声危害 | 一般风险 | 1. 佩戴耳塞或耳罩 2. 控制在噪声源 3. 定期进行噪声检测 4. 合理安排作业时间 | 安全员 |+| 物料堆放 | 较大风险 | 1. 堆放整齐稳固 2. 不超过规定高度 3. 留出安全通道 4. 定期检查堆放状态 | 仓库管理员 |++---++## 4. 个人防护用品++### 4.1 必须配备的防护用品++| 防护用品 | 适用区域 | 更换周期 | 责任人 |+|---------|---------|---------|--------|+| 安全帽 | 全体作业区域 | 损坏时更换 | 员工个人 |+| 防护眼镜 | 加工区、检修区 | 损坏时更换 | 员工个人 |+| 防护手套 | 接触化学品、机械设备时 | 损坏时更换 | 员工个人 |+| 耳塞/耳罩 | 噪声区域 | 每周更换 | 员工个人 |+| 绝缘鞋 | 电气作业区域 | 6个月更换 | 员工个人 |+| 防静电工作服 | 全体作业区域 | 1年更换 | 员工个人 |++### 4.2 防护用品使用规定++1. 作业前必须正确佩戴防护用品+2. 防护用品损坏或失效必须立即更换+3. 严禁私自改装或拆卸防护装置+4. 离职或调岗时必须归还防护用品++---++## 5. 安全责任体系++### 5.1 各级人员安全责任++| 角色 | 安全职责 |+|------|---------|+| 总经理 | 全面负责公司安全生产工作 |+| 安全主管 | 负责安全管理体系建设、安全监督检查 |+| 设备负责人 | 负责设备安全运行、隐患排查整改 |+| 班组长 | 负责本班组安全管理、员工安全教育 |+| 作业人员 | 严格遵守安全规程、正确使用防护用品 |++### 5.2 安全考核与奖惩++- 每月进行安全绩效考核+- 发现隐患及时上报给予奖励+- 违章作业按规定进行处罚+- 年度安全先进给予表彰++---++## 6. 隐患排查与整改++### 6.1 隐患排查频次++| 排查类型 | 频次 | 负责人 |+|---------|------|--------|+| 日常巡检 | 每日 | 当班员工 |+| 周检查 | 每周 | 班组长 |+| 月度检查 | 每月 | 设备负责人 |+| 专项检查 | 每季度 | 安全主管 |++### 6.2 隐患整改流程++1. 发现隐患,记录隐患信息+2. 评估隐患等级,确定整改措施+3. 下发整改通知,落实整改责任+4. 实施整改,验收整改结果+5. 销号归档,持续改进++---++**编制人**: 安全环保部+**审核人**: 生产部+**批准人**: 总经理+**生效日期**: 2024年2月15日diff --git a/tests/fixtures/test_samples/zh/industry/system_topology.md b/tests/fixtures/test_samples/zh/industry/system_topology.mdnew file mode 100644index 0000000..6f6031d--- /dev/null+++ b/tests/fixtures/test_samples/zh/industry/system_topology.md@@ -0,0 +1,185 @@+# A工厂系统架构说明书++**文档编号**: SA-2024-001+**版本**: v1.0+**编制日期**: 2024年1月++---++## 1. 工厂概述++A工厂是公司旗下的现代化制造工厂,位于工业园区内,占地面积约50000平方米。工厂主要从事电子产品制造和精密加工业务。++### 1.1 工厂规模++| 项目 | 数据 |+|------|------|+| 占地面积 | 50000平方米 |+| 建筑面积 | 35000平方米 |+| 员工人数 | 约500人 |+| 年产值 | 5亿元 |++---++## 2. 厂区布局++A工厂由以下几个主要功能区域组成:++### 2.1 生产区域++| 区域名称 | 功能 | 面积 |+|---------|------|------|+| 制造车间A | 自动化装配生产线 | 8000平方米 |+| 制造车间B | 精密加工中心 | 6000平方米 |+| 制造车间C | 组装车间 | 5000平方米 |++### 2.2 辅助区域++| 区域名称 | 功能 | 面积 |+|---------|------|------|+| 仓库区 | 原材料和成品存储 | 10000平方米 |+| 动力站 | 供电、供水、供气 | 2000平方米 |+| 办公区 | 行政办公 | 3000平方米 |++---++## 3. 生产系统++### 3.1 制造车间A - 自动化装配生产线++制造车间A是工厂的核心生产车间,主要包含以下系统:++#### 3.1.1 数控加工系统++| 设备名称 | 规格 | 数量 | 功能 |+|---------|------|------|------|+| 数控加工中心Alpha | TM-5000X | 2台 | 精密零件加工 |+| 数控加工中心Beta | TM-5000X | 2台 | 精密零件加工 |++#### 3.1.2 机器人系统++| 设备名称 | 规格 | 数量 | 功能 |+|---------|------|------|------|+| 工业机械臂R1 | AR-200 | 3台 | 工件搬运与装配 |+| 工业机械臂R2 | AR-200 | 3台 | 工件搬运与装配 |+| 工业机械臂R3 | AR-150 | 2台 | 备用机械臂 |++#### 3.1.3 物料输送系统++| 设备名称 | 规格 | 数量 | 功能 |+|---------|------|------|------|+| 传送带系统 | CT-500 | 1套 | 工件输送 |+| 自动导引车AGV | LM-1000 | 4台 | 物料配送 |++#### 3.1.4 辅助系统++| 系统名称 | 功能 |+|---------|------|+| 冷却系统 | 为数控设备提供冷却 |+| 润滑系统 | 为机械设备提供润滑 |+| 液压系统 | 为气动设备提供动力 |+| 除尘系统 | 保持车间清洁 |++### 3.2 制造车间B - 精密加工中心++制造车间B主要承担高精度零件加工任务:++| 系统名称 | 主要设备 | 功能 |+|---------|---------|------|+| 车削系统 | 数控车床4台 | 零件车削加工 |+| 铣削系统 | 数控铣床3台 | 零件铣削加工 |+| 磨削系统 | 精密磨床2台 | 零件精磨加工 |+| 检测系统 | 三坐标测量仪 | 尺寸检测 |++### 3.3 制造车间C - 组装车间++制造车间C负责产品组装:++| 系统名称 | 功能 |+|---------|------|+| 总装线 | 产品总装配 |+| 测试线 | 产品功能测试 |+| 包装线 | 产品包装入库 |++---++## 4. 动力系统++### 4.1 供电系统++| 项目 | 数据 |+|------|------|+| 变压器容量 | 2000KVA |+| 供电电压 | 10KV |+| 备用电源 | 柴油发电机500KW |++### 4.2 供水系统++| 项目 | 数据 |+|------|------|+| 日供水量 | 200吨 |+| 供水压力 | 0.3MPa |++### 4.3 供气系统++| 项目 | 数据 |+|------|------|+| 空压机 | 3台 |+| 供气压力 | 0.7MPa |++---++## 5. 层级结构汇总++A工厂系统层级结构如下:++```+A工厂+├── 制造车间A+│ ├── 数控加工系统+│ │ ├── 数控加工中心Alpha+│ │ └── 数控加工中心Beta+│ ├── 机器人系统+│ │ ├── 工业机械臂R1+│ │ ├── 工业机械臂R2+│ │ └── 工业机械臂R3+│ ├── 物料输送系统+│ │ ├── 传送带系统+│ │ └── 自动导引车AGV+│ └── 辅助系统+│ ├── 冷却系统+│ ├── 润滑系统+│ ├── 液压系统+│ └── 除尘系统+├── 制造车间B+│ ├── 车削系统+│ ├── 铣削系统+│ ├── 磨削系统+│ └── 检测系统+├── 制造车间C+│ ├── 总装线+│ ├── 测试线+│ └── 包装线+├── 仓库区+├── 动力站+│ ├── 供电系统+│ ├── 供水系统+│ └── 供气系统+└── 办公区+```++---++## 6. 系统关联++各系统之间存在以下关联关系:++- 制造车间A、B、C共享动力站的供电、供水、供气服务+- 仓库区为三个制造车间提供原材料供应和成品存放+- 物料输送系统连接各制造车间,实现物料流通++---++**编制人**: 工程部+**审核人**: 技术部+**批准人**: 厂领导