shohabbosdev commited on
Commit
b81fc38
1 Parent(s): a36b8a4

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +54 -0
  2. countries_code.py +242 -0
  3. requirements.txt +1 -0
app.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import gradio as gr
3
+ from countries_code import a
4
+
5
+ def binary_search(list,item):
6
+ low=0
7
+ high = len(list)-1
8
+ while low <= high:
9
+ mid = (low + high)//2
10
+ guess = list[mid]
11
+
12
+ if guess == item:
13
+ return mid
14
+ elif guess > item:
15
+ high = mid - 1
16
+ else:
17
+ low = mid + 1
18
+ return None
19
+
20
+ list1 = [a[j]['code'] for j in range(len(a))]
21
+ list2 = [a[i]['name'] for i in range(len(a))]
22
+
23
+ def name_gender(name,country):
24
+ try:
25
+ if name!='' and country!='':
26
+ country = list1[binary_search(list2,country)]
27
+ url = f"https://api.genderize.io/?name={name.title()}&country_id={country}"
28
+ response = requests.get(url)
29
+ if response.status_code==200:
30
+ return response.json()
31
+ else:
32
+ return f"Serverdan so'rov kelmadi: {response.status_code}"
33
+
34
+ except Exception as e:
35
+ return f"Xatolik: {e}"
36
+
37
+ demo = gr.Interface(
38
+ fn=name_gender,
39
+ description=
40
+ """
41
+ <h1 align="center">Name to Gender</h1>
42
+ O'z ismingizni kiriting va qaysi millat fuqarosi ekanligini taxmin qilib ko'ring<br>
43
+ Creator: <a href="https://t.me/shohabbosdev">Shoh Abbos</a>
44
+ """,
45
+ inputs=[
46
+ gr.Textbox(placeholder="Ismingizni kiriting...", label="Ism", autofocus=True),
47
+ gr.Dropdown(choices=list2, value="Uzbekistan", allow_custom_value=True)
48
+ ],
49
+ submit_btn = gr.Button("Aniqlash", variant="primary"),
50
+ clear_btn = gr.Button("Tozalash", variant="secondary"),
51
+ outputs = gr.JSON(label="Natija oynasi")
52
+ )
53
+ if __name__ == "__main__":
54
+ demo.launch(share=False)
countries_code.py ADDED
@@ -0,0 +1,242 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ a=[
2
+ {"name": "Afg'onistom", "code": "AF"},
3
+ {"name": "Indeksatsion Orollar", "code": "AX"},
4
+ {"name": "Albaniya", "code": "AL"},
5
+ {"name": "Jazoir", "code": "DZ"},
6
+ {"name": "Amerika Samoasi", "code": "AS"},
7
+ {"name": "AndorrA", "code": "AD"},
8
+ {"name": "Angola", "code": "AO"},
9
+ {"name": "Anguilla", "code": "AI"},
10
+ {"name": "Antarctica", "code": "AQ"},
11
+ {"name": "Antigua and Barbuda", "code": "AG"},
12
+ {"name": "Argentina", "code": "AR"},
13
+ {"name": "Armenia", "code": "AM"},
14
+ {"name": "Aruba", "code": "AW"},
15
+ {"name": "Australia", "code": "AU"},
16
+ {"name": "Austria", "code": "AT"},
17
+ {"name": "Azerbaijan", "code": "AZ"},
18
+ {"name": "Bahamas", "code": "BS"},
19
+ {"name": "Bahrain", "code": "BH"},
20
+ {"name": "Bangladesh", "code": "BD"},
21
+ {"name": "Barbados", "code": "BB"},
22
+ {"name": "Belarus", "code": "BY"},
23
+ {"name": "Belgium", "code": "BE"},
24
+ {"name": "Belize", "code": "BZ"},
25
+ {"name": "Benin", "code": "BJ"},
26
+ {"name": "Bermuda", "code": "BM"},
27
+ {"name": "Bhutan", "code": "BT"},
28
+ {"name": "Bolivia", "code": "BO"},
29
+ {"name": "Bosnia and Herzegovina", "code": "BA"},
30
+ {"name": "Botswana", "code": "BW"},
31
+ {"name": "Bouvet Island", "code": "BV"},
32
+ {"name": "Brazil", "code": "BR"},
33
+ {"name": "British Indian Ocean Territory", "code": "IO"},
34
+ {"name": "Brunei Darussalam", "code": "BN"},
35
+ {"name": "Bulgaria", "code": "BG"},
36
+ {"name": "Burkina Faso", "code": "BF"},
37
+ {"name": "Burundi", "code": "BI"},
38
+ {"name": "Cambodia", "code": "KH"},
39
+ {"name": "Cameroon", "code": "CM"},
40
+ {"name": "Canada", "code": "CA"},
41
+ {"name": "Cape Verde", "code": "CV"},
42
+ {"name": "Cayman Islands", "code": "KY"},
43
+ {"name": "Central African Republic", "code": "CF"},
44
+ {"name": "Chad", "code": "TD"},
45
+ {"name": "Chile", "code": "CL"},
46
+ {"name": "China", "code": "CN"},
47
+ {"name": "Christmas Island", "code": "CX"},
48
+ {"name": "Cocos (Keeling) Islands", "code": "CC"},
49
+ {"name": "Colombia", "code": "CO"},
50
+ {"name": "Comoros", "code": "KM"},
51
+ {"name": "Congo", "code": "CG"},
52
+ {"name": "Congo, The Democratic Republic of the", "code": "CD"},
53
+ {"name": "Cook Islands", "code": "CK"},
54
+ {"name": "Costa Rica", "code": "CR"},
55
+ {"name": "Croatia", "code": "HR"},
56
+ {"name": "Cuba", "code": "CU"},
57
+ {"name": "Cyprus", "code": "CY"},
58
+ {"name": "Czech Republic", "code": "CZ"},
59
+ {"name": "Denmark", "code": "DK"},
60
+ {"name": "Djibouti", "code": "DJ"},
61
+ {"name": "Dominica", "code": "DM"},
62
+ {"name": "Dominican Republic", "code": "DO"},
63
+ {"name": "Ecuador", "code": "EC"},
64
+ {"name": "Egypt", "code": "EG"},
65
+ {"name": "El Salvador", "code": "SV"},
66
+ {"name": "Equatorial Guinea", "code": "GQ"},
67
+ {"name": "Eritrea", "code": "ER"},
68
+ {"name": "Estonia", "code": "EE"},
69
+ {"name": "Ethiopia", "code": "ET"},
70
+ {"name": "Falkland Islands (Malvinas)", "code": "FK"},
71
+ {"name": "Faroe Islands", "code": "FO"},
72
+ {"name": "Fiji", "code": "FJ"},
73
+ {"name": "Finland", "code": "FI"},
74
+ {"name": "France", "code": "FR"},
75
+ {"name": "French Guiana", "code": "GF"},
76
+ {"name": "French Polynesia", "code": "PF"},
77
+ {"name": "French Southern Territories", "code": "TF"},
78
+ {"name": "Gabon", "code": "GA"},
79
+ {"name": "Gambia", "code": "GM"},
80
+ {"name": "Georgia", "code": "GE"},
81
+ {"name": "Germany", "code": "DE"},
82
+ {"name": "Ghana", "code": "GH"},
83
+ {"name": "Gibraltar", "code": "GI"},
84
+ {"name": "Greece", "code": "GR"},
85
+ {"name": "Greenland", "code": "GL"},
86
+ {"name": "Grenada", "code": "GD"},
87
+ {"name": "Guadeloupe", "code": "GP"},
88
+ {"name": "Guam", "code": "GU"},
89
+ {"name": "Guatemala", "code": "GT"},
90
+ {"name": "Guernsey", "code": "GG"},
91
+ {"name": "Guinea", "code": "GN"},
92
+ {"name": "Guinea-Bissau", "code": "GW"},
93
+ {"name": "Guyana", "code": "GY"},
94
+ {"name": "Haiti", "code": "HT"},
95
+ {"name": "Heard Island and Mcdonald Islands", "code": "HM"},
96
+ {"name": "Holy See (Vatican City State)", "code": "VA"},
97
+ {"name": "Honduras", "code": "HN"},
98
+ {"name": "Hong Kong", "code": "HK"},
99
+ {"name": "Hungary", "code": "HU"},
100
+ {"name": "Iceland", "code": "IS"},
101
+ {"name": "India", "code": "IN"},
102
+ {"name": "Indonesia", "code": "ID"},
103
+ {"name": "Iran, Islamic Republic Of", "code": "IR"},
104
+ {"name": "Iraq", "code": "IQ"},
105
+ {"name": "Ireland", "code": "IE"},
106
+ {"name": "Isle of Man", "code": "IM"},
107
+ {"name": "Israel", "code": "IL"},
108
+ {"name": "Italy", "code": "IT"},
109
+ {"name": "Jamaica", "code": "JM"},
110
+ {"name": "Japan", "code": "JP"},
111
+ {"name": "Jersey", "code": "JE"},
112
+ {"name": "Jordan", "code": "JO"},
113
+ {"name": "Kazakhstan", "code": "KZ"},
114
+ {"name": "Kenya", "code": "KE"},
115
+ {"name": "Kiribati", "code": "KI"},
116
+ {"name": "Korea, Republic of", "code": "KR"},
117
+ {"name": "Kuwait", "code": "KW"},
118
+ {"name": "Kyrgyzstan", "code": "KG"},
119
+ {"name": "Latvia", "code": "LV"},
120
+ {"name": "Lebanon", "code": "LB"},
121
+ {"name": "Lesotho", "code": "LS"},
122
+ {"name": "Liberia", "code": "LR"},
123
+ {"name": "Libyan Arab Jamahiriya", "code": "LY"},
124
+ {"name": "Liechtenstein", "code": "LI"},
125
+ {"name": "Lithuania", "code": "LT"},
126
+ {"name": "Luxembourg", "code": "LU"},
127
+ {"name": "Macao", "code": "MO"},
128
+ {"name": "North Macedonia", "code": "MK"},
129
+ {"name": "Madagascar", "code": "MG"},
130
+ {"name": "Malawi", "code": "MW"},
131
+ {"name": "Malaysia", "code": "MY"},
132
+ {"name": "Maldives", "code": "MV"},
133
+ {"name": "Mali", "code": "ML"},
134
+ {"name": "Malta", "code": "MT"},
135
+ {"name": "Marshall Islands", "code": "MH"},
136
+ {"name": "Martinique", "code": "MQ"},
137
+ {"name": "Mauritania", "code": "MR"},
138
+ {"name": "Mauritius", "code": "MU"},
139
+ {"name": "Mayotte", "code": "YT"},
140
+ {"name": "Mexico", "code": "MX"},
141
+ {"name": "Micronesia, Federated States of", "code": "FM"},
142
+ {"name": "Moldova, Republic of", "code": "MD"},
143
+ {"name": "Monaco", "code": "MC"},
144
+ {"name": "Mongolia", "code": "MN"},
145
+ {"name": "Montserrat", "code": "MS"},
146
+ {"name": "Morocco", "code": "MA"},
147
+ {"name": "Mozambique", "code": "MZ"},
148
+ {"name": "Myanmar", "code": "MM"},
149
+ {"name": "Namibia", "code": "NA"},
150
+ {"name": "Nauru", "code": "NR"},
151
+ {"name": "Nepal", "code": "NP"},
152
+ {"name": "Netherlands", "code": "NL"},
153
+ {"name": "Netherlands Antilles", "code": "AN"},
154
+ {"name": "New Caledonia", "code": "NC"},
155
+ {"name": "New Zealand", "code": "NZ"},
156
+ {"name": "Nicaragua", "code": "NI"},
157
+ {"name": "Niger", "code": "NE"},
158
+ {"name": "Nigeria", "code": "NG"},
159
+ {"name": "Niue", "code": "NU"},
160
+ {"name": "Norfolk Island", "code": "NF"},
161
+ {"name": "Northern Mariana Islands", "code": "MP"},
162
+ {"name": "Norway", "code": "NO"},
163
+ {"name": "Oman", "code": "OM"},
164
+ {"name": "Pakistan", "code": "PK"},
165
+ {"name": "Palau", "code": "PW"},
166
+ {"name": "Palestinian Territory, Occupied", "code": "PS"},
167
+ {"name": "Panama", "code": "PA"},
168
+ {"name": "Papua New Guinea", "code": "PG"},
169
+ {"name": "Paraguay", "code": "PY"},
170
+ {"name": "Peru", "code": "PE"},
171
+ {"name": "Philippines", "code": "PH"},
172
+ {"name": "Pitcairn Islands", "code": "PN"},
173
+ {"name": "Poland", "code": "PL"},
174
+ {"name": "Portugal", "code": "PT"},
175
+ {"name": "Puerto Rico", "code": "PR"},
176
+ {"name": "Qatar", "code": "QA"},
177
+ {"name": "Reunion", "code": "RE"},
178
+ {"name": "Romania", "code": "RO"},
179
+ {"name": "Russian Federation", "code": "RU"},
180
+ {"name": "Rwanda", "code": "RW"},
181
+ {"name": "Saint Helena", "code": "SH"},
182
+ {"name": "Saint Kitts and Nevis", "code": "KN"},
183
+ {"name": "Saint Lucia", "code": "LC"},
184
+ {"name": "Saint Pierre and Miquelon", "code": "PM"},
185
+ {"name": "Saint Vincent and the Grenadines", "code": "VC"},
186
+ {"name": "Samoa", "code": "WS"},
187
+ {"name": "San Marino", "code": "SM"},
188
+ {"name": "Sao Tome and Principe", "code": "ST"},
189
+ {"name": "Saudi Arabia", "code": "SA"},
190
+ {"name": "Senegal", "code": "SN"},
191
+ {"name": "Serbia and Montenegro", "code": "CS"},
192
+ {"name": "Seychelles", "code": "SC"},
193
+ {"name": "Sierra Leone", "code": "SL"},
194
+ {"name": "Singapore", "code": "SG"},
195
+ {"name": "Slovakia", "code": "SK"},
196
+ {"name": "Slovenia", "code": "SI"},
197
+ {"name": "Solomon Islands", "code": "SB"},
198
+ {"name": "Somalia", "code": "SO"},
199
+ {"name": "South Africa", "code": "ZA"},
200
+ {"name": "South Georgia and the South Sandwich Islands", "code": "GS"},
201
+ {"name": "Spain", "code": "ES"},
202
+ {"name": "Sri Lanka", "code": "LK"},
203
+ {"name": "Sudan", "code": "SD"},
204
+ {"name": "Suriname", "code": "SR"},
205
+ {"name": "Svalbard and Jan Mayen", "code": "SJ"},
206
+ {"name": "Swaziland", "code": "SZ"},
207
+ {"name": "Sweden", "code": "SE"},
208
+ {"name": "Switzerland", "code": "CH"},
209
+ {"name": "Syrian Arab Republic", "code": "SY"},
210
+ {"name": "Taiwan", "code": "TW"},
211
+ {"name": "Tajikistan", "code": "TJ"},
212
+ {"name": "Tanzania, United Republic of", "code": "TZ"},
213
+ {"name": "Thailand", "code": "TH"},
214
+ {"name": "Timor-Leste", "code": "TL"},
215
+ {"name": "Togo", "code": "TG"},
216
+ {"name": "Tokelau", "code": "TK"},
217
+ {"name": "Tonga", "code": "TO"},
218
+ {"name": "Trinidad and Tobago", "code": "TT"},
219
+ {"name": "Tunisia", "code": "TN"},
220
+ {"name": "Turkey", "code": "TR"},
221
+ {"name": "Turkmenistan", "code": "TM"},
222
+ {"name": "Turks and Caicos Islands", "code": "TC"},
223
+ {"name": "Tuvalu", "code": "TV"},
224
+ {"name": "Uganda", "code": "UG"},
225
+ {"name": "Ukraine", "code": "UA"},
226
+ {"name": "United Arab Emirates", "code": "AE"},
227
+ {"name": "United Kingdom", "code": "GB"},
228
+ {"name": "United States", "code": "US"},
229
+ {"name": "United States Minor Outlying Islands", "code": "UM"},
230
+ {"name": "Uruguay", "code": "UY"},
231
+ {"name": "Uzbekistan", "code": "UZ"},
232
+ {"name": "Vanuatu", "code": "VU"},
233
+ {"name": "Venezuela", "code": "VE"},
234
+ {"name": "Vietnam", "code": "VN"},
235
+ {"name": "Virgin Islands, British", "code": "VG"},
236
+ {"name": "Virgin Islands, U.S.", "code": "VI"},
237
+ {"name": "Wallis and Futuna", "code": "WF"},
238
+ {"name": "Western Sahara", "code": "EH"},
239
+ {"name": "Yemen", "code": "YE"},
240
+ {"name": "Zambia", "code": "ZM"},
241
+ {"name": "Zimbabwe","code": "ZN"}
242
+ ]
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ requests