kargaranamir commited on
Commit
abf23c4
1 Parent(s): f120cea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -4
app.py CHANGED
@@ -18,6 +18,7 @@ import altair as alt
18
  from altair import X, Y, Scale
19
  import base64
20
  import json
 
21
 
22
  @st.cache_resource
23
  def load_sp():
@@ -225,18 +226,26 @@ with tab1:
225
  clicked = st.button("Submit")
226
 
227
  if sent:
228
- sent = sent.replace('\n', '')
229
 
230
  probs, labels = compute([sent], version=version)
231
  prob = probs[0]
232
  label = labels[0]
233
 
 
 
 
 
 
 
 
 
 
 
234
  # plot
235
  plot(label, prob)
236
 
237
- print(sent)
238
- with open("logs.txt", "a") as f:
239
- f.write(sent + "\n")
240
  with tab2:
241
 
242
  version = st.radio(
 
18
  from altair import X, Y, Scale
19
  import base64
20
  import json
21
+ import os
22
 
23
  @st.cache_resource
24
  def load_sp():
 
226
  clicked = st.button("Submit")
227
 
228
  if sent:
229
+ sent = sent.replace('\n', ' ')
230
 
231
  probs, labels = compute([sent], version=version)
232
  prob = probs[0]
233
  label = labels[0]
234
 
235
+
236
+ # Check if the file exists
237
+ if not os.path.exists('logs.txt'):
238
+ with open('logs.txt', 'w') as file:
239
+ pass
240
+
241
+ print(f"{sent}, {label}: {prob}")
242
+ with open("logs.txt", "a") as f:
243
+ f.write(f"{sent}, {label}: {prob}\n")
244
+
245
  # plot
246
  plot(label, prob)
247
 
248
+
 
 
249
  with tab2:
250
 
251
  version = st.radio(