Kuaaangwen commited on
Commit
88993fe
·
1 Parent(s): 44264ed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -10
app.py CHANGED
@@ -7,11 +7,7 @@ from sklearn.metrics.pairwise import cosine_similarity
7
 
8
  model = SentenceTransformer('paraphrase-xlm-r-multilingual-v1')
9
 
10
- sentences = \
11
- [
12
- "I have a bigger house than you",
13
- "You have a bigger house than me"
14
- ]
15
 
16
  sentence_embeddings = model.encode(sentences)
17
 
@@ -25,9 +21,15 @@ print('Similarity between {} and {} is {}'.format(sentences[0],
25
  cosine_similarity(sentence_embeddings[0].reshape(1, -1),
26
  sentence_embeddings[1].reshape(1, -1))[0][0]))
27
 
28
- st.title("Similarity text")
29
 
30
- st.write('Similarity between {} and {} is {}'.format(sentences[0],
31
- sentences[1],
32
- cosine_similarity(sentence_embeddings[0].reshape(1, -1),
33
- sentence_embeddings[1].reshape(1, -1))[0][0]))
 
 
 
 
 
 
 
7
 
8
  model = SentenceTransformer('paraphrase-xlm-r-multilingual-v1')
9
 
10
+ sentences = []
 
 
 
 
11
 
12
  sentence_embeddings = model.encode(sentences)
13
 
 
21
  cosine_similarity(sentence_embeddings[0].reshape(1, -1),
22
  sentence_embeddings[1].reshape(1, -1))[0][0]))
23
 
24
+ st.title("Sentence Similarity")
25
 
26
+ sentence_1 = st.text_input("Sentence 1 input")
27
+
28
+ sentence_2 = st.text_input("Sentence 2 input")
29
+
30
+ submit_button = st.button("submit")
31
+
32
+ if st.button('submit'):
33
+ sentences.append(sentence_1)
34
+ sentences.append(sentence_2)
35
+ st.write(sentences)