Datasets:
File size: 722 Bytes
5c71405 337cf2a 5c71405 337cf2a 5c71405 337cf2a 5c71405 337cf2a |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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)); |