Update concept_map_generator.py
Browse files- concept_map_generator.py +134 -6
concept_map_generator.py
CHANGED
|
@@ -12,9 +12,6 @@ def generate_concept_map(json_input: str) -> str: # Removed base_color parameter
|
|
| 12 |
json_input (str): A JSON string describing the concept map structure.
|
| 13 |
It must follow the Expected JSON Format Example below.
|
| 14 |
|
| 15 |
-
Returns:
|
| 16 |
-
str: The filepath to the generated PNG image file.
|
| 17 |
-
|
| 18 |
Expected JSON Format Example:
|
| 19 |
{
|
| 20 |
"central_node": "Artificial Intelligence (AI)",
|
|
@@ -29,8 +26,33 @@ def generate_concept_map(json_input: str) -> str: # Removed base_color parameter
|
|
| 29 |
"label": "Deep Learning",
|
| 30 |
"relationship": "for example",
|
| 31 |
"subnodes": [
|
| 32 |
-
{
|
| 33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
]
|
| 35 |
}
|
| 36 |
]
|
|
@@ -45,13 +67,119 @@ def generate_concept_map(json_input: str) -> str: # Removed base_color parameter
|
|
| 45 |
"label": "AGI",
|
| 46 |
"relationship": "this is",
|
| 47 |
"subnodes": [
|
| 48 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 49 |
]
|
| 50 |
}
|
| 51 |
]
|
| 52 |
}
|
| 53 |
]
|
| 54 |
}
|
|
|
|
|
|
|
|
|
|
| 55 |
"""
|
| 56 |
try:
|
| 57 |
if not json_input.strip():
|
|
|
|
| 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)",
|
|
|
|
| 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 |
]
|
|
|
|
| 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():
|