Update app.py
Browse files
app.py
CHANGED
@@ -25,10 +25,10 @@ names = load_names_from_url('https://huggingface.co/spaces/histlearn/ShowGraph/r
|
|
25 |
|
26 |
print("Loaded names:", names) # Adicionando impressão para depuração
|
27 |
|
28 |
-
def run_query_and_visualize(qtext,
|
29 |
-
# Carrega o arquivo
|
30 |
g = rdflib.Graph()
|
31 |
-
g.parse(
|
32 |
|
33 |
# Executa a consulta SPARQL
|
34 |
qres = g.query(qtext)
|
@@ -70,7 +70,6 @@ with gr.Blocks() as demo:
|
|
70 |
query_input = gr.Textbox(label="Consulta SPARQL", value=update_query(names[0]), lines=10)
|
71 |
else:
|
72 |
query_input = gr.Textbox(label="Consulta SPARQL", value="", lines=10)
|
73 |
-
turtle_file_input = gr.File(label="Arquivo Turtle")
|
74 |
run_button = gr.Button("Executar Consulta")
|
75 |
|
76 |
graph_output = gr.HTML()
|
@@ -80,9 +79,9 @@ with gr.Blocks() as demo:
|
|
80 |
|
81 |
selected_location.change(fn=on_location_change, inputs=selected_location, outputs=query_input)
|
82 |
|
83 |
-
def on_run_button_click(query
|
84 |
-
return run_query_and_visualize(query,
|
85 |
|
86 |
-
run_button.click(fn=on_run_button_click, inputs=[query_input
|
87 |
|
88 |
demo.launch()
|
|
|
25 |
|
26 |
print("Loaded names:", names) # Adicionando impressão para depuração
|
27 |
|
28 |
+
def run_query_and_visualize(qtext, jsonld_file):
|
29 |
+
# Carrega o arquivo JSON-LD
|
30 |
g = rdflib.Graph()
|
31 |
+
g.parse(jsonld_file, format="json-ld")
|
32 |
|
33 |
# Executa a consulta SPARQL
|
34 |
qres = g.query(qtext)
|
|
|
70 |
query_input = gr.Textbox(label="Consulta SPARQL", value=update_query(names[0]), lines=10)
|
71 |
else:
|
72 |
query_input = gr.Textbox(label="Consulta SPARQL", value="", lines=10)
|
|
|
73 |
run_button = gr.Button("Executar Consulta")
|
74 |
|
75 |
graph_output = gr.HTML()
|
|
|
79 |
|
80 |
selected_location.change(fn=on_location_change, inputs=selected_location, outputs=query_input)
|
81 |
|
82 |
+
def on_run_button_click(query):
|
83 |
+
return run_query_and_visualize(query, 'https://huggingface.co/spaces/histlearn/ShowGraph/raw/main/datafile.jsonld')
|
84 |
|
85 |
+
run_button.click(fn=on_run_button_click, inputs=[query_input], outputs=graph_output)
|
86 |
|
87 |
demo.launch()
|