Consoli Sergio commited on
Commit
aab88fa
·
1 Parent(s): af1a9ea

updated faceted browser with sparql query

Browse files
Files changed (1) hide show
  1. app-demo-myMultiNER.py +11 -6
app-demo-myMultiNER.py CHANGED
@@ -48,6 +48,7 @@ from common import strtobool, token_counter, encoding_getter, strip_quotes
48
  from nerBio import annotate, entitiesFusion, is_cross_inside, elinking
49
  from llmqueryNer import call_model, call_model_with_caching, process_list, setup_gptjrc, api_call_gptjrc, model_list_gptjrc
50
 
 
51
 
52
  from joblib import Memory
53
 
@@ -172,8 +173,10 @@ def get_urls(word, df_annotated_combined):
172
  #html_links = "<br>".join([f'<a href="https://expl-rels-dev-vast.apps.ocpt.jrc.ec.europa.eu/?concept={url}" target="_blank">{url}</a>' for url in urls])
173
  #html_links = "<br>".join([f'<a href="https://api-vast.jrc.service.ec.europa.eu/describe//?url={url}" target="_blank">{url}</a>' for url in urls])
174
  html_links = "<br>".join(
175
- [f'<a href="https://api-vast.jrc.service.ec.europa.eu/sparql?default-graph-uri=&query=DESCRIBE+<{url}>&format=text/html" target="_blank">{url}</a>' for
176
- url in urls])
 
 
177
  return html_links
178
  return ""
179
 
@@ -618,7 +621,7 @@ def nerBio(text, ModelsSelection, CategoriesSelection, ScoreFilt, EntityLinking,
618
  # 'word']
619
  #),
620
  lambda row: (
621
- f"<a href='https://api-vast.jrc.service.ec.europa.eu/sparql?default-graph-uri=&query=DESCRIBE+<{row['namedEntity']}>&format=text/html' target='_blank'>{row['word']}</a>"
622
  if row['namedEntity'] not in [None, '', 'NaN', 'nan'] and pd.notnull(row['namedEntity']) else row[
623
  'word']
624
  ),
@@ -749,9 +752,11 @@ def update_urls(selected_word, state):
749
  # Convert list of URLs to HTML string with clickable links
750
  #html_links = "<br>".join([f'<a href="https://expl-rels-dev-vast.apps.ocpt.jrc.ec.europa.eu/?concept={url}" target="_blank">{url}</a>' for url in urls])
751
  #html_links = "<br>".join([f'<a href="https://api-vast.jrc.service.ec.europa.eu/describe//?url={url}" target="_blank">{url}</a>' for url in urls])
752
- html_links = "<br>".join([f'<a href="https://api-vast.jrc.service.ec.europa.eu/sparql?default-graph-uri=&query=DESCRIBE+<{url}>&format=text/html" target="_blank">{url}</a>'
753
- for url in urls])
754
-
 
 
755
  return html_links
756
  return ""
757
  else:
 
48
  from nerBio import annotate, entitiesFusion, is_cross_inside, elinking
49
  from llmqueryNer import call_model, call_model_with_caching, process_list, setup_gptjrc, api_call_gptjrc, model_list_gptjrc
50
 
51
+ import urllib.parse #consose 20251022
52
 
53
  from joblib import Memory
54
 
 
173
  #html_links = "<br>".join([f'<a href="https://expl-rels-dev-vast.apps.ocpt.jrc.ec.europa.eu/?concept={url}" target="_blank">{url}</a>' for url in urls])
174
  #html_links = "<br>".join([f'<a href="https://api-vast.jrc.service.ec.europa.eu/describe//?url={url}" target="_blank">{url}</a>' for url in urls])
175
  html_links = "<br>".join(
176
+ [
177
+ f'<a href="https://api-vast.jrc.service.ec.europa.eu/sparql?default-graph-uri=&query=DESCRIBE+%3C{urllib.parse.quote(url)}%3E&format=text%2Fhtml" target="_blank">{url}</a>'
178
+ for url in urls]
179
+ )
180
  return html_links
181
  return ""
182
 
 
621
  # 'word']
622
  #),
623
  lambda row: (
624
+ f"<a href='https://api-vast.jrc.service.ec.europa.eu/sparql?default-graph-uri=&query=DESCRIBE+%3C{urllib.parse.quote(row['namedEntity'])}%3E&format=text%2Fhtml' target='_blank'>{row['word']}</a>"
625
  if row['namedEntity'] not in [None, '', 'NaN', 'nan'] and pd.notnull(row['namedEntity']) else row[
626
  'word']
627
  ),
 
752
  # Convert list of URLs to HTML string with clickable links
753
  #html_links = "<br>".join([f'<a href="https://expl-rels-dev-vast.apps.ocpt.jrc.ec.europa.eu/?concept={url}" target="_blank">{url}</a>' for url in urls])
754
  #html_links = "<br>".join([f'<a href="https://api-vast.jrc.service.ec.europa.eu/describe//?url={url}" target="_blank">{url}</a>' for url in urls])
755
+ html_links = "<br>".join(
756
+ [
757
+ f'<a href="https://api-vast.jrc.service.ec.europa.eu/sparql?default-graph-uri=&query=DESCRIBE+%3C{urllib.parse.quote(url)}%3E&format=text%2Fhtml" target="_blank">{url}</a>'
758
+ for url in urls]
759
+ )
760
  return html_links
761
  return ""
762
  else: