musfiqdehan commited on
Commit
75aab4f
1 Parent(s): 03e97cd

Refactor get_better_translation function in translators.py

Browse files
Files changed (1) hide show
  1. helper/translators.py +2 -128
helper/translators.py CHANGED
@@ -48,139 +48,13 @@ def google_translation(sentence: str, source="auto", target="en") -> str:
48
  return translated_sentence
49
 
50
 
51
- def get_better_translation(translator_func, src=""):
52
  src_mod = get_translated_digit(src)
53
- tgt = translator_func(src_mod)
54
  tgt = decontracting_words(tgt)
55
  tgt = tgt.replace('rupees', 'takas').replace('Rs', 'takas')
56
  return tgt
57
 
58
- # def select_translator(src, translator):
59
- # """
60
- # Select the translator
61
- # """
62
- # tgt = None
63
- # tgt_base = None
64
-
65
- # if translator == "Google":
66
- # tgt = get_better_translation(google_translation, src)
67
- # tgt = space_punc(tgt)
68
- # tgt_base = google_translation(src)
69
- # elif translator == "BanglaNMT":
70
- # tgt = get_better_translation(banglanmt_translation, src)
71
- # tgt = space_punc(tgt)
72
- # tgt_base = banglanmt_translation(src)
73
- # elif translator == "MyMemory":
74
- # tgt = get_better_translation(mymemory_translation, src)
75
- # tgt = space_punc(tgt)
76
- # tgt_base = mymemory_translation(src)
77
-
78
- # return tgt_base, tgt
79
-
80
- # Afrikaans
81
- # Albanian
82
- # Arabic
83
- # Aragonese
84
- # Armenian
85
- # Asturian
86
- # Azerbaijani
87
- # Bashkir
88
- # Basque
89
- # Bavarian
90
- # Belarusian
91
- # Bengali
92
- # Bishnupriya Manipuri
93
- # Bosnian
94
- # Breton
95
- # Bulgarian
96
- # Burmese
97
- # Catalan
98
- # Cebuano
99
- # Chechen
100
- # Chinese (Simplified)
101
- # Chinese (Traditional)
102
- # Chuvash
103
- # Croatian
104
- # Czech
105
- # Danish
106
- # Dutch
107
- # English
108
- # Estonian
109
- # Finnish
110
- # French
111
- # Galician
112
- # Georgian
113
- # German
114
- # Greek
115
- # Gujarati
116
- # Haitian
117
- # Hebrew
118
- # Hindi
119
- # Hungarian
120
- # Icelandic
121
- # Ido
122
- # Indonesian
123
- # Irish
124
- # Italian
125
- # Japanese
126
- # Javanese
127
- # Kannada
128
- # Kazakh
129
- # Kirghiz
130
- # Korean
131
- # Latin
132
- # Latvian
133
- # Lithuanian
134
- # Lombard
135
- # Low Saxon
136
- # Luxembourgish
137
- # Macedonian
138
- # Malagasy
139
- # Malay
140
- # Malayalam
141
- # Marathi
142
- # Minangkabau
143
- # Nepali
144
- # Newar
145
- # Norwegian (Bokmal)
146
- # Norwegian (Nynorsk)
147
- # Occitan
148
- # Persian (Farsi)
149
- # Piedmontese
150
- # Polish
151
- # Portuguese
152
- # Punjabi
153
- # Romanian
154
- # Russian
155
- # Scots
156
- # Serbian
157
- # Serbo-Croatian
158
- # Sicilian
159
- # Slovak
160
- # Slovenian
161
- # South Azerbaijani
162
- # Spanish
163
- # Sundanese
164
- # Swahili
165
- # Swedish
166
- # Tagalog
167
- # Tajik
168
- # Tamil
169
- # Tatar
170
- # Telugu
171
- # Turkish
172
- # Ukrainian
173
- # Urdu
174
- # Uzbek
175
- # Vietnamese
176
- # Volapük
177
- # Waray-Waray
178
- # Welsh
179
- # West Frisian
180
- # Western Punjabi
181
- # Yoruba
182
- # Thai
183
- # Mongolian
184
 
185
  target_lang_dict = {
186
  "Afrikaans": "af",
 
48
  return translated_sentence
49
 
50
 
51
+ def get_better_translation(src=""):
52
  src_mod = get_translated_digit(src)
53
+ tgt = google_translation(src_mod)
54
  tgt = decontracting_words(tgt)
55
  tgt = tgt.replace('rupees', 'takas').replace('Rs', 'takas')
56
  return tgt
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
  target_lang_dict = {
60
  "Afrikaans": "af",