You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
831 B
33 lines
831 B
import networkx as nx |
|
from _arango import arango |
|
import random |
|
from print_color import * |
|
import json |
|
import datetime |
|
|
|
# Create a new directed graph |
|
G = nx.DiGraph() |
|
|
|
q = "for doc in interrogations return doc" |
|
interrogations = list(arango.db.aql.execute(q)) |
|
|
|
|
|
for interrogation in interrogations: |
|
if not 'mentioned_persons' in interrogation: |
|
continue |
|
person_key = interrogation['person_id'].split('/')[1] |
|
mentioned_persons = interrogation["mentioned_persons"] |
|
for mentioned_person in mentioned_persons: |
|
G.add_edge( |
|
person_key, |
|
mentioned_person, |
|
label=interrogation["_key"], |
|
) |
|
|
|
|
|
|
|
# Write the graph to a GEXF file |
|
current_time = datetime.datetime.now().strftime("%H-%M-%S") |
|
filename = f"output_files/mentions_{current_time}.gexf" |
|
nx.write_gexf(G, filename) |
|
|
|
|