wing-nus kirinzhu commited on
Commit
146a258
1 Parent(s): 1d5b312

add dataset extraction (#9)

Browse files

- Upload 3 files (25855ca468189f58824e501837e88e06b4c54cf2)


Co-authored-by: Linxiao Zhu <kirinzhu@users.noreply.huggingface.co>

Files changed (3) hide show
  1. app.py +48 -0
  2. description.py +16 -1
  3. requirements.txt +2 -1
app.py CHANGED
@@ -3,6 +3,7 @@ from description import *
3
 
4
  from reference_string_parsing import *
5
  from controlled_summarization import *
 
6
 
7
  with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
8
  gr.Markdown("# Gradio Demo for SciAssist")
@@ -95,4 +96,51 @@ with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
95
  )
96
 
97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  demo.launch(share=False)
 
3
 
4
  from reference_string_parsing import *
5
  from controlled_summarization import *
6
+ from dataset_extraction import *
7
 
8
  with gr.Blocks(css="#htext span {white-space: pre-line}") as demo:
9
  gr.Markdown("# Gradio Demo for SciAssist")
 
96
  )
97
 
98
 
99
+ # Dataset Extraction
100
+ with gr.TabItem("Dataset Mentions Extraction"):
101
+ with gr.Box():
102
+ gr.Markdown(de_str_md)
103
+ with gr.Row():
104
+ with gr.Column():
105
+ de_str = gr.Textbox(label="Input String")
106
+ with gr.Row():
107
+ de_str_btn = gr.Button("Extract")
108
+ de_str_output = gr.HighlightedText(
109
+ elem_id="htext",
110
+ label="The Result of Extraction",
111
+ combine_adjacent=True,
112
+ adjacent_separator=" ",
113
+ )
114
+ de_str_examples = gr.Examples(examples=[["The impact of gender identity on emotions was examined by researchers using a subsample from the National Longitudinal Study of Adolescent Health. The study aimed to investigate the direct effects of gender identity on emotional experiences and expression. By focusing on a subsample of the larger study, the researchers were able to hone in on the specific relationship between gender identity and emotions. Through their analysis, the researchers sought to determine whether gender identity could have a significant and direct impact on emotional well-being. The findings of the study have important implications for our understanding of the complex interplay between gender identity and emotional experiences, and may help to inform future interventions and support for individuals who experience gender-related emotional distress."],
115
+ ["The possibility of genotype-environment interaction for memory performance and change was examined in 150 monozygotic twin pairs from the Swedish Adoption Twin Study of Aging and the National Comorbidity Survey. They aimed to explore how genetic and environmental factors could interact to affect cognitive performance in aging individuals. Through their analysis, the researchers hoped to gain a better understanding of the complex interplay between nature and nurture in determining cognitive outcomes. By investigating the unique characteristics of monozygotic twins, who share identical genetic material, the study was able to isolate the role of environmental factors in shaping cognitive abilities over time. The findings from this research have important implications for our understanding of the complex interplay between genetics and the environment in shaping cognitive outcomes in aging individuals."]],
116
+ inputs=[de_str])
117
+ with gr.Box():
118
+ gr.Markdown(de_file_md)
119
+ with gr.Row():
120
+ with gr.Column():
121
+ de_file = gr.File(label="Input File")
122
+ with gr.Row():
123
+ de_file_btn = gr.Button("Extract")
124
+
125
+ de_file_output = gr.HighlightedText(
126
+ elem_id="htext",
127
+ label="The Result of Extraction",
128
+ combine_adjacent=True,
129
+ adjacent_separator=" ",
130
+ )
131
+ de_file_examples = gr.Examples(examples=[["examples/127.txt"]], inputs=[de_file])
132
+
133
+
134
+ de_file_btn.click(
135
+ fn=de_for_file,
136
+ inputs=[de_file],
137
+ outputs=de_file_output
138
+ )
139
+ de_str_btn.click(
140
+ fn=de_for_str,
141
+ inputs=[de_str],
142
+ outputs=de_str_output
143
+ )
144
+
145
+
146
  demo.launch(share=False)
description.py CHANGED
@@ -48,4 +48,19 @@ To **test on a file**, the input can be:
48
 
49
 
50
 
51
- '''
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
 
50
 
51
+ '''
52
+
53
+
54
+
55
+ de_str_md = '''
56
+ To **test on strings**, please input your sentences or paragraphs.
57
+ '''
58
+
59
+ de_file_md = '''
60
+ To **test on a file**, the input can be:
61
+
62
+ - A txt file which contains the content to be extracted dataset mentions from.
63
+
64
+ - A pdf file which contains a whole scientific documention without any preprocessing (including title, author, body text...).
65
+
66
+ '''
requirements.txt CHANGED
@@ -1,2 +1,3 @@
1
  torch==1.12.0
2
- SciAssist==0.0.36
 
 
1
  torch==1.12.0
2
+ SciAssist==0.0.32
3
+ nltk~=3.7