deepugaur commited on
Commit
5572ae7
·
verified ·
1 Parent(s): 3a9379f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py CHANGED
@@ -31,3 +31,28 @@ if st.button('Translate'):
31
  translation = translate_word(word)
32
  st.write(f"Translation: {translation}")
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  translation = translate_word(word)
32
  st.write(f"Translation: {translation}")
33
 
34
+
35
+ test_data = [
36
+ {"english": "hello", "hindi": "नमस्ते"},
37
+ {"english": "world", "hindi": "दुनिया"},
38
+ {"english": "apple", "hindi": "सेब"},
39
+ {"english": "book", "hindi": "किताब"},
40
+ {"english": "computer", "hindi": "कंप्यूटर"}
41
+ ]
42
+
43
+ def translate_and_evaluate(test_data):
44
+ correct = 0
45
+ total = len(test_data)
46
+
47
+ for item in test_data:
48
+ translated_word = translate_word(item["english"])
49
+ if translated_word == item["hindi"]:
50
+ correct += 1
51
+
52
+ accuracy = (correct / total) * 100
53
+ return accuracy
54
+
55
+ # Calculate accuracy
56
+ accuracy = translate_and_evaluate(test_data)
57
+ print(f"Accuracy: {accuracy:.2f}%")
58
+