-
Notifications
You must be signed in to change notification settings - Fork 0
/
ApiGenderChecker.py
executable file
·35 lines (29 loc) · 1 KB
/
ApiGenderChecker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
import sys
sys.path.append("/Users/arindam/Confessions/genderize")
from genderize import Genderize
if len(sys.argv)>1:
gender = sys.argv[1]
readFile = "firstNameList.dat"
writeFile = "apiFirstName.dat"
#genderNames = open("Text_Data/my"+gender+".txt").readlines()
#f = open("api"+gender+".txt",'w')
genderNames = open(readFile).readlines()
f = open(writeFile,'w')
count = 0
for i in range(len(genderNames)):
genderNames[i] = genderNames[i].strip()
genderList = []
for i in range(0,len(genderNames),10):
genderNams = genderNames[i:(i+10)]
genderList += Genderize().get(genderNams)
probability = count = 0
for i in range(len(genderList)):
if genderList[i]['gender'] is not None:
probability = genderList[i]['probability']
count = genderList[i]['count']
else:
genderList[i]['gender'] = "None"
print(genderNames[i]+":"+genderList[i]['gender']+","+str(count)+","+str(probability)+"\n")
f.write(genderNames[i]+":"+genderList[i]['gender']+","+str(count)+","+str(probability)+"\n")
f.close()