ZahirJS commited on
Commit
a886a2c
·
verified ·
1 Parent(s): ec39e15

Update concept_map_generator.py

Browse files
Files changed (1) hide show
  1. concept_map_generator.py +174 -1
concept_map_generator.py CHANGED
@@ -5,8 +5,181 @@ import os
5
  from graph_generator_utils import add_nodes_and_edges
6
 
7
  def generate_concept_map(json_input: str) -> str:
8
- """
9
  Generates a concept map from JSON input.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  """
11
  try:
12
  if not json_input.strip():
 
5
  from graph_generator_utils import add_nodes_and_edges
6
 
7
  def generate_concept_map(json_input: str) -> str:
8
+ """
9
  Generates a concept map from JSON input.
10
+
11
+ Args:
12
+ json_input (str): A JSON string describing the concept map structure.
13
+ It must follow the Expected JSON Format Example below.
14
+
15
+ Expected JSON Format Example:
16
+ {
17
+ "central_node": "Artificial Intelligence (AI)",
18
+ "nodes": [
19
+ {
20
+ "id": "ml_fundamental",
21
+ "label": "Machine Learning",
22
+ "relationship": "is essential for",
23
+ "subnodes": [
24
+ {
25
+ "id": "dl_branch",
26
+ "label": "Deep Learning",
27
+ "relationship": "for example",
28
+ "subnodes": [
29
+ {
30
+ "id": "cnn_example",
31
+ "label": "CNNs",
32
+ "relationship": "for example"
33
+ },
34
+ {
35
+ "id": "rnn_example",
36
+ "label": "RNNs",
37
+ "relationship": "for example"
38
+ }
39
+ ]
40
+ },
41
+ {
42
+ "id": "rl_branch",
43
+ "label": "Reinforcement Learning",
44
+ "relationship": "for example",
45
+ "subnodes": [
46
+ {
47
+ "id": "qlearning_example",
48
+ "label": "Q-Learning",
49
+ "relationship": "example"
50
+ },
51
+ {
52
+ "id": "pg_example",
53
+ "label": "Policy Gradients",
54
+ "relationship": "example"
55
+ }
56
+ ]
57
+ }
58
+ ]
59
+ },
60
+ {
61
+ "id": "ai_types",
62
+ "label": "Types",
63
+ "relationship": "formed by",
64
+ "subnodes": [
65
+ {
66
+ "id": "agi_type",
67
+ "label": "AGI",
68
+ "relationship": "this is",
69
+ "subnodes": [
70
+ {
71
+ "id": "strong_ai",
72
+ "label": "Strong AI",
73
+ "relationship": "provoked by",
74
+ "subnodes": [
75
+ {
76
+ "id": "human_intel",
77
+ "label": "Human-level Intel.",
78
+ "relationship": "of"
79
+ }
80
+ ]
81
+ }
82
+ ]
83
+ },
84
+ {
85
+ "id": "ani_type",
86
+ "label": "ANI",
87
+ "relationship": "this is",
88
+ "subnodes": [
89
+ {
90
+ "id": "weak_ai",
91
+ "label": "Weak AI",
92
+ "relationship": "provoked by",
93
+ "subnodes": [
94
+ {
95
+ "id": "narrow_tasks",
96
+ "label": "Narrow Tasks",
97
+ "relationship": "of"
98
+ }
99
+ ]
100
+ }
101
+ ]
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ "id": "ai_capabilities",
107
+ "label": "Capabilities",
108
+ "relationship": "change",
109
+ "subnodes": [
110
+ {
111
+ "id": "data_proc",
112
+ "label": "Data Processing",
113
+ "relationship": "can",
114
+ "subnodes": [
115
+ {
116
+ "id": "big_data",
117
+ "label": "Big Data",
118
+ "relationship": "as",
119
+ "subnodes": [
120
+ {
121
+ "id": "analysis_example",
122
+ "label": "Data Analysis",
123
+ "relationship": "example"
124
+ },
125
+ {
126
+ "id": "prediction_example",
127
+ "label": "Prediction",
128
+ "relationship": "example"
129
+ }
130
+ ]
131
+ }
132
+ ]
133
+ },
134
+ {
135
+ "id": "decision_making",
136
+ "label": "Decision Making",
137
+ "relationship": "can be",
138
+ "subnodes": [
139
+ {
140
+ "id": "automation",
141
+ "label": "Automation",
142
+ "relationship": "as",
143
+ "subnodes": [
144
+ {
145
+ "id": "robotics_example",
146
+ "label": "Robotics",
147
+ "relationship": "Example"},
148
+ {
149
+ "id": "autonomous_example",
150
+ "label": "Autonomous Vehicles",
151
+ "relationship": "of one"
152
+ }
153
+ ]
154
+ }
155
+ ]
156
+ },
157
+ {
158
+ "id": "problem_solving",
159
+ "label": "Problem Solving",
160
+ "relationship": "can",
161
+ "subnodes": [
162
+ {
163
+ "id": "optimization",
164
+ "label": "Optimization",
165
+ "relationship": "as is",
166
+ "subnodes": [
167
+ {
168
+ "id": "algorithms_example",
169
+ "label": "Algorithms",
170
+ "relationship": "for example"
171
+ }
172
+ ]
173
+ }
174
+ ]
175
+ }
176
+ ]
177
+ }
178
+ ]
179
+ }
180
+
181
+ Returns:
182
+ str: The filepath to the generated PNG image file.
183
  """
184
  try:
185
  if not json_input.strip():