Rifky commited on
Commit
9878be5
·
1 Parent(s): 5759bd5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -13
app.py CHANGED
@@ -65,22 +65,23 @@ if submit:
65
 
66
  print (f'\nresult: {result}')
67
 
 
 
 
 
 
 
 
68
  input_column.markdown(f"<small>Compute Finished in {int(time.time() - last_time)} seconds</small>", unsafe_allow_html=True)
69
  prediction = np.argmax(result, axis=-1)
70
  input_column.success(f"This news is {label[prediction]}.")
71
  input_column.text(f"{int(result[prediction]*100)}% confidence")
72
  input_column.progress(result[prediction])
73
 
74
- title_embeddings = base_model.encode(title)
75
- similarity_score = cosine_similarity(
76
- [title_embeddings],
77
- data["embeddings"]
78
- ).flatten()
79
- sorted = np.argsort(similarity_score)[::-1].tolist()
80
- for i in sorted[:5]:
81
- reference_column.write(f"""
82
- <a href={data["url"][i]}><small>turnbackhoax.id</small></a>
83
- <h5>{data["title"][i]}</h5>
84
- """, unsafe_allow_html=True)
85
- with reference_column.expander("read content"):
86
- st.write(data["text"][i])
 
65
 
66
  print (f'\nresult: {result}')
67
 
68
+ title_embeddings = base_model.encode(title)
69
+ similarity_score = cosine_similarity(
70
+ [title_embeddings],
71
+ data["embeddings"]
72
+ ).flatten()
73
+ sorted = np.argsort(similarity_score)[::-1].tolist()
74
+
75
  input_column.markdown(f"<small>Compute Finished in {int(time.time() - last_time)} seconds</small>", unsafe_allow_html=True)
76
  prediction = np.argmax(result, axis=-1)
77
  input_column.success(f"This news is {label[prediction]}.")
78
  input_column.text(f"{int(result[prediction]*100)}% confidence")
79
  input_column.progress(result[prediction])
80
 
81
+ for i in sorted[:5]:
82
+ reference_column.write(f"""
83
+ <a href={data["url"][i]}><small>turnbackhoax.id</small></a>
84
+ <h5>{data["title"][i]}</h5>
85
+ """, unsafe_allow_html=True)
86
+ with reference_column.expander("read content"):
87
+ st.write(data["text"][i])