Hi folks, just beginning my journey in neo4j .. i am planning to create a graph with relation between entities being represented by vectorized phrases ( so the relationship / edge will contain a small textual summary of the relation between the entities and also its vectorized format ) ..i am able to retrieve the parent and child nodes and its contents but having trouble retrieving contents of the relationship ..pfb the code for insertion
Blockquote
import json
from neo4j import GraphDatabase
with open('config.json', 'r' ) as fp:
js_ = json.load( fp )
URI = js_["URI"]
AUTH = ( js_['uname'] , js_['pwd'] )
fname_ = "emb_exp_op.csv"
with GraphDatabase.driver(URI, auth=AUTH) as driver:
print( driver.verify_connectivity() )
with driver.session() as session:
qry_ = '''LOAD CSV WITH HEADERS FROM 'file:///'''+fname_+'''' AS row
MERGE ( parent:Parent {text:row.parent_entity} ) WITH row, parent
MERGE ( child:Child {text:row.child_entity} ) WITH row, child, parent
MERGE( parent )-[ relation:RELATED_TO { property:row.relation } ]->( child )
WITH row, child, parent, relation CALL db.create.setRelationshipVectorProperty( relation, 'embedding', apoc.convert.fromJsonList( row.relation_emb ) )'''
result = session.run( qry_ )
print( result.value() )
Blockquote
while trying to retrieve , this is the code i use
Blockquote
import json
from neo4j import GraphDatabase
with open('config.json', 'r' ) as fp:
js_ = json.load( fp )
URI = js_["URI"]
AUTH = ( js_['uname'] , js_['pwd'] )
fname_ = "emb_exp_op.csv"
with GraphDatabase.driver(URI, auth=AUTH) as driver:
print( driver.verify_connectivity() )
with driver.session() as session:
qry_ = ''' MATCH ( relation:RELATED_TO ) RETURN relation.embedding '''
result = session.run( qry_ )
print( result.value() )
Blockquote
simply returns an array of None ..pfb a sample of the csv file i am using
parent_entity , child_entity, relation, relation_emb
photoelectric effect,classical electromagnetism,The experimental results disagree with classical electromagnetism which predicts that continuous light waves transfer energy to electrons which would then be emitted when they accumulate enough energy,"[-0.05979490652680397, 0.029119880869984627, -0.035598330199718475, 0.10272198915481567, -0.03214927390217781, -0.05320843681693077, .........