Spaces:
Configuration error
Configuration error
Delete Json_2_tree.py
Browse files- Json_2_tree.py +0 -22
Json_2_tree.py
DELETED
@@ -1,22 +0,0 @@
|
|
1 |
-
|
2 |
-
# Function to recursively build the tree graph from the JSON
|
3 |
-
def json_to_dot(graph, node_id, parent_node, parent_label):
|
4 |
-
if isinstance(parent_node, dict):
|
5 |
-
for key, value in parent_node.items():
|
6 |
-
if key.startswith("Question"):
|
7 |
-
question_id = f"{node_id}_{key}"
|
8 |
-
label_text = "\n".join(value[i:i+30] for i in range(0, len(value), 30))
|
9 |
-
shape = 'diamond' if len(value) > 50 else 'box'
|
10 |
-
graph.node(question_id, label_text, shape=shape, style='filled', fillcolor='lightblue')
|
11 |
-
graph.edge(parent_label, question_id, color='black')
|
12 |
-
json_to_dot(graph, question_id, value, question_id)
|
13 |
-
elif key in ["Yes", "No"]:
|
14 |
-
option_label = f"{node_id}_{key}"
|
15 |
-
graph.node(option_label, key, shape='box', style='filled', fillcolor='lightgreen' if key == "Yes" else 'lightcoral')
|
16 |
-
graph.edge(parent_label, option_label, label=key, color='black')
|
17 |
-
json_to_dot(graph, option_label, value, option_label)
|
18 |
-
elif key == "Result":
|
19 |
-
result_label = f"{node_id}_{key}"
|
20 |
-
result_str = f"{key}: {value}\nCouncil regulations: {parent_node['Council regulations']}"
|
21 |
-
graph.node(result_label, result_str, shape='box', style='filled', fillcolor='lightgrey')
|
22 |
-
graph.edge(parent_label, result_label, color='black')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|