I have a code chunk
if show_relations:
_print('Relations:')
entities = graph['entities']
relgraph=[]
relations_data = [
[
entities[rel['subject']]['head'].lower(),
relgraph.append(entities[rel['subject']]['head'].lower()),
rel['relation'].lower(),
relgraph.append(rel['relation'].lower()),
entities[rel['object']]['head'].lower(),
relgraph.append(entities[rel['object']]['head'].lower()),
_print(relgraph)
]
for rel in graph['relations']
]
I created a relgraph list. Append the entries of list. With each iteration, I want to recreate this list.
Also, dump these lists into json file. How do I do that.
I tried to put relgraph=[] before and after for statement but it gives me an error saying invalid syntax
forloop with a list comprehension.