Created
June 22, 2023 15:47
-
-
Save wonhyeongseo/3448ddf86ed09037fc6252c0a76feea0 to your computer and use it in GitHub Desktop.
Using namechart.kr to deduce gender of a Korean name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
url = 'https://api.namechart.kr/search?query=' | |
def gender(name) -> tuple: | |
response = requests.get(f"{url}{name}", verify=False) | |
if response.status_code == 200: | |
data = response.json() | |
# contains female/male/total counts and | |
# resulting prediction based on trend as 'trendGender' | |
count = data['match']['count'] | |
return 'F' if count['female'] > count['male'] else 'M' | |
else : | |
print(response.status_code) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment