Upload 3 files
Browse files- sentences.json +2 -2
- src/app.js +12 -10
sentences.json
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:be92f4c5c80d5e7d218d6e3b826f7b0eec0416c1d809cc2ecd5c8a5a6f626ccb
|
3 |
+
size 2424063
|
src/app.js
CHANGED
@@ -1,18 +1,20 @@
|
|
1 |
const network = require("./network.json")
|
2 |
const nodes = network.nodes;
|
3 |
const links = network.links;
|
4 |
-
const node_by_url = new Map(nodes.map(node=>[node.id, node]))
|
5 |
|
6 |
-
|
7 |
-
for(const link of links) {
|
8 |
const target_node = node_by_url.get(link.source)
|
9 |
-
const texts = [node_by_url.get(link.target).title].concat(node_by_url.get(link.target).body_text
|
10 |
-
.map(text=>text ? text.replace(/\s/g, "") : "")
|
11 |
-
if(texts.length > 2) {
|
12 |
-
for(const text of texts) {
|
13 |
-
if(target_node.title && text) {
|
14 |
-
|
15 |
}
|
16 |
}
|
17 |
}
|
18 |
-
}
|
|
|
|
|
|
1 |
const network = require("./network.json")
|
2 |
const nodes = network.nodes;
|
3 |
const links = network.links;
|
4 |
+
const node_by_url = new Map(nodes.map(node => [node.id, node]))
|
5 |
|
6 |
+
const data_array = [];
|
7 |
+
for (const link of links) {
|
8 |
const target_node = node_by_url.get(link.source)
|
9 |
+
const texts = [node_by_url.get(link.target).title].concat(node_by_url.get(link.target).body_text.split(/\n|。|./))
|
10 |
+
.map(text => text ? text.replace(/\s/g, "") : "")
|
11 |
+
if (texts.length > 2) {
|
12 |
+
for (const text of texts) {
|
13 |
+
if (target_node.title && text) {
|
14 |
+
data_array.push({ text: text, title: target_node.title.replace(/,/g, " ") })
|
15 |
}
|
16 |
}
|
17 |
}
|
18 |
+
}
|
19 |
+
|
20 |
+
console.log(JSON.stringify(data_array));
|