Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -27,7 +27,12 @@ def generate_sentence_embedding(sentence, language):
|
|
27 |
embedding = sum_embeddings / sum_mask
|
28 |
return embedding
|
29 |
|
30 |
-
def calculate_cosine_similarities(
|
|
|
|
|
|
|
|
|
|
|
31 |
source_embedding = generate_sentence_embedding(source_sentence, source_language)
|
32 |
target_embedding_1 = generate_sentence_embedding(target_sentence_1, target_language_1)
|
33 |
target_embedding_2 = generate_sentence_embedding(target_sentence_2, target_language_2)
|
@@ -47,6 +52,7 @@ def calculate_cosine_similarities(source_sentence, source_language, target_sente
|
|
47 |
cosine_scores_output = "**" + cosine_scores_output.replace("\n", "**\n", 1)
|
48 |
return cosine_scores_output
|
49 |
|
|
|
50 |
def main():
|
51 |
demo = gr.Interface(
|
52 |
fn=calculate_cosine_similarities,
|
|
|
27 |
embedding = sum_embeddings / sum_mask
|
28 |
return embedding
|
29 |
|
30 |
+
def calculate_cosine_similarities(row_source_sentence, source_language, row_target_sentence_1, target_language_1, row_target_sentence_2, target_language_2, row_target_sentence_3, target_language_3):
|
31 |
+
source_sentence = row_source_sentence[0]
|
32 |
+
target_sentence_1 = row_target_sentence_1[0]
|
33 |
+
target_sentence_2 = row_target_sentence_2[0]
|
34 |
+
target_sentence_3 = row_target_sentence_3[0]
|
35 |
+
|
36 |
source_embedding = generate_sentence_embedding(source_sentence, source_language)
|
37 |
target_embedding_1 = generate_sentence_embedding(target_sentence_1, target_language_1)
|
38 |
target_embedding_2 = generate_sentence_embedding(target_sentence_2, target_language_2)
|
|
|
52 |
cosine_scores_output = "**" + cosine_scores_output.replace("\n", "**\n", 1)
|
53 |
return cosine_scores_output
|
54 |
|
55 |
+
|
56 |
def main():
|
57 |
demo = gr.Interface(
|
58 |
fn=calculate_cosine_similarities,
|