8
n8n 中文网amn8n.com

学术引用网络构建器

中级

这是一个Document Extraction, Multimodal AI领域的自动化工作流,包含 9 个节点。主要使用 Set, Code, PdfVector, WriteBinaryFile 等节点。 使用PDF向量API构建学术引用网络,用于Gephi可视化

前置要求
  • 无特殊前置要求,导入即可使用
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "meta": {
    "instanceId": "placeholder"
  },
  "nodes": [
    {
      "id": "config-note",
      "name": "配置",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        250,
        150
      ],
      "parameters": {
        "content": "## 引文网络构建器"
      },
      "typeVersion": 1
    },
    {
      "id": "input-params",
      "name": "设置参数",
      "type": "n8n-nodes-base.set",
      "position": [
        450,
        300
      ],
      "parameters": {
        "values": {
          "string": [
            {
              "name": "seedPapers",
              "value": "10.1038/nature12373,12345678,2301.12345"
            },
            {
              "name": "depth",
              "value": "2"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "split-ids",
      "name": "拆分论文ID",
      "type": "n8n-nodes-base.code",
      "position": [
        650,
        300
      ],
      "parameters": {
        "functionCode": "const papers = $json.seedPapers.split(',').map(id => ({ id: id.trim() }));\nreturn papers;"
      },
      "typeVersion": 1
    },
    {
      "id": "pdfvector-fetch",
      "name": "PDF向量 - 获取论文",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "notes": "Fetch details for each paper",
      "position": [
        850,
        300
      ],
      "parameters": {
        "ids": "={{ $json.id }}",
        "fields": [
          "title",
          "authors",
          "year",
          "doi",
          "abstract",
          "totalCitations",
          "totalReferences"
        ],
        "resource": "academic",
        "operation": "fetch"
      },
      "typeVersion": 1
    },
    {
      "id": "fetch-citations",
      "name": "获取引用论文",
      "type": "n8n-nodes-pdfvector.pdfVector",
      "position": [
        1050,
        300
      ],
      "parameters": {
        "limit": 20,
        "query": "=references:{{ $json.doi }}",
        "fields": [
          "title",
          "authors",
          "year",
          "doi",
          "totalCitations"
        ],
        "resource": "academic",
        "operation": "search"
      },
      "typeVersion": 1
    },
    {
      "id": "build-network",
      "name": "构建网络数据",
      "type": "n8n-nodes-base.code",
      "position": [
        1250,
        300
      ],
      "parameters": {
        "functionCode": "// Build network nodes and edges\nconst nodes = [];\nconst edges = [];\n\n// Add main paper as node\nnodes.push({\n  id: $json.doi || $json.id,\n  label: $json.title,\n  size: Math.log($json.totalCitations + 1) * 10,\n  citations: $json.totalCitations,\n  year: $json.year,\n  type: 'seed'\n});\n\n// Add citing papers and edges\nif ($json.citingPapers) {\n  $json.citingPapers.forEach(paper => {\n    nodes.push({\n      id: paper.doi,\n      label: paper.title,\n      size: Math.log(paper.totalCitations + 1) * 5,\n      citations: paper.totalCitations,\n      year: paper.year,\n      type: 'citing'\n    });\n    \n    edges.push({\n      source: paper.doi,\n      target: $json.doi || $json.id,\n      weight: 1\n    });\n  });\n}\n\nreturn { nodes, edges };"
      },
      "typeVersion": 1
    },
    {
      "id": "combine-network",
      "name": "合并网络",
      "type": "n8n-nodes-base.code",
      "position": [
        1450,
        300
      ],
      "parameters": {
        "functionCode": "// Combine all nodes and edges from multiple papers\nconst allNodes = [];\nconst allEdges = [];\n\nitems.forEach(item => {\n  if (item.json.nodes) {\n    allNodes.push(...item.json.nodes);\n  }\n  if (item.json.edges) {\n    allEdges.push(...item.json.edges);\n  }\n});\n\n// Remove duplicate nodes based on ID\nconst uniqueNodes = Array.from(new Map(allNodes.map(node => [node.id, node])).values());\n\nreturn [{ json: { nodes: uniqueNodes, edges: allEdges } }];"
      },
      "typeVersion": 1
    },
    {
      "id": "export-network",
      "name": "导出网络JSON",
      "type": "n8n-nodes-base.writeBinaryFile",
      "position": [
        1650,
        300
      ],
      "parameters": {
        "fileName": "citation_network_{{ $now.format('yyyy-MM-dd') }}.json",
        "fileContent": "={{ JSON.stringify({ nodes: $json.nodes, edges: $json.edges }, null, 2) }}"
      },
      "typeVersion": 1
    },
    {
      "id": "generate-gexf",
      "name": "生成GEXF",
      "type": "n8n-nodes-base.code",
      "position": [
        1650,
        450
      ],
      "parameters": {
        "functionCode": "// Generate Gephi-compatible GEXF format\nconst nodes = $json.nodes;\nconst edges = $json.edges;\n\nlet gexf = `<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<gexf xmlns=\"http://www.gexf.net/1.2draft\" version=\"1.2\">\n  <graph mode=\"static\" defaultedgetype=\"directed\">\n    <nodes>\\n`;\n\nnodes.forEach(node => {\n  gexf += `      <node id=\"${node.id}\" label=\"${node.label}\">\n        <attvalues>\n          <attvalue for=\"citations\" value=\"${node.citations}\"/>\n          <attvalue for=\"year\" value=\"${node.year}\"/>\n        </attvalues>\n      </node>\\n`;\n});\n\ngexf += `    </nodes>\n    <edges>\\n`;\n\nedges.forEach((edge, i) => {\n  gexf += `      <edge id=\"${i}\" source=\"${edge.source}\" target=\"${edge.target}\" weight=\"${edge.weight}\"/>\\n`;\n});\n\ngexf += `    </edges>\n  </graph>\n</gexf>`;\n\nreturn { gexf };"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Set Parameters": {
      "main": [
        [
          {
            "node": "Split Paper IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Combine Network": {
      "main": [
        [
          {
            "node": "Export Network JSON",
            "type": "main",
            "index": 0
          },
          {
            "node": "Generate GEXF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Paper IDs": {
      "main": [
        [
          {
            "node": "PDF Vector - Fetch Papers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Network Data": {
      "main": [
        [
          {
            "node": "Combine Network",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Citing Papers": {
      "main": [
        [
          {
            "node": "Build Network Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "PDF Vector - Fetch Papers": {
      "main": [
        [
          {
            "node": "Fetch Citing Papers",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

中级 - 文档提取, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
中级
节点数量9
分类2
节点类型5
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
PDF Vector

PDF Vector

@pdfvector

A fully featured PDF APIs for developers - Parse any PDF or Word document, extract structured data, and access millions of academic papers - all through simple APIs.

外部链接
在 n8n.io 查看

分享此工作流