-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscratchbook.py
41 lines (34 loc) · 1.22 KB
/
scratchbook.py
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
41
import os, sys
from neo4j import GraphDatabase
if __name__ == "__main__":
SCRIPT_DIR = os.path.dirname(
os.path.realpath(os.path.join(os.getcwd(), os.path.expanduser(__file__)))
)
MODULE_ROOT_DIR = os.path.join(SCRIPT_DIR, "..")
sys.path.insert(0, os.path.normpath(MODULE_ROOT_DIR))
from dict2graph_tests._test_tools import wipe_all_neo4j_data
wipe_all_neo4j_data(GraphDatabase.driver("neo4j://localhost"))
from neo4j import GraphDatabase
from dict2graph import Dict2graph, Transformer, NodeTrans
data = {"bookshelf": {"Genre": "Explaining the world"}}
d2g = Dict2graph()
d2g.add_transformation(
[
Transformer.match_nodes("bookshelf").do(NodeTrans.AddProperty({"mtr": "wood"})),
Transformer.match_nodes("bookshelf").do(
NodeTrans.OverridePropertyName("mtr", "material")
),
]
)
d2g.parse(data)
NEO4J_DRIVER = GraphDatabase.driver("neo4j://localhost")
d2g.create(NEO4J_DRIVER)
t = {
"article": {
"title": "Blood money: Bayer's inventory of HIV-contaminated blood products and third world hemophiliacs",
"author": {
"name": "Leemon McHenry",
"affiliation": "Department of Philosophy, California State University",
},
},
}