ZahirJS commited on
Commit
bf5eed8
·
verified ·
1 Parent(s): 028a336

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -72
app.py CHANGED
@@ -3,6 +3,7 @@ import json
3
  from graphviz import Digraph
4
  import os
5
  from tempfile import NamedTemporaryFile
 
6
 
7
  def generate_concept_map(json_input: str) -> str:
8
  """
@@ -10,7 +11,7 @@ def generate_concept_map(json_input: str) -> str:
10
 
11
  Args:
12
  json_input (str): JSON describing the concept map structure.
13
-
14
  REQUIRED FORMAT EXAMPLE:
15
  {
16
  "central_node": "AI",
@@ -139,80 +140,10 @@ def generate_concept_map(json_input: str) -> str:
139
  return f"Error: {str(e)}"
140
 
141
  if __name__ == "__main__":
142
- # Complex sample JSON
143
- sample_json = """
144
- {
145
- "central_node": "Artificial Intelligence (AI)",
146
- "nodes": [
147
- {
148
- "id": "ml",
149
- "label": "Machine Learning",
150
- "relationship": "Core Component",
151
- "subnodes": [
152
- {
153
- "id": "sl",
154
- "label": "Supervised Learning",
155
- "relationship": "Learning Type",
156
- "subnodes": [
157
- {
158
- "id": "reg",
159
- "label": "Regression",
160
- "relationship": "Technique",
161
- "subnodes": [
162
- {"id": "lr", "label": "Linear Regression", "relationship": "Algorithm"}
163
- ]
164
- },
165
- {
166
- "id": "clf",
167
- "label": "Classification",
168
- "relationship": "Technique",
169
- "subnodes": [
170
- {"id": "svm", "label": "SVM", "relationship": "Algorithm"},
171
- {"id": "rf", "label": "Random Forest", "relationship": "Algorithm"}
172
- ]
173
- }
174
- ]
175
- },
176
- {
177
- "id": "ul",
178
- "label": "Unsupervised Learning",
179
- "relationship": "Learning Type",
180
- "subnodes": [
181
- {
182
- "id": "clus",
183
- "label": "Clustering",
184
- "relationship": "Technique",
185
- "subnodes": [
186
- {"id": "kmeans", "label": "K-Means", "relationship": "Algorithm"}
187
- ]
188
- }
189
- ]
190
- }
191
- ]
192
- },
193
- {
194
- "id": "nlp",
195
- "label": "NLP",
196
- "relationship": "Application Domain",
197
- "subnodes": [
198
- {
199
- "id": "sa",
200
- "label": "Sentiment Analysis",
201
- "relationship": "Task",
202
- "subnodes": [
203
- {"id": "tb", "label": "Transformer-Based", "relationship": "Approach"}
204
- ]
205
- }
206
- ]
207
- }
208
- ]
209
- }
210
- """
211
-
212
  demo = gr.Interface(
213
  fn=generate_concept_map,
214
  inputs=gr.Textbox(
215
- value=sample_json,
216
  placeholder="Paste JSON following the documented format",
217
  label="Structured JSON Input",
218
  lines=25
 
3
  from graphviz import Digraph
4
  import os
5
  from tempfile import NamedTemporaryFile
6
+ from sample_data import COMPLEX_SAMPLE_JSON # ¡Aquí está el import!
7
 
8
  def generate_concept_map(json_input: str) -> str:
9
  """
 
11
 
12
  Args:
13
  json_input (str): JSON describing the concept map structure.
14
+
15
  REQUIRED FORMAT EXAMPLE:
16
  {
17
  "central_node": "AI",
 
140
  return f"Error: {str(e)}"
141
 
142
  if __name__ == "__main__":
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
143
  demo = gr.Interface(
144
  fn=generate_concept_map,
145
  inputs=gr.Textbox(
146
+ value=COMPLEX_SAMPLE_JSON,
147
  placeholder="Paste JSON following the documented format",
148
  label="Structured JSON Input",
149
  lines=25