Spaces:
Runtime error
Runtime error
Commit
·
20efea7
1
Parent(s):
2832187
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,13 +13,15 @@ sentences = []
|
|
| 13 |
|
| 14 |
st.title("Sentence Similarity")
|
| 15 |
|
| 16 |
-
# Streamlit
|
| 17 |
|
| 18 |
-
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
if submit_button:
|
| 25 |
|
|
@@ -33,7 +35,7 @@ if submit_button:
|
|
| 33 |
sentence_embeddings = model.encode(sentences)
|
| 34 |
|
| 35 |
|
| 36 |
-
st.write('Similarity between
|
| 37 |
sentence_2,
|
| 38 |
cosine_similarity(sentence_embeddings[0].reshape(1, -1),
|
| 39 |
sentence_embeddings[1].reshape(1, -1))[0][0]) * 100)
|
|
|
|
| 13 |
|
| 14 |
st.title("Sentence Similarity")
|
| 15 |
|
| 16 |
+
# Streamlit form elements
|
| 17 |
|
| 18 |
+
with st.form("submission_form", clear_on_submit=False):
|
| 19 |
|
| 20 |
+
sentence_1 = st.text_input("Sentence 1 input")
|
| 21 |
+
|
| 22 |
+
sentence_2 = st.text_input("Sentence 2 input")
|
| 23 |
+
|
| 24 |
+
submit_button = st.form_submit_button("Compare Sentences")
|
| 25 |
|
| 26 |
if submit_button:
|
| 27 |
|
|
|
|
| 35 |
sentence_embeddings = model.encode(sentences)
|
| 36 |
|
| 37 |
|
| 38 |
+
st.write('Similarity between {} and {} is {}%'.format(sentence_1,
|
| 39 |
sentence_2,
|
| 40 |
cosine_similarity(sentence_embeddings[0].reshape(1, -1),
|
| 41 |
sentence_embeddings[1].reshape(1, -1))[0][0]) * 100)
|