|
const network = require("./network.json") |
|
const nodes = network.nodes; |
|
const links = network.links; |
|
const node_by_url = new Map(nodes.map(node => [node.id, node])) |
|
|
|
const data_array = []; |
|
for (const link of links) { |
|
const target_node = node_by_url.get(link.source) |
|
const texts = [node_by_url.get(link.target).title].concat(node_by_url.get(link.target).body_text.split(/\n|。|./)) |
|
.map(text => text ? text.replace(/\s/g, "") : "") |
|
if (texts.length > 2) { |
|
for (const text of texts) { |
|
if (target_node.title && text) { |
|
data_array.push({ text: text, title: target_node.title.replace(/,/g, " ") }) |
|
} |
|
} |
|
} |
|
} |
|
|
|
console.log(JSON.stringify(data_array)); |