Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
09-25-2022 09:36 AM
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": [
]
},
Solved! Go to Solution.
09-26-2022 07:51 PM
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.
09-25-2022 10:03 AM
What does this represent? How is the data in the json related? Do you have data model it is to map too?
09-25-2022 12:40 PM
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
09-25-2022 02:19 PM
As I understand it:
Is this correct?
09-25-2022 04:02 PM
Yes
09-26-2022 02:32 AM
hi
yes that's correct thank you
09-26-2022 04:31 AM
The json seams to be incomplete. In particular, are the nodes organized in a list like the relationships? Can you provide the full file?
09-26-2022 01:25 PM
i will share file i don't know because i'm beginner in neo4j
https://drive.google.com/file/d/1wbgXlCWZdBJ1sJag0YJ7HfBA8clAwo3I/view?usp=sharing
09-26-2022 07:51 PM
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.
09-26-2022 11:20 PM
Hello, i have try 2 queries, first one is ok i can create nodes but second i have just table do you know why? please check my result.
Thank you
https://drive.google.com/file/d/1eNEFgUlLsgaLAHzG-NwC__LJhPvWEk5i/view?usp=sharing
https://drive.google.com/file/d/1W_DeOcCQLKM3ar1KMy4XQVVo-rsJ3_Nn/view?usp=sharing
09-27-2022 05:48 AM
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
09-27-2022 10:56 AM
Thank you all is good
All the sessions of the conference are now available online