Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,38 +6,6 @@ import jsonlines
|
|
6 |
import json
|
7 |
|
8 |
st.markdown("# π Auto-generating Question-Answering Datasets with Domain-Specific Knowledge for Language Models in Scientific Tasks", unsafe_allow_html=True)
|
9 |
-
|
10 |
-
##########
|
11 |
-
# Transformation Algorithm
|
12 |
-
##########
|
13 |
-
st.markdown('## π₯οΈ QA Dataset Auto Generation', unsafe_allow_html=True)
|
14 |
-
|
15 |
-
cde_lst = ["./CDE_properties.jsonl"]
|
16 |
-
paper_lst = ["./reference_paper.json"]
|
17 |
-
|
18 |
-
st.session_state['cde'] = "./CDE_properties.jsonl"
|
19 |
-
st.session_state['cde'] = st.selectbox("ChemDataExtractor generated database path:", cde_lst)
|
20 |
-
st.write("Example of the data record in the ChemDataExtractor generated database: ")
|
21 |
-
with open(st.session_state['cde'], 'r') as file:
|
22 |
-
for line in file:
|
23 |
-
json_data = json.loads(line.strip())
|
24 |
-
json_string = json.dumps(json_data, indent=4)
|
25 |
-
st.text_area("", value=json_string, height=200)
|
26 |
-
break
|
27 |
-
|
28 |
-
st.session_state['paper'] = "./reference_paper.json"
|
29 |
-
st.session_state['paper'] = st.selectbox("Paper collection path:", paper_lst)
|
30 |
-
st.write("Example of the paper in collection: ")
|
31 |
-
with open(st.session_state['paper'],'r+', encoding = "utf-8") as f:
|
32 |
-
string = f.read()
|
33 |
-
extractions = json.loads(string)
|
34 |
-
for extraction in extractions:
|
35 |
-
json_data = json.loads(extraction)
|
36 |
-
json_string = json.dumps(json_data, indent=4)
|
37 |
-
st.text_area("", value=json_string, height=200)
|
38 |
-
break
|
39 |
-
|
40 |
-
|
41 |
|
42 |
##########
|
43 |
# Question Answering
|
@@ -106,6 +74,8 @@ if st.button('Extract the answer'):
|
|
106 |
else:
|
107 |
st.write("Please enter both a question and context.")
|
108 |
|
|
|
|
|
109 |
##########
|
110 |
# Property Extraction
|
111 |
##########
|
@@ -141,3 +111,35 @@ if st.button('Extract the property'):
|
|
141 |
st.write("Please enter both a question and context.")
|
142 |
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
import json
|
7 |
|
8 |
st.markdown("# π Auto-generating Question-Answering Datasets with Domain-Specific Knowledge for Language Models in Scientific Tasks", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
##########
|
11 |
# Question Answering
|
|
|
74 |
else:
|
75 |
st.write("Please enter both a question and context.")
|
76 |
|
77 |
+
|
78 |
+
|
79 |
##########
|
80 |
# Property Extraction
|
81 |
##########
|
|
|
111 |
st.write("Please enter both a question and context.")
|
112 |
|
113 |
|
114 |
+
|
115 |
+
##########
|
116 |
+
# Transformation Algorithm
|
117 |
+
##########
|
118 |
+
st.markdown('## π₯οΈ QA Dataset Auto Generation', unsafe_allow_html=True)
|
119 |
+
|
120 |
+
cde_lst = ["./CDE_properties.jsonl"]
|
121 |
+
paper_lst = ["./reference_paper.json"]
|
122 |
+
|
123 |
+
st.session_state['cde'] = "./CDE_properties.jsonl"
|
124 |
+
st.session_state['cde'] = st.selectbox("ChemDataExtractor generated database path:", cde_lst)
|
125 |
+
st.write("Example of the data record in the ChemDataExtractor generated database: ")
|
126 |
+
with open(st.session_state['cde'], 'r') as file:
|
127 |
+
for line in file:
|
128 |
+
json_data = json.loads(line.strip())
|
129 |
+
json_string = json.dumps(json_data, indent=4)
|
130 |
+
st.text_area("", value=json_string, height=200)
|
131 |
+
break
|
132 |
+
|
133 |
+
st.session_state['paper'] = "./reference_paper.json"
|
134 |
+
st.session_state['paper'] = st.selectbox("Paper collection path:", paper_lst)
|
135 |
+
st.write("Example of the paper in collection: ")
|
136 |
+
with open(st.session_state['paper'],'r+', encoding = "utf-8") as f:
|
137 |
+
string = f.read()
|
138 |
+
extractions = json.loads(string)
|
139 |
+
for extraction in extractions:
|
140 |
+
json_data = json.loads(extraction)
|
141 |
+
json_string = json.dumps(json_data, indent=4)
|
142 |
+
st.text_area("", value=json_string, height=200)
|
143 |
+
break
|
144 |
+
|
145 |
+
|