Spaces:
Sleeping
Sleeping
dyxohjl666
commited on
Commit
•
02d7398
1
Parent(s):
44257a9
Add precomputing acl data
Browse files- app.py +37 -12
- requirements.txt +2 -1
app.py
CHANGED
@@ -5,12 +5,13 @@ from reference_string_parsing import *
|
|
5 |
from controlled_summarization import *
|
6 |
from dataset_extraction import *
|
7 |
|
|
|
8 |
import requests
|
9 |
|
10 |
# Example Usage
|
11 |
-
#url = "https://arxiv.org/pdf/2305.14996.pdf"
|
12 |
-
#dest_folder = "./examples/"
|
13 |
-
#download_pdf(url, dest_folder)
|
14 |
|
15 |
|
16 |
with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
|
@@ -31,17 +32,20 @@ with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
|
|
31 |
gr.Markdown("* Set the length of text used for summarization. Length 0 will exert no control over length.")
|
32 |
# ctrlsum_file_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
|
33 |
# ctrlsum_file_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
|
34 |
-
ctrlsum_file_length = gr.
|
35 |
-
|
|
|
36 |
with gr.Row():
|
37 |
ctrlsum_file_btn = gr.Button("Generate")
|
38 |
ctrlsum_file_output = gr.Textbox(
|
39 |
elem_id="htext",
|
40 |
label="Summary",
|
41 |
)
|
42 |
-
ctrlsum_file_examples = gr.Examples(
|
43 |
-
|
44 |
-
|
|
|
|
|
45 |
|
46 |
|
47 |
|
@@ -51,13 +55,34 @@ with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
|
|
51 |
outputs=[ctrlsum_file_output, ctrlsum_str, ctrlsum_file]
|
52 |
)
|
53 |
def clear():
|
54 |
-
return None,0,None, None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
|
57 |
-
ctrlsum_file.upload(clear, inputs=None,outputs=[ctrlsum_str,ctrlsum_file_length,ctrlsum_file_keywords, ctrlsum_url])
|
58 |
-
ctrlsum_url.input(clear, inputs=None, outputs=[ctrlsum_str, ctrlsum_file_length, ctrlsum_file_keywords, ctrlsum_file])
|
59 |
ctrlsum_str.input(clear, inputs=None,
|
60 |
-
outputs=[ctrlsum_url, ctrlsum_file_length, ctrlsum_file_keywords, ctrlsum_file])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
# Reference String Parsing
|
62 |
with gr.TabItem("Reference String Parsing"):
|
63 |
gr.Markdown(rsp_title_md)
|
|
|
5 |
from controlled_summarization import *
|
6 |
from dataset_extraction import *
|
7 |
|
8 |
+
from controlled_summarization import recommended_kw
|
9 |
import requests
|
10 |
|
11 |
# Example Usage
|
12 |
+
# url = "https://arxiv.org/pdf/2305.14996.pdf"
|
13 |
+
# dest_folder = "./examples/"
|
14 |
+
# download_pdf(url, dest_folder)
|
15 |
|
16 |
|
17 |
with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
|
|
|
32 |
gr.Markdown("* Set the length of text used for summarization. Length 0 will exert no control over length.")
|
33 |
# ctrlsum_file_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
|
34 |
# ctrlsum_file_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
|
35 |
+
ctrlsum_file_length = gr.Radio(label="Length", value=0, choices=[0, 50, 100, 200])
|
36 |
+
kw = gr.Radio(visible=False)
|
37 |
+
ctrlsum_file_keywords = gr.Textbox(label="Keywords", max_lines=1)
|
38 |
with gr.Row():
|
39 |
ctrlsum_file_btn = gr.Button("Generate")
|
40 |
ctrlsum_file_output = gr.Textbox(
|
41 |
elem_id="htext",
|
42 |
label="Summary",
|
43 |
)
|
44 |
+
ctrlsum_file_examples = gr.Examples(
|
45 |
+
examples=[["examples/H01-1042_body.txt", 50, "automatic evaluation technique", "", ""],
|
46 |
+
["examples/H01-1042.pdf", 0, "automatic evaluation technique", "", ""]],
|
47 |
+
inputs=[ctrlsum_file, ctrlsum_file_length, ctrlsum_file_keywords, ctrlsum_str, ctrlsum_url
|
48 |
+
])
|
49 |
|
50 |
|
51 |
|
|
|
55 |
outputs=[ctrlsum_file_output, ctrlsum_str, ctrlsum_file]
|
56 |
)
|
57 |
def clear():
|
58 |
+
return None, 0, None, None, gr.Radio(visible=False)
|
59 |
+
|
60 |
+
|
61 |
+
def update_url(url):
|
62 |
+
if url in recommended_kw.keys():
|
63 |
+
keywords = recommended_kw[url]
|
64 |
+
if keywords != None:
|
65 |
+
return None, None, gr.Radio(choices=keywords[:3], label="Recommended Keywords", visible=True,
|
66 |
+
interactive=True)
|
67 |
|
68 |
+
return None, None, gr.Radio(visible=False)
|
69 |
+
|
70 |
+
|
71 |
+
ctrlsum_file.upload(clear, inputs=None,
|
72 |
+
outputs=[ctrlsum_str, ctrlsum_file_length, ctrlsum_file_keywords, ctrlsum_url, kw])
|
73 |
+
ctrlsum_url.input(update_url, inputs=ctrlsum_url, outputs=[ctrlsum_str, ctrlsum_file, kw])
|
74 |
|
|
|
|
|
75 |
ctrlsum_str.input(clear, inputs=None,
|
76 |
+
outputs=[ctrlsum_url, ctrlsum_file_length, ctrlsum_file_keywords, ctrlsum_file, kw])
|
77 |
+
|
78 |
+
|
79 |
+
|
80 |
+
def select_kw(env: gr.SelectData):
|
81 |
+
return env.value
|
82 |
+
|
83 |
+
|
84 |
+
kw.select(select_kw, None, ctrlsum_file_keywords)
|
85 |
+
|
86 |
# Reference String Parsing
|
87 |
with gr.TabItem("Reference String Parsing"):
|
88 |
gr.Markdown(rsp_title_md)
|
requirements.txt
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
pip==23.2.1
|
2 |
torch==1.12.0
|
3 |
-
SciAssist==0.
|
4 |
nltk~=3.7
|
|
|
|
1 |
pip==23.2.1
|
2 |
torch==1.12.0
|
3 |
+
SciAssist==0.1.3
|
4 |
nltk~=3.7
|
5 |
+
pytest
|