jskim commited on
Commit
4068146
·
1 Parent(s): dedd4f7

making links to open in new tab

Browse files
Files changed (2) hide show
  1. app.py +20 -3
  2. score.py +1 -1
app.py CHANGED
@@ -123,7 +123,8 @@ def get_similar_paper(
123
  for i in range(top_papers_show):
124
  out_tmp = [
125
  #gr.update(value=titles[i], visible=True),
126
- gr.update(value="#### [%s](%s)"%(titles[i], paper_urls[i]), visible=True),
 
127
  gr.update(value='#### Affinity: %0.3f'%doc_scores[i], visible=True) # document affinity
128
  ]
129
  tp = results[display_title[i]]['top_pairs']
@@ -190,14 +191,15 @@ def change_paper(selected_papers_radio, info={}):
190
  aff_score = info[selected_papers_radio]['doc_score']
191
  highlights = info[selected_papers_radio]['highlight']
192
  url = info[selected_papers_radio]['url']
193
- title_out = '#### [%s](%s)'%(title, url) # output in format of markdown
 
194
  aff_score_out = '#### Affinity: %s'%aff_score
195
  return title_out, abstract, aff_score_out, highlights['0']
196
 
197
  else:
198
  return
199
 
200
- with gr.Blocks() as demo:
201
  info = gr.State({}) # cached search results as a State variable shared throughout
202
 
203
  # Text description about the app and disclaimer
@@ -233,6 +235,21 @@ Below we describe how to use the tool. Also feel free to check out [this video](
233
  """
234
  )
235
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
  ### INPUT
237
  with gr.Row() as input_row:
238
  with gr.Column():
 
123
  for i in range(top_papers_show):
124
  out_tmp = [
125
  #gr.update(value=titles[i], visible=True),
126
+ gr.update(value="""<a href="%s" target="_blank"><h4>%s</h4></a>"""%(paper_urls[i], titles[i]), visible=True),
127
+ #gr.update(value="#### [%s](%s)"%(titles[i], paper_urls[i]), visible=True),
128
  gr.update(value='#### Affinity: %0.3f'%doc_scores[i], visible=True) # document affinity
129
  ]
130
  tp = results[display_title[i]]['top_pairs']
 
191
  aff_score = info[selected_papers_radio]['doc_score']
192
  highlights = info[selected_papers_radio]['highlight']
193
  url = info[selected_papers_radio]['url']
194
+ title_out = """<a href="%s" target="_blank"><h4>%s</h4></a>"""%(url, title)
195
+ # title_out = '#### [%s](%s)'%(title, url) # output in format of markdown
196
  aff_score_out = '#### Affinity: %s'%aff_score
197
  return title_out, abstract, aff_score_out, highlights['0']
198
 
199
  else:
200
  return
201
 
202
+ with gr.Blocks(css='style.css') as demo:
203
  info = gr.State({}) # cached search results as a State variable shared throughout
204
 
205
  # Text description about the app and disclaimer
 
235
  """
236
  )
237
 
238
+ # gr.HTML(
239
+ # """
240
+
241
+ # <div class="help-tip">
242
+ # <p>This is the same tooltip, but with <b>HTML tags!</b> <a href="http://tutorialzine.com/">And a links!</a> You could do <i><strike>even more</strike></i>!</p>
243
+ # </div>
244
+
245
+ # <p>This time, the tooltip contains rich text. Try it!</p>
246
+
247
+ # <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed eu diam consectetur, facilisis lorem in, condimentum est. Etiam at leo quis ligula ullamcorper varius. Vivamus sed risus vestibulum, faucibus nibh sed, eleifend enim. Nulla semper augue sit amet velit ultrices consectetur. Sed tincidunt consectetur fermentum.</p>
248
+
249
+ # """,
250
+ # visible=True
251
+ # )
252
+
253
  ### INPUT
254
  with gr.Row() as input_row:
255
  with gr.Column():
score.py CHANGED
@@ -251,7 +251,7 @@ def get_highlight_info(model, text1, text2, K=None):
251
  return sent_ids, sent_scores, info, top_pairs_info
252
 
253
  ### Document-level operations
254
-
255
  def predict_docscore(doc_model, tokenizer, query, titles, abstracts, batch=20):
256
  # compute document scores for each papers
257
 
 
251
  return sent_ids, sent_scores, info, top_pairs_info
252
 
253
  ### Document-level operations
254
+ # TODO Use specter_MFR
255
  def predict_docscore(doc_model, tokenizer, query, titles, abstracts, batch=20):
256
  # compute document scores for each papers
257