Spaces:
Runtime error
Runtime error
publichealthsurveillance
commited on
Commit
•
a518b81
1
Parent(s):
6b3f9b7
Update app.py
Browse files
app.py
CHANGED
@@ -89,6 +89,7 @@ def vs_output(number):
|
|
89 |
return "neutral"
|
90 |
if int(number) == 2:
|
91 |
return "vaccine supportive"
|
|
|
92 |
|
93 |
def vs_BERT(text):
|
94 |
return "BERT ➡" + vs_output(vs_predictor_bert.predict(str(text)))
|
@@ -112,14 +113,23 @@ hm_predictor_bert = ktrain.load_predictor(folder + "bert")
|
|
112 |
hm_predictor_mental = ktrain.load_predictor(folder + "mentalbert")
|
113 |
hm_predictor_phs = ktrain.load_predictor(folder + "phsbert")
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
def hm_BERT(text):
|
116 |
-
return "BERT
|
117 |
|
118 |
def hm_MentalBERT(text):
|
119 |
-
return "MentalBERT
|
120 |
|
121 |
def hm_PHSBERT(text):
|
122 |
-
return "PHS-BERT
|
123 |
|
124 |
hm_bert_io = Interface(fn=hm_BERT, inputs="text", outputs="text")
|
125 |
hm_mental_io = Interface(fn=hm_MentalBERT, inputs="text", outputs="text")
|
@@ -134,14 +144,21 @@ covid_predictor_bert = ktrain.load_predictor(folder + "bert")
|
|
134 |
covid_predictor_mental = ktrain.load_predictor(folder + "mentalbert")
|
135 |
covid_predictor_phs = ktrain.load_predictor(folder + "phsbert")
|
136 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
def covid_BERT(text):
|
138 |
-
return "BERT
|
139 |
|
140 |
def covid_MentalBERT(text):
|
141 |
-
return "MentalBERT
|
142 |
|
143 |
def covid_PHSBERT(text):
|
144 |
-
return "PHS-BERT
|
145 |
|
146 |
covid_bert_io = Interface(fn=covid_BERT, inputs="text", outputs="text")
|
147 |
covid_mental_io = Interface(fn=covid_MentalBERT, inputs="text", outputs="text")
|
@@ -156,14 +173,21 @@ stress_predictor_bert = ktrain.load_predictor(folder + "bert")
|
|
156 |
stress_predictor_mental = ktrain.load_predictor(folder + "mentalbert")
|
157 |
stress_predictor_phs = ktrain.load_predictor(folder + "phsbert")
|
158 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
def stress_BERT(text):
|
160 |
-
return "BERT
|
161 |
|
162 |
def stress_MentalBERT(text):
|
163 |
-
return "MentalBERT
|
164 |
|
165 |
def stress_PHSBERT(text):
|
166 |
-
return "PHS-BERT
|
167 |
|
168 |
stress_bert_io = Interface(fn=stress_BERT, inputs="text", outputs="text")
|
169 |
stress_mental_io = Interface(fn=stress_MentalBERT, inputs="text", outputs="text")
|
@@ -178,14 +202,21 @@ other_predictor_bert = ktrain.load_predictor(folder + "bert")
|
|
178 |
other_predictor_mental = ktrain.load_predictor(folder + "mentalbert")
|
179 |
other_predictor_phs = ktrain.load_predictor(folder + "phsbert")
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
def other_BERT(text):
|
182 |
-
return "BERT
|
183 |
|
184 |
def other_MentalBERT(text):
|
185 |
-
return "MentalBERT
|
186 |
|
187 |
def other_PHSBERT(text):
|
188 |
-
return "PHS-BERT
|
189 |
|
190 |
other_bert_io = Interface(fn=other_BERT, inputs="text", outputs="text")
|
191 |
other_mental_io = Interface(fn=other_MentalBERT, inputs="text", outputs="text")
|
|
|
89 |
return "neutral"
|
90 |
if int(number) == 2:
|
91 |
return "vaccine supportive"
|
92 |
+
return "N/A"
|
93 |
|
94 |
def vs_BERT(text):
|
95 |
return "BERT ➡" + vs_output(vs_predictor_bert.predict(str(text)))
|
|
|
113 |
hm_predictor_mental = ktrain.load_predictor(folder + "mentalbert")
|
114 |
hm_predictor_phs = ktrain.load_predictor(folder + "phsbert")
|
115 |
|
116 |
+
def hm_output(number):
|
117 |
+
if int(number) == 0:
|
118 |
+
return "Figurative Health Mentions"
|
119 |
+
if int(number) == 1:
|
120 |
+
return "Non-Health Mentions"
|
121 |
+
if int(number) == 2:
|
122 |
+
return "Health Mentions"
|
123 |
+
return "N/A"
|
124 |
+
|
125 |
def hm_BERT(text):
|
126 |
+
return "BERT ➡ " + hm_output(hm_predictor_bert.predict(str(text)))
|
127 |
|
128 |
def hm_MentalBERT(text):
|
129 |
+
return "MentalBERT ➡ " + hm_output(hm_predictor_mental.predict(str(text)))
|
130 |
|
131 |
def hm_PHSBERT(text):
|
132 |
+
return "PHS-BERT ➡ " + hm_output(hm_predictor_phs.predict(str(text)))
|
133 |
|
134 |
hm_bert_io = Interface(fn=hm_BERT, inputs="text", outputs="text")
|
135 |
hm_mental_io = Interface(fn=hm_MentalBERT, inputs="text", outputs="text")
|
|
|
144 |
covid_predictor_mental = ktrain.load_predictor(folder + "mentalbert")
|
145 |
covid_predictor_phs = ktrain.load_predictor(folder + "phsbert")
|
146 |
|
147 |
+
def cv_output(number):
|
148 |
+
if int(number) == 0:
|
149 |
+
return "news"
|
150 |
+
if int(number) == 1:
|
151 |
+
return "personal narrative"
|
152 |
+
return "N/A"
|
153 |
+
|
154 |
def covid_BERT(text):
|
155 |
+
return "BERT ➡ " + cv_output(covid_predictor_bert.predict(str(text)))
|
156 |
|
157 |
def covid_MentalBERT(text):
|
158 |
+
return "MentalBERT ➡ " + cv_output(covid_predictor_mental.predict(str(text)))
|
159 |
|
160 |
def covid_PHSBERT(text):
|
161 |
+
return "PHS-BERT ➡ " + cv_output(covid_predictor_phs.predict(str(text)))
|
162 |
|
163 |
covid_bert_io = Interface(fn=covid_BERT, inputs="text", outputs="text")
|
164 |
covid_mental_io = Interface(fn=covid_MentalBERT, inputs="text", outputs="text")
|
|
|
173 |
stress_predictor_mental = ktrain.load_predictor(folder + "mentalbert")
|
174 |
stress_predictor_phs = ktrain.load_predictor(folder + "phsbert")
|
175 |
|
176 |
+
def st_output(number):
|
177 |
+
if int(number) == 0:
|
178 |
+
return "no stress"
|
179 |
+
if int(number) == 1:
|
180 |
+
return "stress"
|
181 |
+
return "N/A"
|
182 |
+
|
183 |
def stress_BERT(text):
|
184 |
+
return "BERT ➡ " + st_output(stress_predictor_bert.predict(str(text)))
|
185 |
|
186 |
def stress_MentalBERT(text):
|
187 |
+
return "MentalBERT ➡ " + st_output(stress_predictor_mental.predict(str(text)))
|
188 |
|
189 |
def stress_PHSBERT(text):
|
190 |
+
return "PHS-BERT ➡ " + st_output(stress_predictor_phs.predict(str(text)))
|
191 |
|
192 |
stress_bert_io = Interface(fn=stress_BERT, inputs="text", outputs="text")
|
193 |
stress_mental_io = Interface(fn=stress_MentalBERT, inputs="text", outputs="text")
|
|
|
202 |
other_predictor_mental = ktrain.load_predictor(folder + "mentalbert")
|
203 |
other_predictor_phs = ktrain.load_predictor(folder + "phsbert")
|
204 |
|
205 |
+
def ot_output(number):
|
206 |
+
if int(number) == 0:
|
207 |
+
return "no adverse drug reaction"
|
208 |
+
if int(number) == 1:
|
209 |
+
return "adverse drug reaction"
|
210 |
+
return "N/A"
|
211 |
+
|
212 |
def other_BERT(text):
|
213 |
+
return "BERT ➡ " + ot_output(other_predictor_bert.predict(str(text)))
|
214 |
|
215 |
def other_MentalBERT(text):
|
216 |
+
return "MentalBERT ➡ " + ot_output(other_predictor_mental.predict(str(text)))
|
217 |
|
218 |
def other_PHSBERT(text):
|
219 |
+
return "PHS-BERT ➡ " + ot_output(other_predictor_phs.predict(str(text)))
|
220 |
|
221 |
other_bert_io = Interface(fn=other_BERT, inputs="text", outputs="text")
|
222 |
other_mental_io = Interface(fn=other_MentalBERT, inputs="text", outputs="text")
|