Update app.py
Browse files
app.py
CHANGED
@@ -19,9 +19,14 @@ def load_names_from_url(jsonld_url):
|
|
19 |
names = load_names_from_url('https://huggingface.co/spaces/histlearn/ShowGraph/raw/main/datafile.jsonld')
|
20 |
|
21 |
def run_query_and_visualize(qtext, jsonld_url):
|
|
|
|
|
|
|
22 |
# Carrega o arquivo JSON-LD
|
23 |
g = rdflib.Graph()
|
24 |
g.parse(jsonld_url, format="json-ld")
|
|
|
|
|
25 |
|
26 |
# Executa a consulta SPARQL
|
27 |
qres = g.query(qtext)
|
@@ -30,6 +35,8 @@ def run_query_and_visualize(qtext, jsonld_url):
|
|
30 |
net = Network(notebook=False, height="400px", width="100%", cdn_resources='remote')
|
31 |
nodes = set()
|
32 |
|
|
|
|
|
33 |
# Processa os resultados da consulta
|
34 |
for row in qres:
|
35 |
s, p, o = row
|
@@ -45,6 +52,8 @@ def run_query_and_visualize(qtext, jsonld_url):
|
|
45 |
net.show("graph.html")
|
46 |
with open("graph.html", "r") as file:
|
47 |
graph_html = file.read()
|
|
|
|
|
48 |
return graph_html
|
49 |
|
50 |
def update_query(selected_location):
|
|
|
19 |
names = load_names_from_url('https://huggingface.co/spaces/histlearn/ShowGraph/raw/main/datafile.jsonld')
|
20 |
|
21 |
def run_query_and_visualize(qtext, jsonld_url):
|
22 |
+
print("Executando consulta SPARQL...")
|
23 |
+
print(f"Consulta SPARQL: {qtext}")
|
24 |
+
|
25 |
# Carrega o arquivo JSON-LD
|
26 |
g = rdflib.Graph()
|
27 |
g.parse(jsonld_url, format="json-ld")
|
28 |
+
|
29 |
+
print("Consulta SPARQL carregada...")
|
30 |
|
31 |
# Executa a consulta SPARQL
|
32 |
qres = g.query(qtext)
|
|
|
35 |
net = Network(notebook=False, height="400px", width="100%", cdn_resources='remote')
|
36 |
nodes = set()
|
37 |
|
38 |
+
print("Processando resultados da consulta...")
|
39 |
+
|
40 |
# Processa os resultados da consulta
|
41 |
for row in qres:
|
42 |
s, p, o = row
|
|
|
52 |
net.show("graph.html")
|
53 |
with open("graph.html", "r") as file:
|
54 |
graph_html = file.read()
|
55 |
+
|
56 |
+
print("Gráfico gerado com sucesso.")
|
57 |
return graph_html
|
58 |
|
59 |
def update_query(selected_location):
|