Skip to content

Hypergraph is more powerful. Transform unstructured text into structured knowledge with LLMs. Graphs, hypergraphs, and spatio-temporal extractions — with one command.

docs: unsmash JSON-LD and Cypher export pages

Frankie-Xu2ced70b25c90
diff --git a/docs/en/cli/commands/export.md b/docs/en/cli/commands/export.md
index 7f16680..23aeb24 100644
--- a/docs/en/cli/commands/export.md
+++ b/docs/en/cli/commands/export.md
@@ -170,18 +170,21 @@ he export graphml ./tesla_kb/ -o ./tesla.graphml
## he export jsonld
Export a knowledge graph to JSON-LD (stdlib `json`, no RDFLib). Binary edges are `@type: Edge` with `source` / `target`. Edges with three or more endpoints are `@type: Hyperedge` with an `endpoint` list in extractor order (never sorted). 0/1-endpoint or missing-endpoint edges are skipped with a warning, same as GraphML.
-## he export cypher
-
-Export a Neo4j / Memgraph-compatible Cypher MERGE script (`cypher-shell < file.cypher`). Binary edges become relationships (`:REL`, or a legal `type`/`label` ident). Edges with three or more endpoints become `(:Hyperedge)` nodes plus `(n)-[:IN]->(h)` in extractor order — never a pairwise clique. 0/1-endpoint or missing-endpoint edges are skipped with a warning.
Existing non-empty output files require `--force` / `-f`.
### Synopsis
```bash
-he export jsonld KA_PATH -o FILE.jsonld [--force]
+he export jsonld KA_PATH -o FILE.jsonld
```
+### Arguments
+
+| Argument | Description |
+|----------|-------------|
+| `KA_PATH` | Path to the knowledge abstract directory (created by `he parse`) |
+
### Options
| Option | Alias | Default | Description |
@@ -194,9 +197,35 @@ he export jsonld KA_PATH -o FILE.jsonld [--force]
```bash
he export jsonld ./tesla_kb/ -o ./tesla.jsonld
he export jsonld ./tesla_kb/ -o ./tesla.jsonld --force
-he export cypher KA_PATH -o FILE.cypher [--force]
```
+---
+
+## he export cypher
+
+Export a Neo4j / Memgraph-compatible Cypher MERGE script (`cypher-shell < file.cypher`). Binary edges become relationships (`:REL`, or a legal `type`/`label` ident). Edges with three or more endpoints become `(:Hyperedge)` nodes plus `(n)-[:IN]->(h)` in extractor order — never a pairwise clique. 0/1-endpoint or missing-endpoint edges are skipped with a warning.
+
+Existing non-empty output files require `--force` / `-f`.
+
+### Synopsis
+
+```bash
+he export cypher KA_PATH -o FILE.cypher
+```
+
+### Arguments
+
+| Argument | Description |
+|----------|-------------|
+| `KA_PATH` | Path to the knowledge abstract directory (created by `he parse`) |
+
+### Options
+
+| Option | Alias | Default | Description |
+|--------|-------|---------|-------------|
+| `--output` | `-o` | *(required)* | Output Cypher file |
+| `--force` | `-f` | off | Overwrite an existing non-empty file |
+
### Examples
```bash
@@ -256,7 +285,7 @@ he export csv ./tesla_kb/ -o ./tesla_csv/ --force
## Python API
-The same capability is available on graph Auto-Types for Obsidian, and as standalone functions for GraphML / CSV / JSON-LD (they are not methods on AutoType):
+The same capability is available on graph Auto-Types for Obsidian, and as standalone functions for GraphML / CSV / JSON-LD / Cypher (they are not methods on AutoType):
```python
ka.export_obsidian("./tesla_vault/", vault_name="Tesla KB", overwrite=True)
@@ -286,12 +315,17 @@ export_to_csv(
)
export_to_jsonld(
-export_to_cypher(
ka.nodes,
ka.edges,
node_id_extractor=ka.node_key_extractor,
incident_nodes_extractor=ka.nodes_in_edge_extractor,
file_path="./tesla.jsonld",
+)
+export_to_cypher(
+ ka.nodes,
+ ka.edges,
+ node_id_extractor=ka.node_key_extractor,
+ incident_nodes_extractor=ka.nodes_in_edge_extractor,
file_path="./tesla.cypher",
)
```
diff --git a/docs/zh/cli/commands/export.md b/docs/zh/cli/commands/export.md
index 851cf57..d13ff40 100644
--- a/docs/zh/cli/commands/export.md
+++ b/docs/zh/cli/commands/export.md
@@ -2,8 +2,7 @@
将知识摘要导出为 [Obsidian](https://obsidian.md) 知识库——一个由 `[[双向链接]]` 关联的 Markdown 笔记文件夹。
-`export` 是一个命令组。目前支持的格式:`obsidian`、`graphml`、`jsonld`、`csv`。
-`export` 是一个命令组。目前支持的格式:`obsidian`、`graphml`、`cypher`、`csv`。
+`export` 是一个命令组。目前支持的格式:`obsidian`、`graphml`、`jsonld`、`cypher`、`csv`。
---
@@ -171,18 +170,21 @@ he export graphml ./tesla_kb/ -o ./tesla.graphml
## he export jsonld
将知识图谱导出为 JSON-LD(标准库 `json`,不引入 RDFLib)。二元边为 `@type: Edge`,带 `source` / `target`。三个及以上端点的边为 `@type: Hyperedge`,`endpoint` 列表保持抽取器顺序(不排序)。0/1 个端点或缺失端点的边会跳过并记 warning,与 GraphML 一致。
-## he export cypher
-
-导出 Neo4j / Memgraph 可用的 Cypher MERGE 脚本(`cypher-shell < file.cypher`)。二元边写成关系(`:REL`,或合法的 `type`/`label` ident)。三个及以上端点的边写成 `(:Hyperedge)` 节点,并用 `(n)-[:IN]->(h)` 按抽取器顺序连接——不会拆成两两团。0/1 个端点或缺失端点的边会跳过并记 warning。
目标文件已存在且非空时需要 `--force` / `-f`。
### 用法
```bash
-he export jsonld KA_PATH -o FILE.jsonld [--force]
+he export jsonld KA_PATH -o FILE.jsonld
```
+### 参数
+
+| 参数 | 说明 |
+|----------|-------------|
+| `KA_PATH` | 知识摘要目录路径(由 `he parse` 生成) |
+
### 选项
| 选项 | 别名 | 默认值 | 说明 |
@@ -195,9 +197,35 @@ he export jsonld KA_PATH -o FILE.jsonld [--force]
```bash
he export jsonld ./tesla_kb/ -o ./tesla.jsonld
he export jsonld ./tesla_kb/ -o ./tesla.jsonld --force
-he export cypher KA_PATH -o FILE.cypher [--force]
```
+---
+
+## he export cypher
+
+导出 Neo4j / Memgraph 可用的 Cypher MERGE 脚本(`cypher-shell < file.cypher`)。二元边写成关系(`:REL`,或合法的 `type`/`label` ident)。三个及以上端点的边写成 `(:Hyperedge)` 节点,并用 `(n)-[:IN]->(h)` 按抽取器顺序连接——不会拆成两两团。0/1 个端点或缺失端点的边会跳过并记 warning。
+
+目标文件已存在且非空时需要 `--force` / `-f`。
+
+### 用法
+
+```bash
+he export cypher KA_PATH -o FILE.cypher
+```
+
+### 参数
+
+| 参数 | 说明 |
+|----------|-------------|
+| `KA_PATH` | 知识摘要目录路径(由 `he parse` 生成) |
+
+### 选项
+
+| 选项 | 别名 | 默认值 | 说明 |
+|--------|-------|---------|-------------|
+| `--output` | `-o` | *(必填)* | 输出 Cypher 文件 |
+| `--force` | `-f` | 关闭 | 覆盖已存在的非空文件 |
+
### 示例
```bash
@@ -257,7 +285,7 @@ he export csv ./tesla_kb/ -o ./tesla_csv/ --force
## Python API
-Obsidian 导出是图谱 Auto-Type 上的方法;GraphML / CSV / JSON-LD 是独立纯函数(不会加到 AutoType 上):
+Obsidian 导出是图谱 Auto-Type 上的方法;GraphML / CSV / JSON-LD / Cypher 是独立纯函数(不会加到 AutoType 上):
```python
ka.export_obsidian("./tesla_vault/", vault_name="Tesla KB", overwrite=True)
@@ -287,12 +315,17 @@ export_to_csv(
)
export_to_jsonld(
-export_to_cypher(
ka.nodes,
ka.edges,
node_id_extractor=ka.node_key_extractor,
incident_nodes_extractor=ka.nodes_in_edge_extractor,
file_path="./tesla.jsonld",
+)
+export_to_cypher(
+ ka.nodes,
+ ka.edges,
+ node_id_extractor=ka.node_key_extractor,
+ incident_nodes_extractor=ka.nodes_in_edge_extractor,
file_path="./tesla.cypher",
)
```