Kuaaangwen commited on
Commit
15e7e9a
·
1 Parent(s): 56c44d6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -16
app.py CHANGED
@@ -40,24 +40,24 @@ if sidebar_selectbox == "Compare two sentences":
40
 
41
  submit_button_compare = st.form_submit_button("Compare Sentences")
42
 
43
- # If submit_button_compare clicked
44
- if submit_button_compare:
45
-
46
- # Perform calculations
47
-
48
- # Append input sentences to 'sentences' list
49
- sentences.append(sentence_1)
50
- sentences.append(sentence_2)
51
-
52
- # Create embeddings for both sentences
53
- sentence_embeddings = model.encode(sentences)
54
 
55
- cos_sim = cosine_similarity(sentence_embeddings[0].reshape(1, -1), sentence_embeddings[1].reshape(1, -1))[0][0]
56
- cos_sim = round(cos_sim * 100) # Convert to percentage and round-off
57
-
 
 
 
 
 
58
 
59
- st.write('Similarity between {} and {} is {}%'.format(sentence_1,
60
- sentence_2, cos_sim))
 
 
 
 
61
 
62
 
63
 
 
40
 
41
  submit_button_compare = st.form_submit_button("Compare Sentences")
42
 
43
+ # If submit_button_compare clicked
44
+ if submit_button_compare:
 
 
 
 
 
 
 
 
 
45
 
46
+ # Perform calculations
47
+
48
+ # Append input sentences to 'sentences' list
49
+ sentences.append(sentence_1)
50
+ sentences.append(sentence_2)
51
+
52
+ # Create embeddings for both sentences
53
+ sentence_embeddings = model.encode(sentences)
54
 
55
+ cos_sim = cosine_similarity(sentence_embeddings[0].reshape(1, -1), sentence_embeddings[1].reshape(1, -1))[0][0]
56
+ cos_sim = round(cos_sim * 100) # Convert to percentage and round-off
57
+
58
+
59
+ st.write('Similarity between {} and {} is {}%'.format(sentence_1,
60
+ sentence_2, cos_sim))
61
 
62
 
63