hicham
(Hicham ZMAIMITA)
1
Hi I have one problem with my json file (with tokens = nodes and relations)
i need to import token and relation from json file to create graphe thankyou
{
"text": "CVE-2021-34481",
"start": 0,
"end": 14,
"token_start": 0,
"token_end": 2,
"entityLabel": "CVE"
},
{
"text": "Windows Print Spooler",
"start": 15,
"end": 36,
"token_start": 3,
"token_end": 5,
"entityLabel": "SOFTWARE"
},
{
"text": "CVE-2018-0599",
"start": 75,
"end": 88,
"token_start": 12,
"token_end": 14,
"entityLabel": "CVE"
},
"relations": [
{
"child": 3,
"head": 0,
"relationLabel": "CONCERNED_BY",
"propertiesList": [
]
},
{
"child": 23,
"head": 12,
"relationLabel": "CONCERNED_BY",
"propertiesList": [
]
},
glilienfield
(Gary Lilienfield)
2
What does this represent? How is the data in the json related? Do you have data model it is to map too?
hicham
(Hicham ZMAIMITA)
3
1 this json file was create with NER annotator for vulnerablity information (cve)
2 the tokens will be the nodes and the end of file you find relations between tokens.
3 i need create graph with this 2 informations (tokens and relationlabel)
4 every relation between head and child
5 head & child ="token_start" and i need show "entityLabel" in graphe
thank you
hicham
(Hicham ZMAIMITA)
5
hi
yes that's correct thank you
hicham
(Hicham ZMAIMITA)
6
glilienfield
(Gary Lilienfield)
7
The json seams to be incomplete. In particular, are the nodes organized in a list like the relationships? Can you provide the full file?
hicham
(Hicham ZMAIMITA)
8
glilienfield
(Gary Lilienfield)
9
I found it easier to create the graph with two queries, one for the nodes and one for the relationships. Run the nodes first.
Node Creation:
call apoc.load.json("file:///kg4.json")
yield value
unwind value.tokens as token
call apoc.create.node(["Node", token.entityLabel], {token_start: token.token_start, text: token.text})
yield node
return node
Relationship Creation:
call apoc.load.json("file:///kg4.json")
yield value
unwind value.relations as relation
match(n:Node{token_start: relation.head})
match(m:Node{token_start: relation.child})
CALL apoc.create.relationship(n, relation.relationLabel, {}, m)
yield rel
return rel
Hope this helps.
hicham
(Hicham ZMAIMITA)
10
glilienfield
(Gary Lilienfield)
11
That is just the output of the query, which returns each created relationship. You need to query the database to see the created data.
try:
match(n:Node) return n