forked from psmuts/devart-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdummy_data.py
More file actions
43 lines (35 loc) · 1.84 KB
/
Copy pathdummy_data.py
File metadata and controls
43 lines (35 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
__author__ = 'psmuts'
#explore using numpy to modify elements of word array such as rather than requerying source
#experiment, if I change the data, does D# automatically change presentation (javascript)
#When a new word comes into word universe, append to dictionary, do not create a new
import random
import io, json
i = 0
j = 0
word_map = {0:"noun",1:"verb",2:"adjective",3:"adverb"}
nodes_collection = {"nodes":[], "links":[]}
for i in range(0,1000):
#words 1:noun,2:adjective,3:verb,4:adverb
node_dict = {"word": word_map[j], "type": str(j), "radi":str(random.randint(1,40))}
nodes_collection["nodes"].append(node_dict)
link_dict = {"source": i, "target": random.randint(0,len(nodes_collection)),"value": random.randint(1,300)}
nodes_collection["links"].append(link_dict)
link_dict = {"source": i, "target": random.randint(0,len(nodes_collection)),"value": random.randint(1,10)}
nodes_collection["links"].append(link_dict)
link_dict = {"source": i, "target": random.randint(0,len(nodes_collection)),"value": random.randint(1,600)}
nodes_collection["links"].append(link_dict)
link_dict = {"source": i, "target": random.randint(0,len(nodes_collection)),"value": random.randint(1,10)}
nodes_collection["links"].append(link_dict)
link_dict = {"source": i, "target": random.randint(0,len(nodes_collection)),"value": random.randint(1,30)}
nodes_collection["links"].append(link_dict)
link_dict = {"source": i, "target": random.randint(0,len(nodes_collection)),"value": random.randint(1,1)}
nodes_collection["links"].append(link_dict)
#be cool to generate links to each other word type
if j < 2:
j += 1
else:
j = 0
i += 1
with io.open('test_3.json', 'w', encoding='utf-8') as f:
f.write(unicode(json.dumps(nodes_collection, ensure_ascii=False)))
print(json.dumps(nodes_collection))