Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.
feat(templates): 添加通用基础模板并更新文档
yifanfeng979d1bc79232ef
diff --git a/hyperextract/templates/README.md b/hyperextract/templates/README.mdindex e7ffa09..43a190d 100644--- a/hyperextract/templates/README.md+++ b/hyperextract/templates/README.md@@ -79,6 +79,19 @@ print(Gallery.list_all())The default choice for unstructured text that doesn't fit a specific industry.+* **Base Templates**: General-purpose knowledge extraction templates covering all AutoType primitives. Use these as building blocks or extend them for domain-specific needs.++| Template | Primitive | Description | Use Case |+| :--- | :--- | :--- | :--- |+| **`BaseModel`** | `AutoModel` | General-purpose structured object extraction | Universal single-object extraction |+| **`BaseList`** | `AutoList` | General-purpose ordered list extraction | Universal list extraction |+| **`BaseSet`** | `AutoSet` | General-purpose entity deduplication | Universal entity collection |+| **`BaseGraph`** | `AutoGraph` | General-purpose knowledge graph extraction | Universal binary relation extraction |+| **`BaseHypergraph`** | `AutoHypergraph` | General-purpose hypergraph extraction | Universal multi-entity relation extraction |+| **`BaseTemporalGraph`** | `AutoTemporalGraph` | General-purpose temporal graph extraction | Universal time-ordered relation extraction |+| **`BaseSpatialGraph`** | `AutoSpatialGraph` | General-purpose spatial graph extraction | Universal location-aware relation extraction |+| **`BaseSpatioTemporalGraph`** | `AutoSpatioTemporalGraph` | General-purpose spatio-temporal graph extraction | Universal time & location relation extraction |+* **Arbitrary Text (Universal Extraction)**: Any type of text for direct entity and relationship extraction.| Template | Primitive | Description | Use Case |diff --git a/hyperextract/templates/README_ZH.md b/hyperextract/templates/README_ZH.mdindex e15752d..3608dce 100644--- a/hyperextract/templates/README_ZH.md+++ b/hyperextract/templates/README_ZH.md@@ -79,6 +79,19 @@ print(Gallery.list_all())适用于无法归类或多领域交叉的文本,通过提取基础实体和SPO关系构建通用图谱。+* **通用结构知识模板**:覆盖所有 AutoType 原语的基础模板。可直接使用或作为领域模板的扩展基础。++| 模板 | 原语 | 描述 | 应用场景 |+| :--- | :--- | :--- | :--- |+| **`BaseModel`** | `AutoModel` | 通用结构模型提取 | 通用单一对象提取 |+| **`BaseList`** | `AutoList` | 通用列表提取 | 通用有序列表提取 |+| **`BaseSet`** | `AutoSet` | 通用实体集合去重 | 通用实体汇总 |+| **`BaseGraph`** | `AutoGraph` | 通用图谱提取 | 通用二元关系提取 |+| **`BaseHypergraph`** | `AutoHypergraph` | 通用超图提取 | 通用多元关系提取 |+| **`BaseTemporalGraph`** | `AutoTemporalGraph` | 通用时序图谱提取 | 通用时间有序关系提取 |+| **`BaseSpatialGraph`** | `AutoSpatialGraph` | 通用空间图谱提取 | 通用位置感知关系提取 |+| **`BaseSpatioTemporalGraph`** | `AutoSpatioTemporalGraph` | 通用时空图谱提取 | 通用时间与位置关系提取 |+* **任意文本 (通用提取)**:适用于任何类型的文本,直接提取其中的实体及关系。| 模板 | 原语 | 描述 | 应用场景 |diff --git a/hyperextract/templates/presets/general/base_graph.yaml b/hyperextract/templates/presets/general/base_graph.yamlnew file mode 100644index 0000000..c372ddc--- /dev/null+++ b/hyperextract/templates/presets/general/base_graph.yaml@@ -0,0 +1,104 @@+language: [zh, en]++name: graph+type: graph+tags: [general, graph]++description:+ zh: '通用图结构知识模板 - 从任意文本中提取实体节点及实体之间的二元关系,构建简单知识图谱。'+ en: 'General-purpose Graph Knowledge Template - Extracts entity nodes and binary relations between entities from any text, constructing a simple knowledge graph.'++output:+ description:+ zh: '由实体节点和关系边组成的知识图谱结果。'+ en: 'Knowledge graph result consisting of entity nodes and relation edges.'+ entities:+ description:+ zh: '文本中可独立识别、可参与关系连接的实体节点。'+ en: 'Entity nodes that can be independently identified and participate in relation connections.'+ fields:+ - name: name+ type: str+ description:+ zh: '实体名称,使用文本中最明确、最稳定的称呼。'+ en: 'Entity name, using the most explicit and stable designation in the text.'+ - name: type+ type: str+ description:+ zh: '实体类型,如人物、地点、组织、物品、概念、事件、制度、技术等。'+ en: 'Entity type, such as person, location, organization, object, concept, event, institution, technology, etc.'+ - name: description+ type: str+ description:+ zh: '对实体身份、含义或其在当前文本中作用的简要说明。'+ en: 'Brief description of the entity identity, meaning, or its role in the current text.'+ required: false+ relations:+ description:+ zh: '实体之间的显式语义关系边。'+ en: 'Explicit semantic relation edges between entities.'+ fields:+ - name: source+ type: str+ description:+ zh: '关系起点实体,必须对应已提取实体的 name。'+ en: 'Source entity of the relation, must correspond to the name of an extracted entity.'+ - name: target+ type: str+ description:+ zh: '关系终点实体,必须对应已提取实体的 name。'+ en: 'Target entity of the relation, must correspond to the name of an extracted entity.'+ - name: type+ type: str+ description:+ zh: '关系类型,使用简洁明确的语义词概括两个实体之间的连接方式。'+ en: 'Relation type, using concise and clear semantic words to describe the connection between two entities.'+ - name: description+ type: str+ description:+ zh: '对关系依据、方向或上下文含义的简要说明。'+ en: 'Brief description of the relation basis, direction, or contextual meaning.'+ required: false++guideline:+ target:+ zh: '你是一位知识抽取与知识图谱构建专家。请从文本中识别关键实体,并构建这些实体之间的二元关系。'+ en: 'You are an expert in knowledge extraction and knowledge graph construction. Identify key entities from the text and construct binary relations between them.'+ rules_for_entities:+ zh:+ - '提取对理解文本事实、结构或逻辑有价值的实体。'+ - 'name 使用原文中最明确、最稳定的称呼;同一实体在全文中保持命名一致。'+ - 'type 需概括实体类别,可使用通用类型标签。'+ - 'description 用 1 句话概括实体的身份或作用;若信息不足可留空。'+ en:+ - 'Extract entities that are valuable for understanding text facts, structure, or logic.'+ - 'Use the most explicit and stable designation in the source text for names; maintain consistent naming for the same entity.'+ - 'Use type to summarize the entity category using general type labels.'+ - 'Describe the entity in 1 sentence; leave empty if information is insufficient.'+ rules_for_relations:+ zh:+ - '仅在文本明确表达两个实体之间存在语义联系时创建关系,不要凭常识补充隐含关系。'+ - 'source 和 target 必须直接引用已提取实体的 name,不能新造实体名称。'+ - 'type 使用简洁、方向清晰的关系词。'+ - 'description 简要说明关系依据或上下文;若文本没有额外信息可留空。'+ - '避免重复关系;若同一对实体存在多种不同关系,可分别记录。'+ en:+ - 'Create relation edges only when the text explicitly expresses a semantic connection between two entities.'+ - 'Source and target must directly reference the name of an extracted entity; do not create new entity names.'+ - 'Use concise relation words with clear direction.'+ - 'Briefly describe the relation basis or context; leave empty if no additional information is available.'+ - 'Avoid duplicate relations; if the same pair of entities has multiple different relations, record them separately.'++identifiers:+ entity_id: name+ relation_id: '{source}|{type}|{target}'+ relation_members:+ source: source+ target: target++options:+ extraction_mode: two_stage++display:+ entity_label: '{name} ({type})'+ relation_label: '{type}'diff --git a/hyperextract/templates/presets/general/base_hypergraph.yaml b/hyperextract/templates/presets/general/base_hypergraph.yamlnew file mode 100644index 0000000..3e69db2--- /dev/null+++ b/hyperextract/templates/presets/general/base_hypergraph.yaml@@ -0,0 +1,102 @@+language: [zh, en]++name: base_hypergraph+type: hypergraph+tags: [general]++description:+ zh: '通用超图结构知识模板 - 从任意文本中提取超图结构,包含节点(实体、概念、地点等)以及连接多个节点的多元关系超边(事件、会议、合作、冲突等)。'+ en: 'General-purpose Hypergraph Knowledge Template - Extracts hypergraph structure from any text, containing nodes (entities, concepts, locations, etc.) and multi-node relation hyperedges (events, meetings, cooperation, conflicts, etc.).'++output:+ description:+ zh: '提取出来的超图结构,包含节点和超边。'+ en: 'Extracted hypergraph structure containing nodes and hyperedges.'+ nodes:+ description:+ zh: '文本中可独立识别的节点,如实体、概念、地点等基本语义单元。'+ en: 'Nodes that can be independently identified in the text, such as entities, concepts, locations, or other basic semantic units.'+ fields:+ - name: name+ type: str+ description:+ zh: '节点名称,使用文本中最明确、最稳定的称呼。'+ en: 'Node name, using the most explicit and stable designation in the text.'+ - name: type+ type: str+ description:+ zh: '节点类型,如实体、概念、地点、组织、物品等。'+ en: 'Node type, such as entity, concept, location, organization, object, etc.'+ - name: description+ type: str+ description:+ zh: '对节点身份或作用的简要说明。'+ en: 'Brief description of the node identity or role.'+ required: false+ hyperedges:+ description:+ zh: '连接多个节点的多元关系超边,如事件、会议、合作、冲突、交易等。'+ en: 'Multi-node relation hyperedges connecting multiple nodes, such as events, meetings, cooperation, conflicts, transactions, etc.'+ fields:+ - name: name+ type: str+ description:+ zh: '该超边的名称或标题,用于唯一标识这条多元关系。'+ en: 'Name or title of this hyperedge, used to uniquely identify this multi-node relation.'+ - name: type+ type: str+ description:+ zh: '超边的类型,如事件、会议、合作、冲突、交易、协议等。'+ en: 'Type of the hyperedge, such as event, meeting, cooperation, conflict, transaction, agreement, etc.'+ - name: participants+ type: list+ description:+ zh: '参与该超边的所有节点名称列表。'+ en: 'List of all node names participating in this hyperedge.'+ - name: description+ type: str+ description:+ zh: '对该超边内容或结果的简要说明。'+ en: 'Brief description of the hyperedge content or result.'+ required: false++guideline:+ target:+ zh: '你是一位关系抽取专家。请从文本中提取超图结构,包括:1)可独立识别的节点(实体、概念、地点等);2)连接多个节点的多元关系超边(事件、会议、合作等)。'+ en: 'You are an expert in relation extraction. Extract hypergraph structure from the text, including: 1) independently identifiable nodes (entities, concepts, locations, etc.); 2) multi-node relation hyperedges (events, meetings, cooperation, etc.).'+ rules_for_nodes:+ zh:+ - '提取文本中可识别的节点,如实体、概念、地点、组织、物品等基本语义单元。'+ - 'name 使用原文中最稳定、最清晰的称呼。'+ - 'type 概括节点的类别,如实体、概念、地点、组织、物品等。'+ - 'description 用 1 句话概括节点身份或作用;若信息不足可留空。'+ en:+ - 'Extract identifiable nodes from the text, such as entities, concepts, locations, organizations, objects, or other basic semantic units.'+ - 'Use the most stable and clear designation in the source text for names.'+ - 'Use type to summarize the node category, such as entity, concept, location, organization, object, etc.'+ - 'Describe the node in 1 sentence; leave empty if information is insufficient.'+ rules_for_hyperedges:+ zh:+ - '仅在文本明确表达多个节点共同参与某个事件或关系时创建超边。'+ - 'participants 必须全部引用已提取节点的 name。'+ - 'name 用简洁的词语概括该超边的核心内容。'+ - 'type 概括该超边的类型,如事件、会议、合作、冲突、交易、协议等。'+ - 'description 简要说明超边内容或结果;无额外信息时可留空。'+ en:+ - 'Create hyperedges only when the text explicitly expresses that multiple nodes jointly participate in an event or relation.'+ - 'All participants must reference the names of extracted nodes.'+ - 'Use concise words for name to summarize the core content of this hyperedge.'+ - 'Use type to characterize the hyperedge type, such as event, meeting, cooperation, conflict, transaction, agreement, etc.'+ - 'Briefly describe the hyperedge content or result; leave empty if no additional information is available.'++identifiers:+ node_id: name+ hyperedge_id: '{name}|{type}'+ hyperedge_members: participants++options:+ extraction_mode: two_stage++display:+ node_label: '{name} ({type})'+ hyperedge_label: '{name}'diff --git a/hyperextract/templates/presets/general/base_list.yaml b/hyperextract/templates/presets/general/base_list.yamlnew file mode 100644index 0000000..d2ba068--- /dev/null+++ b/hyperextract/templates/presets/general/base_list.yaml@@ -0,0 +1,45 @@+language: [zh, en]++name: list+type: list+tags: [general, list]++description:+ zh: '通用列表结构知识模板 - 从任意文本中提取项目列表,每个项目可以是关键词、标签、要点或任意文本片段。'+ en: 'General-purpose List Knowledge Template - Extracts a list of items from any text, where items can be keywords, tags, points, or any text fragments.'++output:+ description:+ zh: '从文本中提取的列表结果。'+ en: 'List result extracted from the text.'+ fields:+ - name: item+ type: str+ description:+ zh: '列表项内容,直接引用或概括原文中的相关内容。'+ en: 'Content of the list item, directly quoted or summarized from the source text.'+ - name: type+ type: str+ description:+ zh: '列表项的类型或分类标签。'+ en: 'Type or category label of the list item.'+ required: false++guideline:+ target:+ zh: '你是一位列表提取专家。请从文本中提取所有符合要求的列表项。'+ en: 'You are a list extraction expert. Extract all qualifying list items from the text.'+ rules:+ zh:+ - '提取所有符合要求的列表项,不遗漏。'+ - 'item 直接引用原文或用简洁语言概括。'+ - 'type 用于区分不同类型的项;如无需区分可留空。'+ - '去除无意义或重复的列表项。'+ en:+ - 'Extract all qualifying list items without omission.'+ - 'Quote directly or summarize items concisely.'+ - 'Use type to distinguish different types; leave empty if unnecessary.'+ - 'Remove meaningless or duplicate items.'++display:+ label: '{item}'diff --git a/hyperextract/templates/presets/general/base_model.yaml b/hyperextract/templates/presets/general/base_model.yamlnew file mode 100644index 0000000..d32d500--- /dev/null+++ b/hyperextract/templates/presets/general/base_model.yaml@@ -0,0 +1,51 @@+language: [zh, en]++name: base_model+type: model+tags: [general]++description:+ zh: '通用结构模型知识模板 - 从任意文本中提取单个结构化对象,包含对象的名称和简要描述。'+ en: 'General-purpose Model Knowledge Template - Extracts a single structured object from any text, including its name and brief description.'++output:+ description:+ zh: '单个结构化对象的结果。'+ en: 'Result of a single structured object.'+ fields:+ - name: name+ type: str+ description:+ zh: '对象的名称或标题,使用文本中最稳定、最清晰的称呼。'+ en: 'Name or title of the object, using the most stable and clear designation in the text.'+ - name: description+ type: str+ description:+ zh: '对象的简要描述,概括其身份、含义或在文本中的作用。'+ en: 'Brief description of the object, summarizing its identity, meaning, or role in the text.'+ required: false+ - name: type+ type: str+ description:+ zh: '对象的类型或分类标签。'+ en: 'Type or category label of the object.'+ required: false++guideline:+ target:+ zh: '你是一位信息提取专家。请从文本中提取一个核心对象,并提供其名称和简要描述。'+ en: 'You are an information extraction expert. Extract one core object from the text and provide its name and brief description.'+ rules:+ zh:+ - '提取文本中核心的、结构化的对象。'+ - 'name 使用原文中最稳定、最清晰的称呼。'+ - 'description 用 1-2 句话概括对象的身份或作用。'+ - 'type 概括对象的类型,如无法确定可留空。'+ en:+ - 'Extract the core, structured object from the text.'+ - 'Use the most stable and clear designation for name.'+ - 'Describe the object in 1-2 sentences.'+ - 'Categorize the object; leave empty if unclassifiable.'++display:+ label: '{name}'diff --git a/hyperextract/templates/presets/general/base_set.yaml b/hyperextract/templates/presets/general/base_set.yamlnew file mode 100644index 0000000..72e8e17--- /dev/null+++ b/hyperextract/templates/presets/general/base_set.yaml@@ -0,0 +1,57 @@+language: [zh, en]++name: base_set+type: set+tags: [general]++description:+ zh: '通用实体集合结构知识模板 - 从任意文本中识别并去重关键实体,汇总为可复用的实体清单。'+ en: 'General-purpose Entity Set Knowledge Template - Identifies and deduplicates key entities from any text, aggregating them into a reusable entity registry.'++output:+ description:+ zh: '去重后的实体列表结果。'+ en: 'Deduplicated entity list result.'+ fields:+ - name: name+ type: str+ description:+ zh: '实体名称,优先使用文本中最稳定、最清晰的称呼。'+ en: 'Entity name, using the most stable and clear designation in the text.'+ - name: type+ type: str+ description:+ zh: '实体类型,如人物、机构、地点、物品、概念、事件、其他。'+ en: 'Entity type, such as person, organization, location, object, concept, event, other.'+ - name: description+ type: str+ description:+ zh: '对实体身份、含义或在文本中作用的简要说明。'+ en: 'Brief description of the entity identity, meaning, or role in the text.'+ required: false++guideline:+ target:+ zh: '你是一位实体识别专家。请从文本中识别具有独立意义的实体,并将重复出现的同一实体合并为一条记录。'+ en: 'You are an entity recognition expert. Identify entities with independent meaning from the text and merge duplicate entities into a single record.'+ rules:+ zh:+ - '提取对理解文本内容有意义的实体。'+ - 'name 使用文本中最清晰、最稳定的称呼;同一实体若有简称或别称,应统一为一个名称。'+ - 'type 用于概括实体类型,尽量准确且可复用。'+ - 'description 用 1 句话说明实体是谁、是什么或在文本中的作用;信息不足时可留空。'+ - '对同一实体进行去重,不要因表述差异重复输出多条。'+ - '不要把纯代词、泛称、临时描述短语或无独立指代意义的词语当作实体。'+ en:+ - 'Extract entities that are meaningful for understanding the text content.'+ - 'Use the clearest and most stable designation for names; unify names with aliases or nicknames.'+ - 'Use type to summarize the entity category.'+ - 'Describe the entity in 1 sentence; leave empty if information is insufficient.'+ - 'Deduplicate entities; do not output multiple records for the same entity.'+ - 'Do not treat pure pronouns, generic terms, or non-referential phrases as entities.'++identifiers:+ item_id: name++display:+ label: '{name}'diff --git a/hyperextract/templates/presets/general/base_spatial_graph.yaml b/hyperextract/templates/presets/general/base_spatial_graph.yamlnew file mode 100644index 0000000..eb62150--- /dev/null+++ b/hyperextract/templates/presets/general/base_spatial_graph.yaml@@ -0,0 +1,126 @@+language: [zh, en]++name: base_spatial_graph+type: spatial_graph+tags: [general]++description:+ zh: '通用空间图结构知识模板 - 从任意文本中提取实体之间的关系,并在文本提供位置信息时为关系补充空间属性。'+ en: 'General-purpose Spatial Graph Knowledge Template - Extracts relationships between entities from any text and supplements spatial attributes when location information is available.'++output:+ description:+ zh: '提取出来的空间图谱结构,包含实体节点、关系边及位置信息。'+ en: 'Extracted spatial graph structure containing entity nodes, relation edges, and location information.'+ entities:+ description:+ zh: '文本中可独立识别、可参与关系连接的实体节点。'+ en: 'Entity nodes that can be independently identified and participate in relation connections.'+ fields:+ - name: name+ type: str+ description:+ zh: '实体名称,使用文本中最明确、最稳定的称呼。'+ en: 'Entity name, using the most explicit and stable designation in the text.'+ - name: type+ type: str+ description:+ zh: '实体类型,如人物、地点、组织、物品、概念、事件、制度等。'+ en: 'Entity type, such as person, location, organization, object, concept, event, institution, etc.'+ - name: description+ type: str+ description:+ zh: '对实体身份、含义或其在当前文本中作用的简要说明。'+ en: 'Brief description of the entity identity, meaning, or its role in the current text.'+ required: false+ relations:+ description:+ zh: '实体之间的关系边;若文本提供位置,可在关系上补充位置属性。'+ en: 'Relation edges between entities; spatial attributes can be added when location information is provided.'+ fields:+ - name: source+ type: str+ description:+ zh: '关系起点实体,必须对应已提取实体的 name。'+ en: 'Source entity of the relation, must correspond to the name of an extracted entity.'+ - name: target+ type: str+ description:+ zh: '关系终点实体,必须对应已提取实体的 name。'+ en: 'Target entity of the relation, must correspond to the name of an extracted entity.'+ - name: relation_type+ type: str+ description:+ zh: '关系类型,用简洁词语概括两个实体之间的连接方式。'+ en: 'Relation type, concisely describing the connection between two entities.'+ - name: location+ type: str+ description:+ zh: '关系对应的位置信息;无明确位置时可留空。'+ en: 'Location information associated with the relation; can be left empty if no explicit location is available.'+ required: false+ - name: description+ type: str+ description:+ zh: '对关系的简要补充说明;无额外信息时可留空。'+ en: 'Brief supplementary explanation for the relation; can be left empty if no additional information is available.'+ required: false++guideline:+ target:+ zh: '你是一位空间知识图谱构建专家。请从文本中提取关键实体及其关系;如果文本提供了位置信息,再为关系补充空间属性。'+ en: 'You are an expert in spatial knowledge graph construction. Extract key entities and their relationships from the text; supplement spatial attributes when location information is provided.'+ rules_for_entities:+ zh:+ - '提取对理解文本事实有价值,且能够参与关系连接的实体。'+ - 'name 使用原文中最稳定、最清晰的称呼;同一实体在全文中保持命名一致。'+ - 'type 需概括实体类别。'+ - 'description 用 1 句话概括实体身份或作用;若信息不足可留空。'+ en:+ - 'Extract entities that are valuable for understanding text facts, and that can participate in relation connections.'+ - 'Use the most stable and clear designation in the source text for names; maintain consistent naming for the same entity.'+ - 'Use type to summarize the entity category.'+ - 'Describe the entity in 1 sentence; leave empty if information is insufficient.'+ rules_for_relations:+ zh:+ - '仅在文本明确表达两个实体之间存在关系时创建关系边。'+ - 'source 和 target 必须直接引用已提取实体的 name。'+ - 'relation_type 使用简洁关系词概括。'+ - 'location 是可选字段;没有明确位置时也要保留关系边,并将 location 留空。'+ - 'description 简要说明关系依据或上下文;无额外信息时可留空。'+ en:+ - 'Create relation edges only when the text explicitly expresses a relationship between two entities.'+ - 'Source and target must directly reference the name of an extracted entity.'+ - 'Use concise relational words for relation_type.'+ - 'location is optional; retain the relation edge even without explicit location, and leave location empty.'+ - 'Briefly describe the relation basis or context; leave empty if no additional information is available.'+ rules_for_location:+ zh:+ - '当前观察位置:{observation_location}'+ - 'location 是可选字段;仅在文本明确提供位置,或可依据相对位置可靠确定时填写。'+ - '没有明确位置时,仍应保留关系边,并将 location 留空。'+ - '优先使用文本中的原始位置表达;可接受地名、地址、区域等。'+ - '若关系涉及空间转移或分布,可在 location 中标注起点和终点。'+ - '无法可靠确定位置时留空,不要根据常识补写。'+ en:+ - 'Current observation location: {observation_location}'+ - 'location is optional; fill in only when the text explicitly provides location or when relative location can be reliably determined.'+ - 'Retain the relation edge even without explicit location, and leave location empty.'+ - 'Prefer to use the original location expression from the text; place names, addresses, and regions are acceptable.'+ - 'If the relation involves spatial transfer or distribution, indicate the start and end points in location.'+ - 'Leave empty when location cannot be reliably determined.'++identifiers:+ entity_id: name+ relation_id: '{source}|{relation_type}|{target}'+ relation_members:+ source: source+ target: target+ location_field: location++options:+ extraction_mode: two_stage++display:+ entity_label: '{name} ({type})'+ relation_label: '{relation_type}'diff --git a/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml b/hyperextract/templates/presets/general/base_spatio_temporal_graph.yamlnew file mode 100644index 0000000..c0de810--- /dev/null+++ b/hyperextract/templates/presets/general/base_spatio_temporal_graph.yaml@@ -0,0 +1,142 @@+language: [zh, en]++name: base_spatio_temporal_graph+type: spatio_temporal_graph+tags: [general]++description:+ zh: '通用时空图结构知识模板 - 从任意文本中提取实体之间的关系,并在文本提供时间和位置信息时为关系补充时空属性。'+ en: 'General-purpose Spatio-Temporal Graph Knowledge Template - Extracts relationships between entities from any text and supplements temporal and spatial attributes when such information is available.'++output:+ description:+ zh: '提取出来的时空图谱结构,包含实体节点、关系边、时间信息和位置信息。'+ en: 'Extracted spatio-temporal graph structure containing entity nodes, relation edges, temporal information, and location information.'+ entities:+ description:+ zh: '文本中可独立识别、可参与关系连接的实体节点。'+ en: 'Entity nodes that can be independently identified and participate in relation connections.'+ fields:+ - name: name+ type: str+ description:+ zh: '实体名称,使用文本中最明确、最稳定的称呼。'+ en: 'Entity name, using the most explicit and stable designation in the text.'+ - name: type+ type: str+ description:+ zh: '实体类型,如人物、地点、组织、物品、概念、事件、制度等。'+ en: 'Entity type, such as person, location, organization, object, concept, event, institution, etc.'+ - name: description+ type: str+ description:+ zh: '对实体身份、含义或其在当前文本中作用的简要说明。'+ en: 'Brief description of the entity identity, meaning, or its role in the current text.'+ required: false+ relations:+ description:+ zh: '实体之间的关系边;若文本提供时间或位置,可在关系上补充时空属性。'+ en: 'Relation edges between entities; temporal and spatial attributes can be added when such information is provided.'+ fields:+ - name: source+ type: str+ description:+ zh: '关系起点实体,必须对应已提取实体的 name。'+ en: 'Source entity of the relation, must correspond to the name of an extracted entity.'+ - name: target+ type: str+ description:+ zh: '关系终点实体,必须对应已提取实体的 name。'+ en: 'Target entity of the relation, must correspond to the name of an extracted entity.'+ - name: event_type+ type: str+ description:+ zh: '关系类型,用简洁词语概括两个实体之间的连接方式。'+ en: 'Relation type, concisely describing the connection between two entities.'+ - name: event_date+ type: str+ description:+ zh: '关系对应的时间;无明确时间时可留空。'+ en: 'Time associated with the relation; can be left empty if no explicit time is available.'+ required: false+ - name: location+ type: str+ description:+ zh: '关系对应的位置信息;无明确位置时可留空。'+ en: 'Location information associated with the relation; can be left empty if no explicit location is available.'+ required: false+ - name: description+ type: str+ description:+ zh: '对关系的简要补充说明;无额外信息时可留空。'+ en: 'Brief supplementary explanation for the relation; can be left empty if no additional information is available.'+ required: false++guideline:+ target:+ zh: '你是一位时空知识图谱构建专家。请从文本中提取关键实体及其关系;如果文本提供了时间或位置信息,再为关系补充相应的时空属性。'+ en: 'You are an expert in spatio-temporal knowledge graph construction. Extract key entities and their relationships from the text; supplement temporal and spatial attributes when such information is provided.'+ rules_for_entities:+ zh:+ - '提取对理解文本事实有价值,且能够参与关系连接的实体。'+ - 'name 使用原文中最稳定、最清晰的称呼;同一实体在全文中保持命名一致。'+ - 'type 需概括实体类别。'+ - 'description 用 1 句话概括实体身份或作用;若信息不足可留空。'+ en:+ - 'Extract entities that are valuable for understanding text facts, and that can participate in relation connections.'+ - 'Use the most stable and clear designation in the source text for names; maintain consistent naming for the same entity.'+ - 'Use type to summarize the entity category.'+ - 'Describe the entity in 1 sentence; leave empty if information is insufficient.'+ rules_for_relations:+ zh:+ - '仅在文本明确表达两个实体之间存在关系时创建关系边。'+ - 'source 和 target 必须直接引用已提取实体的 name。'+ - 'event_type 使用简洁关系词概括。'+ - 'event_date 是可选字段;没有明确时间时也要保留关系边,并将 event_date 留空。'+ - 'location 是可选字段;没有明确位置时也要保留关系边,并将 location 留空。'+ - 'description 简要说明关系依据或上下文;无额外信息时可留空。'+ en:+ - 'Create relation edges only when the text explicitly expresses a relationship between two entities.'+ - 'Source and target must directly reference the name of an extracted entity.'+ - 'Use concise relational words for event_type.'+ - 'event_date is optional; retain the relation edge even without explicit time, and leave event_date empty.'+ - 'location is optional; retain the relation edge even without explicit location, and leave location empty.'+ - 'Briefly describe the relation basis or context; leave empty if no additional information is available.'+ rules_for_time:+ zh:+ - '当前观察日期:{observation_time}'+ - 'event_date 是可选字段;仅在文本明确提供时间,或可依据相对时间可靠换算时填写。'+ - '若文本给出明确年份,则写为 YYYY;若给出完整日期,则写为 YYYY-MM-DD。'+ - '无法可靠确定时间时留空。'+ en:+ - 'Current observation date: {observation_time}'+ - 'event_date is optional; fill in only when the text explicitly provides time or when relative time can be reliably converted.'+ - 'Write years as YYYY; write full dates as YYYY-MM-DD.'+ - 'Leave empty when time cannot be reliably determined.'+ rules_for_location:+ zh:+ - '当前观察位置:{observation_location}'+ - 'location 是可选字段;仅在文本明确提供位置时填写。'+ - '优先使用文本中的原始位置表达。'+ - '无法可靠确定位置时留空。'+ en:+ - 'Current observation location: {observation_location}'+ - 'location is optional; fill in only when the text explicitly provides location.'+ - 'Prefer to use the original location expression from the text.'+ - 'Leave empty when location cannot be reliably determined.'++identifiers:+ entity_id: name+ relation_id: '{source}|{event_type}|{target}'+ relation_members:+ source: source+ target: target+ time_field: event_date+ location_field: location++options:+ extraction_mode: two_stage++display:+ entity_label: '{name} ({type})'+ relation_label: '{event_type}'diff --git a/hyperextract/templates/presets/general/base_temporal_graph.yaml b/hyperextract/templates/presets/general/base_temporal_graph.yamlindex e8ac4d9..3c066db 100644--- a/hyperextract/templates/presets/general/base_temporal_graph.yaml+++ b/hyperextract/templates/presets/general/base_temporal_graph.yaml@@ -5,17 +5,17 @@ type: temporal_graphtags: [general]description:- zh: '基础时序图谱模板 - 从文本中提取实体之间的关系,并在文本提供时间信息时为关系补充时间属性,用于表达事实、事件或状态的连接及其时间上下文。'- en: 'Base Temporal Graph Template - Extracts relationships between entities from text and supplements temporal attributes to relations when time information is provided, expressing the connections of facts, events, or states with their temporal context.'+ zh: '通用时序图结构知识模板 - 从任意文本中提取实体之间的关系,并在文本提供时间信息时为关系补充时间属性。'+ en: 'General-purpose Temporal Graph Knowledge Template - Extracts relationships between entities from any text and supplements temporal attributes when time information is available.'output:description:- zh: '包含实体节点、关系边及可选时间信息的时序图谱结构。'- en: 'Temporal graph structure containing entity nodes, relation edges, and optional temporal information.'+ zh: '包含实体节点、关系边及时间信息的时序图谱结果。'+ en: 'Temporal graph result containing entity nodes, relation edges, and temporal information.'entities:description:zh: '文本中可独立识别、可参与关系连接的实体节点。'- en: 'Entity nodes that can be independently identified and participate in relation connections in the text.'+ en: 'Entity nodes that can be independently identified and participate in relation connections.'fields:- name: nametype: str@@ -25,19 +25,18 @@ output:- name: typetype: strdescription:- zh: '实体类型,如人物、地点、组织、物品、概念、事件、制度、其他。'- en: 'Entity type, such as person, location, organization, object, concept, event, institution, or other.'+ zh: '实体类型,如人物、地点、组织、物品、概念、事件、制度等。'+ en: 'Entity type, such as person, location, organization, object, concept, event, institution, etc.'- name: descriptiontype: strdescription:zh: '对实体身份、含义或其在当前文本中作用的简要说明。'en: 'Brief description of the entity identity, meaning, or its role in the current text.'required: false-relations:description:zh: '实体之间的关系边;若文本提供时间,可在关系上补充时间属性。'- en: 'Relation edges between entities; temporal attributes can be added to relations if the text provides time information.'+ en: 'Relation edges between entities; temporal attributes can be added when time information is provided.'fields:- name: sourcetype: str@@ -49,18 +48,18 @@ output:description:zh: '关系终点实体,必须对应已提取实体的 name。'en: 'Target entity of the relation, must correspond to the name of an extracted entity.'- - name: eventType+ - name: event_typetype: strdescription:zh: '关系类型,用简洁词语概括两个实体之间的连接方式。'en: 'Relation type, concisely describing the connection between two entities.'- - name: eventDate+ - name: event_datetype: strdescription:zh: '关系对应的时间;无明确时间时可留空。'en: 'Time associated with the relation; can be left empty if no explicit time is available.'required: false- - name: details+ - name: descriptiontype: strdescription:zh: '对关系的简要补充说明;无额外信息时可留空。'@@ -69,69 +68,61 @@ output:guideline:target:- zh: '你是一位时序知识图谱构建专家。请从文本中提取关键实体,以及这些实体之间的关系;如果文本提供了明确时间,再为关系补充时间属性。'- en: 'You are an expert in temporal knowledge graph construction. Extract key entities and their relationships from the text; if the text provides explicit time information, supplement temporal attributes to the relations.'+ zh: '你是一位时序知识图谱构建专家。请从文本中提取关键实体及其关系;如果文本提供了时间信息,再为关系补充时间属性。'+ en: 'You are an expert in temporal knowledge graph construction. Extract key entities and their relationships from the text; supplement temporal attributes when time information is provided.'rules_for_entities:zh:- - '提取对理解文本事实、事件过程和时间演变有价值,且能够参与关系连接的实体。'- - '为每个实体指定合适类型,如人物、地点、组织、物品、概念、事件、制度、其他。'+ - '提取对理解文本事实、事件过程有价值,且能够参与关系连接的实体。'- 'name 使用原文中最稳定、最清晰的称呼;同一实体在全文中保持命名一致。'- - 'description 用 1 句话概括实体身份、含义或其在文本中的作用;信息不足时可留空。'- - '优先保留在文本中与其他实体存在明确联系的实体;对既不关键也没有明确关系支撑的边缘实体,可不提取。'+ - 'type 需概括实体类别。'+ - 'description 用 1 句话概括实体身份或作用;若信息不足可留空。'en:- - 'Extract entities that are valuable for understanding text facts, event processes, and temporal evolution, and that can participate in relation connections.'- - 'Assign appropriate types to each entity, such as person, location, organization, object, concept, event, institution, or other.'- - 'Use the most stable and clear designation in the source text for names; maintain consistent naming for the same entity throughout the text.'- - 'Use one sentence to summarize entity identity, meaning, or its role in the text; can be left empty if information is insufficient.'- - 'Prioritize retaining entities that have clear connections with other entities in the text; edge entities that are neither critical nor supported by explicit relations may be omitted.'+ - 'Extract entities that are valuable for understanding text facts and event processes, and that can participate in relation connections.'+ - 'Use the most stable and clear designation in the source text for names; maintain consistent naming for the same entity.'+ - 'Use type to summarize the entity category.'+ - 'Describe the entity in 1 sentence; leave empty if information is insufficient.'rules_for_relations:zh:- - '仅在文本明确表达两个实体之间存在关系、事件或状态变化时创建关系边。'- - 'source 和 target 必须直接引用已提取实体的 name,不要新增未提取实体。'- - '只要文本能支持关系成立,就应提取该关系边。'- - 'eventType 使用简洁关系词概括,如属于、位于、任职、合作、参与、影响、发布、签署、相关等。'- - 'eventDate 是可选字段;没有明确时间时也要保留关系边,并将 eventDate 留空。'- - 'details 只补充必要背景或结果,没有额外信息时可留空。'- - '无法确定具体关系对象时,不要强行构造边。'+ - '仅在文本明确表达两个实体之间存在关系时创建关系边。'+ - 'source 和 target 必须直接引用已提取实体的 name。'+ - 'event_type 使用简洁关系词概括。'+ - 'event_date 是可选字段;没有明确时间时也要保留关系边,并将 event_date 留空。'+ - 'description 简要说明关系依据或上下文;无额外信息时可留空。'en:- - 'Create relation edges only when the text explicitly expresses that a relationship, event, or state change exists between two entities.'- - 'Source and target must directly reference the name of an extracted entity; do not create new unextracted entities.'- - 'Extract the relation edge as long as the text supports the establishment of the relationship.'- - 'Use concise relational words for eventType, such as belongs to, located at, employed by, cooperates with, participates in, affects, publishes, signs, related to, etc.'- - 'eventDate is an optional field; retain the relation edge even without explicit time, and leave eventDate empty.'- - 'details should only supplement necessary background or results; can be left empty if no additional information is available.'- - 'Do not forcibly construct edges when the specific relation target cannot be determined.'+ - 'Create relation edges only when the text explicitly expresses a relationship between two entities.'+ - 'Source and target must directly reference the name of an extracted entity.'+ - 'Use concise relational words for event_type.'+ - 'event_date is optional; retain the relation edge even without explicit time, and leave event_date empty.'+ - 'Briefly describe the relation basis or context; leave empty if no additional information is available.'rules_for_time:zh:- '当前观察日期:{observation_time}'- - 'eventDate 是可选字段;仅在文本明确提供时间,或可依据相对时间可靠换算时填写。'- - '没有明确时间时,仍应保留关系边,并将 eventDate 留空。'+ - 'event_date 是可选字段;仅在文本明确提供时间,或可依据相对时间可靠换算时填写。'+ - '没有明确时间时,仍应保留关系边,并将 event_date 留空。'- '相对时间以 observation_time 为基准解析,如"去年/今年/明年""昨天/今天/明天""十年前/五年后"。'- '若文本给出明确年份,则写为 YYYY;若给出完整日期,则写为 YYYY-MM-DD;保留文本可确定的最细粒度。'- - '"年初/年末"可解析为当年 1 月 1 日或 12 月 31 日;朝代、时期名称或模糊历史时间可按原文保留。'- '若时间只对应关系成立、变化或终止中的某一时点,则记录最直接相关的那个时间。'- '无法可靠确定时间时留空,不要根据常识补写。'en:- 'Current observation date: {observation_time}'- - 'eventDate is an optional field; fill in only when the text explicitly provides time or when relative time can be reliably converted.'- - 'Retain the relation edge even without explicit time, and leave eventDate empty.'- - 'Parse relative time based on observation_time, such as "last year/this year/next year," "yesterday/today/tomorrow," "ten years ago/in five years."'- - 'If the text provides an explicit year, write as YYYY; if it provides a complete date, write as YYYY-MM-DD; preserve the finest granularity that can be determined from the text.'- - '"Beginning/end of year" can be parsed as January 1st or December 31st of that year; dynasty names, period names, or vague historical times can be kept in the original text.'- - 'If the time corresponds to only one point among the establishment, change, or termination of the relation, record the most directly relevant time.'- - 'Leave empty when time cannot be reliably determined; do not fill in based on common sense.'+ - 'event_date is optional; fill in only when the text explicitly provides time or when relative time can be reliably converted.'+ - 'Retain the relation edge even without explicit time, and leave event_date empty.'+ - 'Parse relative time based on observation_time.'+ - 'Write years as YYYY; write full dates as YYYY-MM-DD; preserve the finest granularity determinable from the text.'+ - 'If time corresponds to only one point among establishment, change, or termination, record the most directly relevant time.'+ - 'Leave empty when time cannot be reliably determined.'identifiers:entity_id: name- relation_id: '{source}|{eventType}|{details}'+ relation_id: '{source}|{event_type}|{target}'relation_members:source: sourcetarget: target- time_field: 'eventDate'+ time_field: event_dateoptions:extraction_mode: two_stagedisplay:entity_label: '{name} ({type})'- relation_label: '{eventType} ({eventDate})'+ relation_label: '{event_type}'