dexay commited on
Commit
3b9fb6c
·
1 Parent(s): 18805a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -1
app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  import pandas as pd
3
  import transformers
4
  import re
 
5
  import postt
6
  from postt import postcor
7
  from transformers import pipeline, TokenClassificationPipeline, BertForTokenClassification , AutoTokenizer , TextClassificationPipeline , AutoModelForSequenceClassification
@@ -241,6 +242,45 @@ if submit and len(x) != 0:
241
  edccanbis = postcor(edccanbis)
242
 
243
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
  for e in edccanbis:
245
  edccan += [[e[3],e[0]+" ["+e[-1][0][2:]+"]", e[1]+" ["+e[-1][1][2:]+"]",e[2]]]
246
 
@@ -250,11 +290,18 @@ if submit and len(x) != 0:
250
  st.table(edccandf)
251
  csv = edccandf.to_csv(index=False).encode('utf-8')
252
  st.download_button(
253
- label="Download data as CSV",
254
  data=csv,
255
  file_name='Relation_triples.csv',
256
  mime='text/csv',
257
  )
 
 
 
 
 
 
 
258
 
259
 
260
 
 
2
  import pandas as pd
3
  import transformers
4
  import re
5
+ import zipfile
6
  import postt
7
  from postt import postcor
8
  from transformers import pipeline, TokenClassificationPipeline, BertForTokenClassification , AutoTokenizer , TextClassificationPipeline , AutoModelForSequenceClassification
 
242
  edccanbis = postcor(edccanbis)
243
 
244
 
245
+
246
+ edccann = []
247
+ edchorm = []
248
+ edcrecep = []
249
+ hormrecep = []
250
+ hormcan = []
251
+
252
+ for e in edccanbis:
253
+ if e[-1]== ["B-EDC","B-CANCER"]:
254
+ edccann += [[e[0],e[1],e[2]]
255
+ elif e[-1]== ["B-EDC","B-HORMONE"]:
256
+ edchorm += [[e[0],e[1],e[2]]
257
+ elif e[-1]== ["B-EDC","B-RECEPTOR"]:
258
+ edcrecep += [[e[0],e[1],e[2]]
259
+ elif e[-1]== ["B-HORMONE","B-RECEPTOR"]:
260
+ hormrecep += [[e[0],e[1],e[2]]
261
+ elif e[-1]== ["B-HORMONE","B-CANCER"]:
262
+ hormcan += [[e[0],e[1],e[2]]
263
+
264
+
265
+ edcrecepdf = pd.DataFrame(edcrecep, columns=["EDC", "RECEPTOR", "RELATION"])
266
+ edccanndf = pd.DataFrame(edccann, columns= ["EDC", "CANCER", "RELATION"] )
267
+ edchormdf = pd.DataFrame(edchorm , columns = ["EDC", "HORMONE", "RELATION"])
268
+ hormrecepdf = pd.DataFrame(hormrecep, columns = ["HORMONE", "RECEPTOR", "RELATION"])
269
+ hormcandf = pd.DataFrame(hormcan, columns = ["HORMONE", "CANCER", "RELATION"])
270
+
271
+ edccancsv = edccanndf.to_csv('edccan.csv')
272
+ edcrecepcsv = edcrecepdf.to_csv('edcrecep.csv')
273
+ edchormcsv = edchormdf.to_csv('edchorm.csv')
274
+ hormcancsv = hormcandf.to_csv('hormcan.csv')
275
+ hormrecepcsv = hormrecepdf.to_csv('hormrecep.csv')
276
+
277
+ with zipfile.ZipFile("allcsvs.zip", "w") as zipf:
278
+ zipf.write(edccancsv)
279
+ zipf.write(edcrecepcsv)
280
+ zipf.write(edchormcsv)
281
+ zipf.write(hormcancsv)
282
+ zipf.write(hormrecepcsv)
283
+
284
  for e in edccanbis:
285
  edccan += [[e[3],e[0]+" ["+e[-1][0][2:]+"]", e[1]+" ["+e[-1][1][2:]+"]",e[2]]]
286
 
 
290
  st.table(edccandf)
291
  csv = edccandf.to_csv(index=False).encode('utf-8')
292
  st.download_button(
293
+ label="Download all data as CSV",
294
  data=csv,
295
  file_name='Relation_triples.csv',
296
  mime='text/csv',
297
  )
298
+ st.download_button(
299
+ "Download in different CSVs",
300
+ zipf,
301
+ file_name='TriplesCSVs.zip',
302
+
303
+ )
304
+
305
 
306
 
307