Spaces:
Runtime error
Runtime error
making the search results more responsive
Browse files
app.py
CHANGED
|
@@ -111,10 +111,17 @@ def get_similar_paper(
|
|
| 111 |
|
| 112 |
## Set up output elements
|
| 113 |
|
| 114 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
out = [
|
| 116 |
-
gr.update(choices=display_title, interactive=True), # set of papers (radio)
|
| 117 |
-
gr.update(choices=input_sentences, interactive=True) # submission sentences
|
|
|
|
|
|
|
| 118 |
]
|
| 119 |
|
| 120 |
# set up elements to visualize upfront
|
|
@@ -162,7 +169,7 @@ def get_similar_paper(
|
|
| 162 |
|
| 163 |
# add updates to the show more button
|
| 164 |
out = out + summary_out + [gr.update(visible=True)] # make show more button visible
|
| 165 |
-
assert(len(out) == (top_num_info_show * 5 + 2) * top_papers_show +
|
| 166 |
|
| 167 |
out += [gr.update(value="""
|
| 168 |
<h3>Top three relevant papers by the reviewer <a href="%s" target="_blank">%s</a></h3>
|
|
@@ -198,6 +205,7 @@ def show_more(info):
|
|
| 198 |
gr.update(visible=True), # title row
|
| 199 |
gr.update(visible=True), # affinity row
|
| 200 |
gr.update(visible=True), # highlight legend
|
|
|
|
| 201 |
)
|
| 202 |
|
| 203 |
def show_status():
|
|
@@ -210,7 +218,7 @@ def update_name(author_id_input):
|
|
| 210 |
|
| 211 |
return gr.update(value=name)
|
| 212 |
|
| 213 |
-
def
|
| 214 |
# change the output highlight based on the sentence selected from the submission
|
| 215 |
if len(info.keys()) != 0: # if the info is not empty
|
| 216 |
source_sents = info[selected_papers_radio]['source_sentences']
|
|
@@ -221,8 +229,9 @@ def change_output_highlight(selected_papers_radio, source_sent_choice, info={}):
|
|
| 221 |
else:
|
| 222 |
return
|
| 223 |
|
| 224 |
-
def change_paper(selected_papers_radio, info={}):
|
| 225 |
if len(info.keys()) != 0: # if the info is not empty
|
|
|
|
| 226 |
title = info[selected_papers_radio]['title']
|
| 227 |
abstract = info[selected_papers_radio]['abstract']
|
| 228 |
aff_score = info[selected_papers_radio]['doc_score']
|
|
@@ -230,8 +239,9 @@ def change_paper(selected_papers_radio, info={}):
|
|
| 230 |
url = info[selected_papers_radio]['url']
|
| 231 |
title_out = """<a href="%s" target="_blank"><h5>%s</h5></a>"""%(url, title)
|
| 232 |
aff_score_out = '##### Affinity Score: %s'%aff_score
|
| 233 |
-
|
| 234 |
-
|
|
|
|
| 235 |
else:
|
| 236 |
return
|
| 237 |
|
|
@@ -285,7 +295,6 @@ R2P2 provides more information about each reviewer. It searches for the most rel
|
|
| 285 |
## PAPER1
|
| 286 |
with gr.Row():
|
| 287 |
result1_desc = gr.Markdown(value='', visible=False)
|
| 288 |
-
# TODO hovering instructions
|
| 289 |
with gr.Row():
|
| 290 |
with gr.Column(scale=3):
|
| 291 |
paper_title1 = gr.Markdown(value='', visible=False)
|
|
@@ -413,7 +422,7 @@ R2P2 provides more information about each reviewer. It searches for the most rel
|
|
| 413 |
paper_title = gr.Markdown(value='')
|
| 414 |
with gr.Row(visible=False) as aff_row:
|
| 415 |
affinity = gr.Markdown(value='')
|
| 416 |
-
with gr.Row():
|
| 417 |
# highlighted text from paper
|
| 418 |
highlight = gr.components.Interpretation(paper_abstract)
|
| 419 |
|
|
@@ -434,8 +443,10 @@ R2P2 provides more information about each reviewer. It searches for the most rel
|
|
| 434 |
info
|
| 435 |
],
|
| 436 |
outputs=[
|
| 437 |
-
selected_papers_radio,
|
| 438 |
-
source_sentences,
|
|
|
|
|
|
|
| 439 |
paper_title1, # paper info
|
| 440 |
affinity1,
|
| 441 |
sent_pair_score1_1,
|
|
@@ -495,12 +506,13 @@ R2P2 provides more information about each reviewer. It searches for the most rel
|
|
| 495 |
title_row,
|
| 496 |
aff_row,
|
| 497 |
highlight_legend,
|
|
|
|
| 498 |
]
|
| 499 |
)
|
| 500 |
|
| 501 |
# change highlight based on selected sentences from submission
|
| 502 |
source_sentences.change(
|
| 503 |
-
fn=
|
| 504 |
inputs=[
|
| 505 |
selected_papers_radio,
|
| 506 |
source_sentences,
|
|
@@ -514,6 +526,7 @@ R2P2 provides more information about each reviewer. It searches for the most rel
|
|
| 514 |
fn=change_paper,
|
| 515 |
inputs=[
|
| 516 |
selected_papers_radio,
|
|
|
|
| 517 |
info,
|
| 518 |
],
|
| 519 |
outputs= [
|
|
@@ -526,3 +539,4 @@ R2P2 provides more information about each reviewer. It searches for the most rel
|
|
| 526 |
|
| 527 |
if __name__ == "__main__":
|
| 528 |
demo.queue().launch() # add ?__theme=light to force light mode
|
|
|
|
|
|
| 111 |
|
| 112 |
## Set up output elements
|
| 113 |
|
| 114 |
+
# first the list of top papers, sentences to select from, paper_title, affinity
|
| 115 |
+
title = results[display_title[0]]['title'] # set default title as the top paper
|
| 116 |
+
url = results[display_title[0]]['url']
|
| 117 |
+
aff_score = results[display_title[0]]['doc_score']
|
| 118 |
+
title_out = """<a href="%s" target="_blank"><h5>%s</h5></a>"""%(url, title)
|
| 119 |
+
aff_score_out = '##### Affinity Score: %s'%aff_score
|
| 120 |
out = [
|
| 121 |
+
gr.update(choices=display_title, value=display_title[0], interactive=True), # set of papers (radio)
|
| 122 |
+
gr.update(choices=input_sentences, value=input_sentences[0], interactive=True), # submission sentences
|
| 123 |
+
gr.update(value=title_out), # paper_title
|
| 124 |
+
gr.update(value=aff_score_out) # affinity
|
| 125 |
]
|
| 126 |
|
| 127 |
# set up elements to visualize upfront
|
|
|
|
| 169 |
|
| 170 |
# add updates to the show more button
|
| 171 |
out = out + summary_out + [gr.update(visible=True)] # make show more button visible
|
| 172 |
+
assert(len(out) == (top_num_info_show * 5 + 2) * top_papers_show + 5)
|
| 173 |
|
| 174 |
out += [gr.update(value="""
|
| 175 |
<h3>Top three relevant papers by the reviewer <a href="%s" target="_blank">%s</a></h3>
|
|
|
|
| 205 |
gr.update(visible=True), # title row
|
| 206 |
gr.update(visible=True), # affinity row
|
| 207 |
gr.update(visible=True), # highlight legend
|
| 208 |
+
gr.update(visible=True), # highlight abstract
|
| 209 |
)
|
| 210 |
|
| 211 |
def show_status():
|
|
|
|
| 218 |
|
| 219 |
return gr.update(value=name)
|
| 220 |
|
| 221 |
+
def change_sentence(selected_papers_radio, source_sent_choice, info={}):
|
| 222 |
# change the output highlight based on the sentence selected from the submission
|
| 223 |
if len(info.keys()) != 0: # if the info is not empty
|
| 224 |
source_sents = info[selected_papers_radio]['source_sentences']
|
|
|
|
| 229 |
else:
|
| 230 |
return
|
| 231 |
|
| 232 |
+
def change_paper(selected_papers_radio, source_sent_choice, info={}):
|
| 233 |
if len(info.keys()) != 0: # if the info is not empty
|
| 234 |
+
source_sents = info[selected_papers_radio]['source_sentences']
|
| 235 |
title = info[selected_papers_radio]['title']
|
| 236 |
abstract = info[selected_papers_radio]['abstract']
|
| 237 |
aff_score = info[selected_papers_radio]['doc_score']
|
|
|
|
| 239 |
url = info[selected_papers_radio]['url']
|
| 240 |
title_out = """<a href="%s" target="_blank"><h5>%s</h5></a>"""%(url, title)
|
| 241 |
aff_score_out = '##### Affinity Score: %s'%aff_score
|
| 242 |
+
for i, s in enumerate(source_sents):
|
| 243 |
+
if source_sent_choice == s:
|
| 244 |
+
return title_out, abstract, aff_score_out, highlights[str(i)]
|
| 245 |
else:
|
| 246 |
return
|
| 247 |
|
|
|
|
| 295 |
## PAPER1
|
| 296 |
with gr.Row():
|
| 297 |
result1_desc = gr.Markdown(value='', visible=False)
|
|
|
|
| 298 |
with gr.Row():
|
| 299 |
with gr.Column(scale=3):
|
| 300 |
paper_title1 = gr.Markdown(value='', visible=False)
|
|
|
|
| 422 |
paper_title = gr.Markdown(value='')
|
| 423 |
with gr.Row(visible=False) as aff_row:
|
| 424 |
affinity = gr.Markdown(value='')
|
| 425 |
+
with gr.Row(visible=False) as hl_row:
|
| 426 |
# highlighted text from paper
|
| 427 |
highlight = gr.components.Interpretation(paper_abstract)
|
| 428 |
|
|
|
|
| 443 |
info
|
| 444 |
],
|
| 445 |
outputs=[
|
| 446 |
+
selected_papers_radio, # list of papers for show more section
|
| 447 |
+
source_sentences, # list of sentences for show more section
|
| 448 |
+
paper_title, # paper title for show more section
|
| 449 |
+
affinity, # paper affinity for show more section
|
| 450 |
paper_title1, # paper info
|
| 451 |
affinity1,
|
| 452 |
sent_pair_score1_1,
|
|
|
|
| 506 |
title_row,
|
| 507 |
aff_row,
|
| 508 |
highlight_legend,
|
| 509 |
+
hl_row
|
| 510 |
]
|
| 511 |
)
|
| 512 |
|
| 513 |
# change highlight based on selected sentences from submission
|
| 514 |
source_sentences.change(
|
| 515 |
+
fn=change_sentence,
|
| 516 |
inputs=[
|
| 517 |
selected_papers_radio,
|
| 518 |
source_sentences,
|
|
|
|
| 526 |
fn=change_paper,
|
| 527 |
inputs=[
|
| 528 |
selected_papers_radio,
|
| 529 |
+
source_sentences,
|
| 530 |
info,
|
| 531 |
],
|
| 532 |
outputs= [
|
|
|
|
| 539 |
|
| 540 |
if __name__ == "__main__":
|
| 541 |
demo.queue().launch() # add ?__theme=light to force light mode
|
| 542 |
+
|