qolina commited on
Commit
b0e98fb
1 Parent(s): ce0e9ff

update with description

Browse files
Files changed (1) hide show
  1. app.py +161 -160
app.py CHANGED
@@ -1,161 +1,162 @@
1
- import gradio as gr
2
- from description import *
3
-
4
- from reference_string_parsing import *
5
- from summarization import *
6
- from controlled_summarization import *
7
-
8
- with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
9
- gr.Markdown("# Gradio Demo for SciAssist")
10
- with gr.Tabs():
11
- # Reference String Parsing
12
- with gr.TabItem("Reference String Parsing"):
13
- with gr.Box():
14
- gr.Markdown(rsp_str_md)
15
- with gr.Row():
16
- with gr.Column():
17
- rsp_str = gr.Textbox(label="Input String")
18
- with gr.Column():
19
- rsp_str_dehyphen = gr.Checkbox(label="dehyphen")
20
- with gr.Row():
21
- rsp_str_btn = gr.Button("Parse")
22
- rsp_str_output = gr.HighlightedText(
23
- elem_id="htext",
24
- label="The Result of Parsing",
25
- combine_adjacent=True,
26
- adjacent_separator=" ",
27
- )
28
- rsp_str_examples = gr.Examples(examples=[[
29
- "Waleed Ammar, Matthew E. Peters, Chandra Bhagavat- ula, and Russell Power. 2017. The ai2 system at semeval-2017 task 10 (scienceie): semi-supervised end-to-end entity and relation extraction. In ACL workshop (SemEval).",
30
- True],
31
- [
32
- "Isabelle Augenstein, Mrinal Das, Sebastian Riedel, Lakshmi Vikraman, and Andrew D. McCallum. 2017. Semeval-2017 task 10 (scienceie): Extracting keyphrases and relations from scientific publications. In ACL workshop (SemEval).",
33
- False]], inputs=[rsp_str, rsp_str_dehyphen])
34
- with gr.Box():
35
- gr.Markdown(rsp_file_md)
36
- with gr.Row():
37
- with gr.Column():
38
- rsp_file = gr.File(label="Input File")
39
- rsp_file_dehyphen = gr.Checkbox(label="dehyphen")
40
- with gr.Row():
41
- rsp_file_btn = gr.Button("Parse")
42
-
43
- rsp_file_output = gr.HighlightedText(
44
- elem_id="htext",
45
- label="The Result of Parsing",
46
- combine_adjacent=True,
47
- adjacent_separator=" ",
48
- )
49
- rsp_file_examples = gr.Examples(examples=[["examples/N18-3011_ref.txt", False],["examples/BERT_paper.pdf", True]], inputs=[rsp_file, rsp_file_dehyphen])
50
-
51
-
52
- rsp_file_btn.click(
53
- fn=rsp_for_file,
54
- inputs=[rsp_file, rsp_file_dehyphen],
55
- outputs=rsp_file_output
56
- )
57
- rsp_str_btn.click(
58
- fn=rsp_for_str,
59
- inputs=[rsp_str, rsp_str_dehyphen],
60
- outputs=rsp_str_output
61
- )
62
-
63
- # Single Document Summarization
64
- with gr.TabItem("Summarization"):
65
- with gr.Box():
66
- gr.Markdown(ssum_str_md)
67
- with gr.Row():
68
- with gr.Column():
69
- ssum_str = gr.Textbox(label="Input String")
70
- # with gr.Column():
71
- # ssum_str_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
72
- # ssum_str_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
73
- with gr.Row():
74
- ssum_str_btn = gr.Button("Generate")
75
- ssum_str_output = gr.Textbox(
76
- elem_id="htext",
77
- label="Summary",
78
- )
79
- ssum_str_examples = gr.Examples(examples=[[ssum_str_example], ],
80
- inputs=[ssum_str])
81
- with gr.Box():
82
- gr.Markdown(ssum_file_md)
83
- with gr.Row():
84
- with gr.Column():
85
- ssum_file = gr.File(label="Input File")
86
- # with gr.Column():
87
- # ssum_file_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
88
- # ssum_file_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
89
- with gr.Row():
90
- ssum_file_btn = gr.Button("Generate")
91
- ssum_file_output = gr.Textbox(
92
- elem_id="htext",
93
- label="Summary",
94
- )
95
- ssum_file_examples = gr.Examples(examples=[["examples/BERT_body.txt"],["examples/BERT_paper.pdf"]],
96
- inputs=[ssum_file])
97
-
98
- ssum_file_btn.click(
99
- fn=ssum_for_file,
100
- inputs=[ssum_file],
101
- outputs=ssum_file_output
102
- )
103
- ssum_str_btn.click(
104
- fn=ssum_for_str,
105
- inputs=[ssum_str],
106
- outputs=ssum_str_output
107
- )
108
-
109
- # Controlled Summarization
110
- with gr.TabItem("Controlled Summarization"):
111
- with gr.Box():
112
- gr.Markdown(ctrlsum_str_md)
113
- with gr.Row():
114
- with gr.Column():
115
- ctrlsum_str = gr.Textbox(label="Input String")
116
- with gr.Column():
117
- # ctrlsum_str_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
118
- # ctrlsum_str_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
119
- ctrlsum_str_length = gr.Slider(0, 300, step=50, label="Length")
120
- ctrlsum_str_keywords = gr.Textbox(label="Keywords")
121
- with gr.Row():
122
- ctrlsum_str_btn = gr.Button("Generate")
123
- ctrlsum_str_output = gr.Textbox(
124
- elem_id="htext",
125
- label="Summary",
126
- )
127
- ctrlsum_str_examples = gr.Examples(examples=[[ssum_str_example, 50, "BERT" ], ],
128
- inputs=[ctrlsum_str, ctrlsum_str_length, ctrlsum_str_keywords])
129
- with gr.Box():
130
- gr.Markdown(ctrlsum_file_md)
131
- with gr.Row():
132
- with gr.Column():
133
- ctrlsum_file = gr.File(label="Input File")
134
- with gr.Column():
135
- # ctrlsum_file_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
136
- # ctrlsum_file_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
137
- ctrlsum_file_length = gr.Slider(0,300,step=50, label="Length")
138
- ctrlsum_file_keywords = gr.Textbox(label="Keywords")
139
- with gr.Row():
140
- ctrlsum_file_btn = gr.Button("Generate")
141
- ctrlsum_file_output = gr.Textbox(
142
- elem_id="htext",
143
- label="Summary",
144
- )
145
- ctrlsum_file_examples = gr.Examples(examples=[["examples/BERT_body.txt", 100, ""],["examples/BERT_paper.pdf", 0, "BERT"]],
146
- inputs=[ctrlsum_file, ctrlsum_file_length, ctrlsum_file_keywords])
147
-
148
- ctrlsum_file_btn.click(
149
- fn=ctrlsum_for_file,
150
- inputs=[ctrlsum_file, ctrlsum_file_length, ctrlsum_file_keywords],
151
- outputs=ctrlsum_file_output
152
- )
153
- ctrlsum_str_btn.click(
154
- fn=ctrlsum_for_str,
155
- inputs=[ctrlsum_str, ctrlsum_str_length, ctrlsum_str_keywords],
156
- outputs=ctrlsum_str_output
157
- )
158
-
159
-
160
-
 
161
  demo.launch(share=False)
 
1
+ import gradio as gr
2
+ from description import *
3
+
4
+ from reference_string_parsing import *
5
+ from summarization import *
6
+ from controlled_summarization import *
7
+
8
+ with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
9
+ gr.Markdown("# SciAssist: Scientists' Assistant toolkit")
10
+ gr.Markdown("SciAssist currently supports Reference String Parsing, uncontrolled Summarization and Controlled Summarization. Github repo: https://github.com/WING-NUS/SciAssist")
11
+ with gr.Tabs():
12
+ # Reference String Parsing
13
+ with gr.TabItem("Reference String Parsing"):
14
+ with gr.Box():
15
+ gr.Markdown(rsp_str_md)
16
+ with gr.Row():
17
+ with gr.Column():
18
+ rsp_str = gr.Textbox(label="Input String")
19
+ with gr.Column():
20
+ rsp_str_dehyphen = gr.Checkbox(label="dehyphen")
21
+ with gr.Row():
22
+ rsp_str_btn = gr.Button("Parse")
23
+ rsp_str_output = gr.HighlightedText(
24
+ elem_id="htext",
25
+ label="The Result of Parsing",
26
+ combine_adjacent=True,
27
+ adjacent_separator=" ",
28
+ )
29
+ rsp_str_examples = gr.Examples(examples=[[
30
+ "Waleed Ammar, Matthew E. Peters, Chandra Bhagavat- ula, and Russell Power. 2017. The ai2 system at semeval-2017 task 10 (scienceie): semi-supervised end-to-end entity and relation extraction. In ACL workshop (SemEval).",
31
+ True],
32
+ [
33
+ "Isabelle Augenstein, Mrinal Das, Sebastian Riedel, Lakshmi Vikraman, and Andrew D. McCallum. 2017. Semeval-2017 task 10 (scienceie): Extracting keyphrases and relations from scientific publications. In ACL workshop (SemEval).",
34
+ False]], inputs=[rsp_str, rsp_str_dehyphen])
35
+ with gr.Box():
36
+ gr.Markdown(rsp_file_md)
37
+ with gr.Row():
38
+ with gr.Column():
39
+ rsp_file = gr.File(label="Input File")
40
+ rsp_file_dehyphen = gr.Checkbox(label="dehyphen")
41
+ with gr.Row():
42
+ rsp_file_btn = gr.Button("Parse")
43
+
44
+ rsp_file_output = gr.HighlightedText(
45
+ elem_id="htext",
46
+ label="The Result of Parsing",
47
+ combine_adjacent=True,
48
+ adjacent_separator=" ",
49
+ )
50
+ rsp_file_examples = gr.Examples(examples=[["examples/N18-3011_ref.txt", False],["examples/BERT_paper.pdf", True]], inputs=[rsp_file, rsp_file_dehyphen])
51
+
52
+
53
+ rsp_file_btn.click(
54
+ fn=rsp_for_file,
55
+ inputs=[rsp_file, rsp_file_dehyphen],
56
+ outputs=rsp_file_output
57
+ )
58
+ rsp_str_btn.click(
59
+ fn=rsp_for_str,
60
+ inputs=[rsp_str, rsp_str_dehyphen],
61
+ outputs=rsp_str_output
62
+ )
63
+
64
+ # Single Document Summarization
65
+ with gr.TabItem("General Summarization"):
66
+ with gr.Box():
67
+ gr.Markdown(ssum_str_md)
68
+ with gr.Row():
69
+ with gr.Column():
70
+ ssum_str = gr.Textbox(label="Input String")
71
+ # with gr.Column():
72
+ # ssum_str_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
73
+ # ssum_str_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
74
+ with gr.Row():
75
+ ssum_str_btn = gr.Button("Generate")
76
+ ssum_str_output = gr.Textbox(
77
+ elem_id="htext",
78
+ label="Summary",
79
+ )
80
+ ssum_str_examples = gr.Examples(examples=[[ssum_str_example], ],
81
+ inputs=[ssum_str])
82
+ with gr.Box():
83
+ gr.Markdown(ssum_file_md)
84
+ with gr.Row():
85
+ with gr.Column():
86
+ ssum_file = gr.File(label="Input File")
87
+ # with gr.Column():
88
+ # ssum_file_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
89
+ # ssum_file_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
90
+ with gr.Row():
91
+ ssum_file_btn = gr.Button("Generate")
92
+ ssum_file_output = gr.Textbox(
93
+ elem_id="htext",
94
+ label="Summary",
95
+ )
96
+ ssum_file_examples = gr.Examples(examples=[["examples/BERT_body.txt"],["examples/BERT_paper.pdf"]],
97
+ inputs=[ssum_file])
98
+
99
+ ssum_file_btn.click(
100
+ fn=ssum_for_file,
101
+ inputs=[ssum_file],
102
+ outputs=ssum_file_output
103
+ )
104
+ ssum_str_btn.click(
105
+ fn=ssum_for_str,
106
+ inputs=[ssum_str],
107
+ outputs=ssum_str_output
108
+ )
109
+
110
+ # Controlled Summarization
111
+ with gr.TabItem("Controlled Summarization"):
112
+ with gr.Box():
113
+ gr.Markdown(ctrlsum_str_md)
114
+ with gr.Row():
115
+ with gr.Column():
116
+ ctrlsum_str = gr.Textbox(label="Input String")
117
+ with gr.Column():
118
+ # ctrlsum_str_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
119
+ # ctrlsum_str_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
120
+ ctrlsum_str_length = gr.Slider(0, 300, step=50, label="Length")
121
+ ctrlsum_str_keywords = gr.Textbox(label="Keywords")
122
+ with gr.Row():
123
+ ctrlsum_str_btn = gr.Button("Generate")
124
+ ctrlsum_str_output = gr.Textbox(
125
+ elem_id="htext",
126
+ label="Summary",
127
+ )
128
+ ctrlsum_str_examples = gr.Examples(examples=[[ssum_str_example, 50, "BERT" ], ],
129
+ inputs=[ctrlsum_str, ctrlsum_str_length, ctrlsum_str_keywords])
130
+ with gr.Box():
131
+ gr.Markdown(ctrlsum_file_md)
132
+ with gr.Row():
133
+ with gr.Column():
134
+ ctrlsum_file = gr.File(label="Input File")
135
+ with gr.Column():
136
+ # ctrlsum_file_beams = gr.Number(label="Number of beams for beam search", value=1, precision=0)
137
+ # ctrlsum_file_sequences = gr.Number(label="Number of generated summaries", value=1, precision=0)
138
+ ctrlsum_file_length = gr.Slider(0,300,step=50, label="Length")
139
+ ctrlsum_file_keywords = gr.Textbox(label="Keywords")
140
+ with gr.Row():
141
+ ctrlsum_file_btn = gr.Button("Generate")
142
+ ctrlsum_file_output = gr.Textbox(
143
+ elem_id="htext",
144
+ label="Summary",
145
+ )
146
+ ctrlsum_file_examples = gr.Examples(examples=[["examples/BERT_body.txt", 100, ""],["examples/BERT_paper.pdf", 0, "BERT"]],
147
+ inputs=[ctrlsum_file, ctrlsum_file_length, ctrlsum_file_keywords])
148
+
149
+ ctrlsum_file_btn.click(
150
+ fn=ctrlsum_for_file,
151
+ inputs=[ctrlsum_file, ctrlsum_file_length, ctrlsum_file_keywords],
152
+ outputs=ctrlsum_file_output
153
+ )
154
+ ctrlsum_str_btn.click(
155
+ fn=ctrlsum_for_str,
156
+ inputs=[ctrlsum_str, ctrlsum_str_length, ctrlsum_str_keywords],
157
+ outputs=ctrlsum_str_output
158
+ )
159
+
160
+
161
+
162
  demo.launch(share=False)