Spaces:
Runtime error
Runtime error
Commit
·
026e9d4
1
Parent(s):
94b0e7c
Update app.py
Browse files
app.py
CHANGED
|
@@ -87,6 +87,8 @@ def init_session_states():
|
|
| 87 |
st.session_state['bio_model'] = None
|
| 88 |
if 'ner_bio' not in st.session_state:
|
| 89 |
st.session_state['ner_bio'] = None
|
|
|
|
|
|
|
| 90 |
|
| 91 |
|
| 92 |
|
|
@@ -119,6 +121,10 @@ def perform_inference(text,display_area):
|
|
| 119 |
display_area.text("Initializing BIO module...")
|
| 120 |
st.session_state['ner_bio'] = ner.UnsupNER("bio/ner_a100_config.json")
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
|
| 124 |
display_area.text("Getting predictions from BIO model...")
|
|
@@ -126,12 +132,16 @@ def perform_inference(text,display_area):
|
|
| 126 |
display_area.text("Computing BIO results...")
|
| 127 |
bio_ner = st.session_state['ner_bio'].tag_sentence_service(text,bio_descs)
|
| 128 |
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
|
| 132 |
sent_arr = [
|
| 133 |
"Lou Gehrig who works for XCorp and lives in New York suffers from Parkinson's ",
|
| 134 |
"Parkinson who works for XCorp and lives in New York suffers from Lou Gehrig's",
|
|
|
|
| 135 |
"lou gehrig was diagnosed with Parkinson's ",
|
| 136 |
"A eGFR below 60 indicates chronic kidney disease",
|
| 137 |
"Overexpression of EGFR occurs across a wide range of different cancers",
|
|
@@ -147,6 +157,7 @@ sent_arr = [
|
|
| 147 |
sent_arr_masked = [
|
| 148 |
"Lou Gehrig:__entity__ who works for XCorp:__entity__ and lives in New:__entity__ York:__entity__ suffers from Parkinson's:__entity__ ",
|
| 149 |
"Parkinson:__entity__ who works for XCorp:__entity__ and lives in New:__entity__ York:__entity__ suffers from Lou Gehrig's:__entity__",
|
|
|
|
| 150 |
"lou:__entity__ gehrig:__entity__ was diagnosed with Parkinson's:__entity__ ",
|
| 151 |
"A eGFR:__entity__ below 60 indicates chronic kidney disease",
|
| 152 |
"Overexpression of EGFR:__entity__ occurs across a wide range of different cancers",
|
|
|
|
| 87 |
st.session_state['bio_model'] = None
|
| 88 |
if 'ner_bio' not in st.session_state:
|
| 89 |
st.session_state['ner_bio'] = None
|
| 90 |
+
if 'aggr' not in st.session_state:
|
| 91 |
+
st.session_state['aggr'] = None
|
| 92 |
|
| 93 |
|
| 94 |
|
|
|
|
| 121 |
display_area.text("Initializing BIO module...")
|
| 122 |
st.session_state['ner_bio'] = ner.UnsupNER("bio/ner_a100_config.json")
|
| 123 |
|
| 124 |
+
if (st.session_state['aggr'] is None):
|
| 125 |
+
display_area.text("Initializing Aggregation module...")
|
| 126 |
+
st.session_state['aggr'] = aggr.AggregateNER("./ensemble_config.json")
|
| 127 |
+
|
| 128 |
|
| 129 |
|
| 130 |
display_area.text("Getting predictions from BIO model...")
|
|
|
|
| 132 |
display_area.text("Computing BIO results...")
|
| 133 |
bio_ner = st.session_state['ner_bio'].tag_sentence_service(text,bio_descs)
|
| 134 |
|
| 135 |
+
obj = json.loads(bio_ner)
|
| 136 |
+
combined_arr = [obj,obj]
|
| 137 |
+
aggregate_results = st.session_state['aggr'].fetch_all(text,combined_arr)
|
| 138 |
+
return aggregate_results
|
| 139 |
|
| 140 |
|
| 141 |
sent_arr = [
|
| 142 |
"Lou Gehrig who works for XCorp and lives in New York suffers from Parkinson's ",
|
| 143 |
"Parkinson who works for XCorp and lives in New York suffers from Lou Gehrig's",
|
| 144 |
+
"Her hypophysitis secondary to ipilimumab was well managed with supplemental hormones",
|
| 145 |
"lou gehrig was diagnosed with Parkinson's ",
|
| 146 |
"A eGFR below 60 indicates chronic kidney disease",
|
| 147 |
"Overexpression of EGFR occurs across a wide range of different cancers",
|
|
|
|
| 157 |
sent_arr_masked = [
|
| 158 |
"Lou Gehrig:__entity__ who works for XCorp:__entity__ and lives in New:__entity__ York:__entity__ suffers from Parkinson's:__entity__ ",
|
| 159 |
"Parkinson:__entity__ who works for XCorp:__entity__ and lives in New:__entity__ York:__entity__ suffers from Lou Gehrig's:__entity__",
|
| 160 |
+
"Her hypophysitis:__entity__ secondary to ipilimumab:__entity__ was well managed with supplemental:__entity__ hormones:__entity__",
|
| 161 |
"lou:__entity__ gehrig:__entity__ was diagnosed with Parkinson's:__entity__ ",
|
| 162 |
"A eGFR:__entity__ below 60 indicates chronic kidney disease",
|
| 163 |
"Overexpression of EGFR:__entity__ occurs across a wide range of different cancers",
|