innocent-charles commited on
Commit
f39ded6
1 Parent(s): 224143d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -9
app.py CHANGED
@@ -7,7 +7,7 @@ def load_model(model_name):
7
  return SentenceTransformer(model_name)
8
 
9
  # Function to compute similarity and classify relationship
10
- def predict(model_name_display, original_sentence_input, sentence_1=None, sentence_2=None, sentence_3=None):
11
  model_name = "sartifyllc/African-Cross-Lingua-Embeddings-Model"
12
  model = load_model(model_name)
13
  result = {
@@ -16,7 +16,9 @@ def predict(model_name_display, original_sentence_input, sentence_1=None, senten
16
  "Sentences to Compare": {
17
  "Sentence 1": sentence_1,
18
  "Sentence 2": sentence_2,
19
- "Sentence 3": sentence_3
 
 
20
  },
21
  "Similarity Scores": {}
22
  }
@@ -32,7 +34,9 @@ def predict(model_name_display, original_sentence_input, sentence_1=None, senten
32
  similarity_scores = {
33
  "Sentence 1": float(similarities[0, 0]),
34
  "Sentence 2": float(similarities[0, 1]),
35
- "Sentence 3": float(similarities[0, 2])
 
 
36
  }
37
  result["Similarity Scores"] = similarity_scores
38
 
@@ -41,9 +45,12 @@ def predict(model_name_display, original_sentence_input, sentence_1=None, senten
41
  model_name_display = gr.Markdown(value="**Model Name**: sartifyllc/African-Cross-Lingua-Embeddings-Model")
42
  original_sentence_input = gr.Textbox(lines=2, placeholder="Enter the original sentence here...", label="Original Sentence")
43
 
44
- sentence_1 = gr.Textbox(lines=2, placeholder="Enter the first sentence here...", label="Sentence 1")
45
- sentence_2 = gr.Textbox(lines=2, placeholder="Enter the second sentence here...", label="Sentence 2")
46
- sentence_3 = gr.Textbox(lines=2, placeholder="Enter the third sentence here...", label="Sentence 3")
 
 
 
47
 
48
  inputs = [model_name_display, original_sentence_input, sentence_1, sentence_2, sentence_3]
49
  outputs = gr.JSON(label="Detailed Similarity Scores")
@@ -63,21 +70,27 @@ gr.Interface(
63
  "Jua linawaka sana leo.",
64
  "Òrùlé jẹ́ tí ó ti máa ń tan-ìmólẹ̀ lónìí.",
65
  "Ran na haske sosai yau.",
66
- "The sun is shining brightly today."
 
 
67
  ],
68
  [
69
  "sartifyllc/African-Cross-Lingua-Embeddings-Model",
70
  "Mbuzi anaruka juu ya uzio.",
71
  "Àgbò ohun ti ń kọjú wá sórí orí-ọ̀kẹ́.",
72
  "Kura mai sauri tana tsalle kan kare mai barci.",
73
- "The goat is jumping over the fence."
 
 
74
  ],
75
  [
76
  "sartifyllc/African-Cross-Lingua-Embeddings-Model",
77
  "Ninapenda kujifunza lugha mpya.",
78
  "Mo nífẹ̀ẹ́ láti kọ́ èdè tuntun.",
79
  "Ina son koyon sababbin harsuna.",
80
- "I love learning new languages."
 
 
81
  ]
82
  ]
83
 
 
7
  return SentenceTransformer(model_name)
8
 
9
  # Function to compute similarity and classify relationship
10
+ def predict(model_name_display, original_sentence_input, sentence_1=None, sentence_2=None, sentence_3=None, sentence_4=None, sentence_5=None):
11
  model_name = "sartifyllc/African-Cross-Lingua-Embeddings-Model"
12
  model = load_model(model_name)
13
  result = {
 
16
  "Sentences to Compare": {
17
  "Sentence 1": sentence_1,
18
  "Sentence 2": sentence_2,
19
+ "Sentence 3": sentence_3,
20
+ "Sentence 4": sentence_4,
21
+ "Sentence 5": sentence_5
22
  },
23
  "Similarity Scores": {}
24
  }
 
34
  similarity_scores = {
35
  "Sentence 1": float(similarities[0, 0]),
36
  "Sentence 2": float(similarities[0, 1]),
37
+ "Sentence 3": float(similarities[0, 2]),
38
+ "Sentence 4": float(similarities[0, 3]),
39
+ "Sentence 5": float(similarities[0, 4]),
40
  }
41
  result["Similarity Scores"] = similarity_scores
42
 
 
45
  model_name_display = gr.Markdown(value="**Model Name**: sartifyllc/African-Cross-Lingua-Embeddings-Model")
46
  original_sentence_input = gr.Textbox(lines=2, placeholder="Enter the original sentence here...", label="Original Sentence")
47
 
48
+ sentence_1 = gr.Textbox(lines=2, placeholder="Enter the sentence to compare here...", label="Sentence 1")
49
+ sentence_2 = gr.Textbox(lines=2, placeholder="Enter the sentence to compare here...", label="Sentence 2")
50
+ sentence_3 = gr.Textbox(lines=2, placeholder="Enter the sentence to compare here...", label="Sentence 3")
51
+ sentence_4 = gr.Textbox(lines=2, placeholder="Enter the sentence to compare here...", label="Sentence 4")
52
+ sentence_5 = gr.Textbox(lines=2, placeholder="Enter the sentence to compare here...", label="Sentence 5")
53
+
54
 
55
  inputs = [model_name_display, original_sentence_input, sentence_1, sentence_2, sentence_3]
56
  outputs = gr.JSON(label="Detailed Similarity Scores")
 
70
  "Jua linawaka sana leo.",
71
  "Òrùlé jẹ́ tí ó ti máa ń tan-ìmólẹ̀ lónìí.",
72
  "Ran na haske sosai yau.",
73
+ "The sun is shining brightly today.",
74
+ "napenda sana jua",
75
+ "schooling is kinda boring, I don't like it"
76
  ],
77
  [
78
  "sartifyllc/African-Cross-Lingua-Embeddings-Model",
79
  "Mbuzi anaruka juu ya uzio.",
80
  "Àgbò ohun ti ń kọjú wá sórí orí-ọ̀kẹ́.",
81
  "Kura mai sauri tana tsalle kan kare mai barci.",
82
+ "The goat is jumping over the fence.",
83
+ "Àgbò ohun ti ń kọjú wá sórí orí-ọ̀kẹ́.",
84
+ "The cat is sleeping under the table."
85
  ],
86
  [
87
  "sartifyllc/African-Cross-Lingua-Embeddings-Model",
88
  "Ninapenda kujifunza lugha mpya.",
89
  "Mo nífẹ̀ẹ́ láti kọ́ èdè tuntun.",
90
  "Ina son koyon sababbin harsuna.",
91
+ "I love learning new languages.",
92
+ "Ina son koyon sababbin harsuna.",
93
+ "botu neyle ki lo no"
94
  ]
95
  ]
96